Skip to content

Commit

Permalink
Merge pull request #209 from tseaver/coverage_for_tests
Browse files Browse the repository at this point in the history
Ensure tests get coverage too.
  • Loading branch information
silvolu committed Oct 2, 2014
2 parents 4b2f3a9 + 9538e94 commit 43f8bb6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 61 deletions.
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 @@ -19,8 +19,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 @@ -214,9 +212,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

0 comments on commit 43f8bb6

Please sign in to comment.