Skip to content

Commit

Permalink
Add coverage for can't-get-here 'else' clause.
Browse files Browse the repository at this point in the history
Addresses:
#1665 (comment)
  • Loading branch information
tseaver committed Mar 28, 2016
1 parent 145ec60 commit 9a9a376
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gcloud/logging/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def commit(self, client=None):
as_json_str = MessageToJson(entry)
as_json = json.loads(as_json_str)
info = {'protoPayload': as_json}
else: # pragma: NO COVER
else:
raise ValueError('Unknown entry type: %s' % (entry_type,))
entries.append(info)

Expand Down
9 changes: 9 additions & 0 deletions gcloud/logging/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@ def test_log_proto(self):
self.assertEqual(len(connection._requested), 0)
self.assertEqual(batch.entries, [('proto', message)])

def test_commit_w_invalid_entry_type(self):
logger = _Logger()
conn = _Connection()
CLIENT = _Client(project=self.PROJECT, connection=conn)
batch = self._makeOne(logger, CLIENT)
batch.entries.append(('bogus', 'BOGUS'))
with self.assertRaises(ValueError):
batch.commit()

def test_commit_w_bound_client(self):
import json
from google.protobuf.json_format import MessageToJson
Expand Down

0 comments on commit 9a9a376

Please sign in to comment.