Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure tests get coverage too. #209

Merged
merged 2 commits into from
Oct 2, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions gcloud/datastore/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,6 @@ def test_save_entity_w_transaction(self):
mutation = datastore_pb.Mutation()

class Xact(object):

def id(self):
return 'xact'

def mutation(self):
return mutation
DATASET_ID = 'DATASET'
Expand Down Expand Up @@ -746,10 +742,6 @@ def test_delete_entities_w_transaction(self):
mutation = datastore_pb.Mutation()

class Xact(object):

def id(self):
return 'xact'

def mutation(self):
return mutation
DATASET_ID = 'DATASET'
Expand Down Expand Up @@ -821,10 +813,6 @@ def test_delete_entity_w_transaction(self):
mutation = datastore_pb.Mutation()

class Xact(object):

def id(self):
return 'xact'

def mutation(self):
return mutation
DATASET_ID = 'DATASET'
Expand Down
5 changes: 0 additions & 5 deletions gcloud/datastore/test_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ def _makeOne(self, dataset=_MARKER, kind=_KIND):
klass = self._getTargetClass()
if dataset is _MARKER:
dataset = Dataset(_DATASET_ID)
if kind is _MARKER:
kind = _KIND
return klass(dataset, kind)

def test_ctor_defaults(self):
Expand Down Expand Up @@ -215,9 +213,6 @@ def connection(self):
def get_entity(self, key):
return self.get(key)

def get_entities(self, keys):
return [self.get(x) for x in keys]


class _Connection(object):
_transaction = _saved = _deleted = None
Expand Down
18 changes: 4 additions & 14 deletions gcloud/storage/test_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,24 +365,14 @@ def __init__(self, *responses):
self._requested = []

def make_request(self, **kw):
from gcloud.storage.exceptions import NotFoundError
self._requested.append(kw)
try:
response, self._responses = self._responses[0], self._responses[1:]
except:
raise NotFoundError('miss', None)
else:
return response
response, self._responses = self._responses[0], self._responses[1:]
return response

def api_request(self, **kw):
from gcloud.storage.exceptions import NotFoundError
self._requested.append(kw)
try:
response, self._responses = self._responses[0], self._responses[1:]
except:
raise NotFoundError('miss', None)
else:
return response
response, self._responses = self._responses[0], self._responses[1:]
return response

def build_api_url(self, path, query_params=None):
from urllib import urlencode
Expand Down
42 changes: 13 additions & 29 deletions gcloud/storage/test_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ def test_set_contents_from_file(self):
KEY = 'key'
UPLOAD_URL = 'http://example.com/upload/name/key'
DATA = 'ABCDEF'
loc_response = _Response(location=UPLOAD_URL)
chunk1_response = _Response()
chunk2_response = _Response()
loc_response = {'location': UPLOAD_URL}
chunk1_response = {}
chunk2_response = {}
connection = _Connection((loc_response, ''),
(chunk1_response, ''),
(chunk2_response, ''),
Expand Down Expand Up @@ -201,9 +201,9 @@ def test_set_contents_from_filename(self):
KEY = 'key'
UPLOAD_URL = 'http://example.com/upload/name/key'
DATA = 'ABCDEF'
loc_response = _Response(location=UPLOAD_URL)
chunk1_response = _Response()
chunk2_response = _Response()
loc_response = {'location': UPLOAD_URL}
chunk1_response = {}
chunk2_response = {}
connection = _Connection((loc_response, ''),
(chunk1_response, ''),
(chunk2_response, ''),
Expand Down Expand Up @@ -245,9 +245,9 @@ def test_set_contents_from_string(self):
KEY = 'key'
UPLOAD_URL = 'http://example.com/upload/name/key'
DATA = 'ABCDEF'
loc_response = _Response(location=UPLOAD_URL)
chunk1_response = _Response()
chunk2_response = _Response()
loc_response = {'location': UPLOAD_URL}
chunk1_response = {}
chunk2_response = {}
connection = _Connection((loc_response, ''),
(chunk1_response, ''),
(chunk2_response, ''),
Expand Down Expand Up @@ -556,12 +556,6 @@ def test_make_public(self):
self.assertEqual(kw[0]['query_params'], {'projection': 'full'})


class _Response(dict):
@property
def status(self):
return self.get('status', 200)


class _Connection(object):
API_BASE_URL = 'http://example.com'

Expand All @@ -570,24 +564,14 @@ def __init__(self, *responses):
self._requested = []

def make_request(self, **kw):
from gcloud.storage.exceptions import NotFoundError
self._requested.append(kw)
try:
response, self._responses = self._responses[0], self._responses[1:]
except:
raise NotFoundError('miss', None)
else:
return response
response, self._responses = self._responses[0], self._responses[1:]
return response

def api_request(self, **kw):
from gcloud.storage.exceptions import NotFoundError
self._requested.append(kw)
try:
response, self._responses = self._responses[0], self._responses[1:]
except:
raise NotFoundError('miss', None)
else:
return response
response, self._responses = self._responses[0], self._responses[1:]
return response

def build_api_url(self, path, query_params=None,
api_base_url=API_BASE_URL):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ deps =
basepython =
python2.7
commands =
nosetests --with-xunit --with-xcoverage --cover-package=gcloud --nocapture --cover-erase
nosetests --with-xunit --with-xcoverage --cover-package=gcloud --nocapture --cover-erase --cover-tests
deps =
nose
unittest2
Expand Down