Permalink
Browse files

rename Person.real_entities real_entity_memberships; tests

  • Loading branch information...
1 parent 293391a commit ec118c3d4c40638c259db99fa55243e9caacbc09 @evildmp committed Apr 26, 2013
@@ -712,8 +712,8 @@ def get_please_contact(self):
return self
@property
- def real_entities(self):
- # returns non-abstract entities the person belongs to
+ def real_entity_memberships(self):
+ # returns Memberships of non-abstract entities the person belongs to
return self.member_of.filter(entity__abstract_entity = False)
@@ -49,7 +49,7 @@
<div class="column lastcolumn">
<div class = "">
{% if image %}<img src="{{ image.url }}" alt="" />{% endif %}
- {% if person.real_entities.count > 1 %}
+ {% if person.real_entity_memberships.count > 1 %}
<h{{ IN_BODY_HEADING_LEVEL }}>Roles & memberships</h{{ IN_BODY_HEADING_LEVEL }}>
{% membership_tree_roots person %}
{% endif %}
@@ -177,8 +177,11 @@ def test_get_roles(self):
)
smith_school_membership.save()
people = [self.smith]
- self.assertEquals(self.school.get_roles_for_members(people), [self.smith])
-
+ self.assertEquals(
+ self.school.get_roles_for_members(people),
+ [self.smith]
+ )
+
class EntityAddressTests(EntityTestObjectsMixin, TestCase):
def test_get_building_works_when_building_is_assigned(self):
@@ -254,6 +257,7 @@ class PersonTests(EntityTestObjectsMixin, TestCase):
def test_person_with_no_memberships(self):
# smith has no Memberships
+ self.assertEquals(list(self.smith.real_entity_memberships), [])
self.assertEquals(self.smith.get_role, None)
self.assertEquals(self.smith.get_entity, None)
self.assertEquals(self.smith.get_building, None)
@@ -270,6 +274,7 @@ def test_person_with_abstract_entity_memberships(self):
)
smith_web_editor_membership.save()
+ self.assertEquals(list(self.smith.real_entity_memberships), [])
self.assertEquals(self.smith.get_role, None)
self.assertEquals(self.smith.get_entity, None)
self.assertEquals(self.smith.get_building, None)
@@ -295,6 +300,10 @@ def test_person_with_abstract_entity_and_real_entity_memberships(self):
)
smith_department_membership.save()
+ self.assertEquals(
+ list(self.smith.real_entity_memberships),
+ [smith_department_membership]
+ )
self.assertEquals(self.smith.get_role, smith_department_membership)
self.assertEquals(self.smith.get_entity, self.department)
self.assertEquals(self.smith.get_building, self.main_building)
@@ -329,6 +338,10 @@ def test_person_with_better_entity_membership(self):
)
smith_school_membership.save()
+ self.assertEquals(
+ list(self.smith.real_entity_memberships),
+ [smith_school_membership, smith_department_membership]
+ )
self.assertEquals(self.smith.get_role, smith_school_membership)
self.assertEquals(self.smith.get_entity, self.school)
self.assertEquals(self.smith.get_building, self.main_building)
@@ -338,6 +351,10 @@ def test_person_with_better_entity_membership(self):
smith_department_membership.importance_to_person = 5
smith_department_membership.save()
+ self.assertEquals(
+ list(self.smith.real_entity_memberships),
+ [smith_school_membership, smith_department_membership]
+ )
self.assertEquals(self.smith.get_role, smith_department_membership)
self.assertEquals(self.smith.get_entity, self.department)
self.assertEquals(self.smith.get_building, self.main_building)

0 comments on commit ec118c3

Please sign in to comment.