Skip to content

Commit

Permalink
add test on missing db_key exception
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkukral committed Sep 27, 2017
1 parent 7ec2cb1 commit 0b07655
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kqueen/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def get_field_names(self):
return fields

def get_db_key(self):
if not self.id:
if self.id and self.id.empty():
raise Exception('Missing object id')

return '{}{}'.format(self.__class__.get_db_prefix(), self.id.serialize())
Expand Down
6 changes: 6 additions & 0 deletions kqueen/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def test_exists(self, cluster):
cluster.save()
assert Cluster.exists(cluster.id)

def test_get_db_key_missing(self, cluster):
cluster.id.set_value(None)

with pytest.raises(Exception, match=r'Missing object id'):
cluster.get_db_key()


class TestFieldCompare:
def setup(self):
Expand Down

0 comments on commit 0b07655

Please sign in to comment.