Skip to content

Commit

Permalink
Removing unused nvariablesdetected by pyflakes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Oct 7, 2014
1 parent 6dd5f2b commit 114fe90
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 95 deletions.
3 changes: 0 additions & 3 deletions gcloud/datastore/connection.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import httplib2

from gcloud import connection
from gcloud.datastore import datastore_v1_pb2 as datastore_pb
from gcloud.datastore import helpers
from gcloud.datastore.dataset import Dataset
from gcloud.datastore.transaction import Transaction


class Connection(connection.Connection):
Expand Down
27 changes: 2 additions & 25 deletions gcloud/datastore/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test__request_not_200(self):
METHOD = 'METHOD'
DATA = 'DATA'
conn = self._makeOne()
http = conn._http = Http({'status': '400'}, 'Bad Request')
conn._http = Http({'status': '400'}, 'Bad Request')
with self.assertRaises(Exception) as e:
conn._request(DATASET_ID, METHOD, DATA)
self.assertEqual(str(e.exception),
Expand Down Expand Up @@ -199,7 +199,6 @@ def test_begin_transaction_w_existing_transaction(self):
def test_begin_transaction_default_serialize(self):
from gcloud.datastore.connection import datastore_pb

xact = object()
DATASET_ID = 'DATASET'
TRANSACTION = 'TRANSACTION'
rsp_pb = datastore_pb.BeginTransactionResponse()
Expand Down Expand Up @@ -230,7 +229,6 @@ def test_begin_transaction_default_serialize(self):
def test_begin_transaction_explicit_serialize(self):
from gcloud.datastore.connection import datastore_pb

xact = object()
DATASET_ID = 'DATASET'
TRANSACTION = 'TRANSACTION'
rsp_pb = datastore_pb.BeginTransactionResponse()
Expand Down Expand Up @@ -368,7 +366,7 @@ def test_run_query_w_namespace_nonempty_result(self):
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
pbs, end, more, skipped = conn.run_query(DATASET_ID, q_pb, 'NS')
returned, = pbs, # One entity.
self.assertEqual(len(pbs), 1)
cw = http._called_with
self.assertEqual(cw['uri'], URI)
self.assertEqual(cw['method'], 'POST')
Expand Down Expand Up @@ -694,13 +692,6 @@ def mutation(self):
rsp_pb = datastore_pb.CommitResponse()
conn = self._makeOne()
conn.transaction(Xact())
URI = '/'.join([conn.API_BASE_URL,
'datastore',
conn.API_VERSION,
'datasets',
DATASET_ID,
'commit',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
result = conn.save_entity(DATASET_ID, key_pb, {'foo': 'Foo'})
self.assertEqual(result, True)
Expand Down Expand Up @@ -765,13 +756,6 @@ def mutation(self):
rsp_pb = datastore_pb.CommitResponse()
conn = self._makeOne()
conn.transaction(Xact())
URI = '/'.join([conn.API_BASE_URL,
'datastore',
conn.API_VERSION,
'datasets',
DATASET_ID,
'commit',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
result = conn.delete_entities(DATASET_ID, [key_pb])
self.assertEqual(result, True)
Expand Down Expand Up @@ -837,13 +821,6 @@ def mutation(self):
rsp_pb = datastore_pb.CommitResponse()
conn = self._makeOne()
conn.transaction(Xact())
URI = '/'.join([conn.API_BASE_URL,
'datastore',
conn.API_VERSION,
'datasets',
DATASET_ID,
'commit',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
result = conn.delete_entity(DATASET_ID, key_pb)
self.assertEqual(result, True)
Expand Down
1 change: 0 additions & 1 deletion gcloud/datastore/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def test_datetime(self):
import datetime
import pytz

naive = datetime.datetime(2014, 9, 16, 10, 19, 32, 4375) # No zone.
utc = datetime.datetime(2014, 9, 16, 10, 19, 32, 4375, pytz.utc)
micros = (calendar.timegm(utc.timetuple()) * 1000000) + 4375
pb = self._makePB('timestamp_microseconds_value', micros)
Expand Down
1 change: 0 additions & 1 deletion gcloud/datastore/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def test_ctor_explicit(self):
from gcloud.datastore.dataset import Dataset

_DATASET = 'DATASET'
_NAMESPACE = 'NAMESPACE'
_KIND = 'KIND'
dataset = Dataset(_DATASET)
query = self._makeOne(_KIND, dataset)
Expand Down
4 changes: 2 additions & 2 deletions gcloud/datastore/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_commit_w_already(self):
connection = _Connection(234)
dataset = _Dataset(_DATASET, connection)
xact = self._makeOne(dataset)
xact._mutation = mutation = object()
xact._mutation = object()
xact.begin()
connection.transaction(()) # Simulate previous commit via false-ish.
xact.commit()
Expand Down Expand Up @@ -118,7 +118,7 @@ class Foo(Exception):
connection = _Connection(234)
dataset = _Dataset(_DATASET, connection)
xact = self._makeOne(dataset)
xact._mutation = mutation = object()
xact._mutation = object()
try:
with xact:
self.assertEqual(xact.id(), 234)
Expand Down
3 changes: 1 addition & 2 deletions gcloud/storage/connection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import base64
import datetime
import httplib2
import json
import time
import urllib
Expand Down Expand Up @@ -390,7 +389,7 @@ def delete_bucket(self, bucket, force=False):
for key in bucket:
key.delete()

response = self.api_request(method='DELETE', path=bucket.path)
self.api_request(method='DELETE', path=bucket.path)
return True

def new_bucket(self, bucket):
Expand Down
1 change: 0 additions & 1 deletion gcloud/storage/key.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import errno
import json
import mimetypes
import os
from StringIO import StringIO
Expand Down
2 changes: 1 addition & 1 deletion gcloud/storage/test_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test___iter___non_empty_no_roles(self):
TYPE = 'type'
ID = 'id'
acl = self._makeOne()
entity = acl.entity(TYPE, ID)
acl.entity(TYPE, ID)
self.assertEqual(list(acl), [])

def test___iter___non_empty_w_roles(self):
Expand Down
5 changes: 0 additions & 5 deletions gcloud/storage/test_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ def test_delete_key_hit(self):

def test_delete_keys_empty(self):
NAME = 'name'
NONESUCH = 'nonesuch'
connection = _Connection()
bucket = self._makeOne(connection, NAME)
bucket.delete_keys([])
Expand Down Expand Up @@ -509,7 +508,6 @@ def test_disable_website(self):
def test_reload_acl_eager_empty(self):
from gcloud.storage.acl import BucketACL
metadata = {'acl': []}
connection = _Connection()
bucket = self._makeOne(metadata=metadata)
self.assertTrue(bucket.reload_acl() is bucket)
self.assertTrue(isinstance(bucket.acl, BucketACL))
Expand All @@ -519,7 +517,6 @@ def test_reload_acl_eager_nonempty(self):
from gcloud.storage.acl import BucketACL
ROLE = 'role'
metadata = {'acl': [{'entity': 'allUsers', 'role': ROLE}]}
connection = _Connection()
bucket = self._makeOne(metadata=metadata)
self.assertTrue(bucket.reload_acl() is bucket)
self.assertTrue(isinstance(bucket.acl, BucketACL))
Expand Down Expand Up @@ -623,7 +620,6 @@ def test_clear_acl(self):
def test_reload_default_object_acl_eager_empty(self):
from gcloud.storage.acl import BucketACL
metadata = {'defaultObjectAcl': []}
connection = _Connection()
bucket = self._makeOne(metadata=metadata)
self.assertTrue(bucket.reload_default_object_acl() is bucket)
self.assertTrue(isinstance(bucket.default_object_acl, BucketACL))
Expand All @@ -633,7 +629,6 @@ def test_reload_default_object_acl_eager_nonempty(self):
from gcloud.storage.acl import BucketACL
ROLE = 'role'
metadata = {'defaultObjectAcl': [{'entity': 'allUsers', 'role': ROLE}]}
connection = _Connection()
bucket = self._makeOne(metadata=metadata)
self.assertTrue(bucket.reload_default_object_acl() is bucket)
self.assertTrue(isinstance(bucket.default_object_acl, BucketACL))
Expand Down
64 changes: 16 additions & 48 deletions gcloud/storage/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def test___contains___hit(self):

def test_build_api_url_no_extra_query_params(self):
PROJECT = 'project'
KEY = 'key'
conn = self._makeOne(PROJECT)
URI = '/'.join([conn.API_BASE_URL,
'storage',
Expand All @@ -136,13 +135,7 @@ def test_build_api_url_w_extra_query_params(self):
from urlparse import parse_qsl
from urlparse import urlsplit
PROJECT = 'project'
KEY = 'key'
conn = self._makeOne(PROJECT)
URI = '/'.join([conn.API_BASE_URL,
'storage',
conn.API_VERSION,
'foo'
])
uri = conn.build_api_url('/foo', {'bar': 'baz'})
scheme, netloc, path, qs, frag = urlsplit(uri)
self.assertEqual('%s://%s' % (scheme, netloc), conn.API_BASE_URL)
Expand Down Expand Up @@ -237,29 +230,19 @@ def test_api_request_defaults(self):
def test_api_request_w_non_json_response(self):
PROJECT = 'project'
conn = self._makeOne(PROJECT)
URI = '/'.join([conn.API_BASE_URL,
'storage',
conn.API_VERSION,
'?project=%s' % PROJECT,
])
http = conn._http = Http({'status': '200',
'content-type': 'text/plain',
},
'CONTENT')
conn._http = Http({'status': '200',
'content-type': 'text/plain',
},
'CONTENT')
self.assertRaises(TypeError, conn.api_request, 'GET', '/')

def test_api_request_wo_json_expected(self):
PROJECT = 'project'
conn = self._makeOne(PROJECT)
URI = '/'.join([conn.API_BASE_URL,
'storage',
conn.API_VERSION,
'?project=%s' % PROJECT,
])
http = conn._http = Http({'status': '200',
'content-type': 'text/plain',
},
'CONTENT')
conn._http = Http({'status': '200',
'content-type': 'text/plain',
},
'CONTENT')
self.assertEqual(conn.api_request('GET', '/', expect_json=False),
'CONTENT')

Expand All @@ -268,11 +251,6 @@ def test_api_request_w_query_params(self):
from urlparse import urlsplit
PROJECT = 'project'
conn = self._makeOne(PROJECT)
URI = '/'.join([conn.API_BASE_URL,
'storage',
conn.API_VERSION,
'?project=%s&foo=bar' % PROJECT,
])
http = conn._http = Http({'status': '200',
'content-type': 'application/json',
},
Expand Down Expand Up @@ -324,30 +302,20 @@ def test_api_request_w_404(self):
from gcloud.storage.exceptions import NotFoundError
PROJECT = 'project'
conn = self._makeOne(PROJECT)
URI = '/'.join([conn.API_BASE_URL,
'storage',
conn.API_VERSION,
'?project=%s' % PROJECT,
])
http = conn._http = Http({'status': '404',
'content-type': 'text/plain',
},
'')
conn._http = Http({'status': '404',
'content-type': 'text/plain',
},
'')
self.assertRaises(NotFoundError, conn.api_request, 'GET', '/')

def test_api_request_w_500(self):
from gcloud.storage.exceptions import ConnectionError
PROJECT = 'project'
conn = self._makeOne(PROJECT)
URI = '/'.join([conn.API_BASE_URL,
'storage',
conn.API_VERSION,
'?project=%s' % PROJECT,
])
http = conn._http = Http({'status': '500',
'content-type': 'text/plain',
},
'')
conn._http = Http({'status': '500',
'content-type': 'text/plain',
},
'')
self.assertRaises(ConnectionError, conn.api_request, 'GET', '/')

def test_get_all_buckets_empty(self):
Expand Down
6 changes: 0 additions & 6 deletions gcloud/storage/test_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,13 @@ def test_get_contents_to_file(self):

def test_get_contents_to_filename(self):
from tempfile import NamedTemporaryFile
from StringIO import StringIO
from gcloud.test_credentials import _Monkey
from gcloud.storage import key as MUT
_CHUNKS = ['abc', 'def']
KEY = 'key'
connection = _Connection()
bucket = _Bucket(connection)
key = self._makeOne(bucket, KEY)
fh = StringIO()
with _Monkey(MUT, KeyDataIterator=lambda self: iter(_CHUNKS)):
with NamedTemporaryFile() as f:
key.get_contents_to_filename(f.name)
Expand Down Expand Up @@ -423,8 +421,6 @@ def test_patch_metadata(self):
def test_reload_acl_eager_empty(self):
from gcloud.storage.acl import ObjectACL
metadata = {'acl': []}
connection = _Connection()
bucket = _Bucket(connection)
key = self._makeOne(metadata=metadata)
self.assertTrue(key.reload_acl() is key)
self.assertTrue(isinstance(key.acl, ObjectACL))
Expand All @@ -434,8 +430,6 @@ def test_reload_acl_eager_nonempty(self):
from gcloud.storage.acl import ObjectACL
ROLE = 'role'
metadata = {'acl': [{'entity': 'allUsers', 'role': ROLE}]}
connection = _Connection()
bucket = _Bucket(connection)
key = self._makeOne(metadata=metadata)
self.assertTrue(key.reload_acl() is key)
self.assertTrue(isinstance(key.acl, ObjectACL))
Expand Down

0 comments on commit 114fe90

Please sign in to comment.