Skip to content

Commit

Permalink
Test and clarifying bool statement
Browse files Browse the repository at this point in the history
  • Loading branch information
timmartin19 committed Nov 9, 2015
1 parent 4707926 commit f9b6312
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ripozo/resources/relationships/relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _should_return_none(self, resource):
None is valid.
:rtype: bool
"""
return not resource.has_all_pks and not resource.no_pks and not self.templated
return not (resource.has_all_pks or resource.no_pks or self.templated)

def remove_child_resource_properties(self, properties):
"""
Expand Down
15 changes: 15 additions & 0 deletions ripozo_tests/unit/resources/relationships/relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,18 @@ def test_remove_child_resource_properties(self):
updated_properties = r.remove_child_resource_properties(original_properties)
self.assertDictEqual(updated_properties, expected)

def test_return_none(self):
"""Tests that the private _should_return_none appropriately
returns according to the expected behavior"""
class MyResource(ResourceBase):
pks = 'id',

res = MyResource(no_pks=True)
rel = Relationship('related')
self.assertFalse(rel._should_return_none(res))
res = MyResource(properties=dict(id=1))
self.assertFalse(rel._should_return_none(res))
res = MyResource(properties=dict())
self.assertTrue(rel._should_return_none(res))
rel.templated = True
self.assertFalse(rel._should_return_none(res))

0 comments on commit f9b6312

Please sign in to comment.