Ejemplo n.º 1
0
    def test_set_items_for_person(self):
        p = Person()
        p.save()
        self.item1.please_contact.add(p)

        self.itemlist.person = p
        self.itemlist.set_items_for_person()

        self.assertEqual(list(self.itemlist.items), [self.item1])
Ejemplo n.º 2
0
    def test_set_items_for_person_featuring(self):
        p = Person()
        p.save()
        self.item1.featuring.add(p)

        self.itemlist.person = p
        self.itemlist.set_items_for_person()

        self.assertEqual(list(self.itemlist.items), [self.item1])
Ejemplo n.º 3
0
    def test_set_items_for_person(self):
        p = Person()
        p.save()
        self.item1.please_contact.add(p)

        itemlist = ItemList()
        itemlist.items = TestModel.objects.all()
        itemlist.person = p
        itemlist.set_items_for_person()

        self.assertEqual(
            list(itemlist.items),
            [self.item1]
        )
Ejemplo n.º 4
0
    def setUp(self):
        #  a geographical Site
        self.cardiff = Site(
            site_name="Main site",
            post_town="Cardiff",
            country="UK",
        )
        self.cardiff.save()

        #  a couple of Buildings on the Site
        self.main_building = Building(
            name="Main Building",
            street="St Mary's Street",
            site=self.cardiff,
        )
        self.main_building.save()

        self.heart_testing_centre = Building(
            name="Heart Testing Centre",
            street="Queen Street",
            site=self.cardiff,
        )
        self.heart_testing_centre.save()

        #  create some Entities in a hierarchy

        #    School of Medicine
        #        Departments (an abstract entity)
        #            Department of Cardiology
        #                Section of Heart Research
        #                Heart Testing Centre
        #                Department of Cardiology Student Centre
        #        Web editors (an abstract entity)

        self.school = Entity(
            name="School of Medicine",
            building=self.main_building,
            slug="medicine",
        )
        self.school.save()

        self.departments = Entity(
            name="departments",
            parent=self.school,
            slug="departments",
            abstract_entity=True,
            building=self.heart_testing_centre,
            # this should be ignored by everything!
        )
        self.departments.save()

        self.department = Entity(
            name="Department of Cardiology",
            parent=self.departments,
            slug="cardiology",
        )
        self.department.save()

        self.section = Entity(
            name="Section of Heart Research",
            parent=self.department,
            slug="heart-research",
        )
        self.section.save()

        self.testing_centre = Entity(
            name="Testing Centre",
            parent=self.department,
            slug="testing-centre",
            building_recapitulates_entity_name=True,
            building=self.heart_testing_centre,
        )
        self.testing_centre.save()

        self.student_centre = Entity(
            name="Department of Cardiology Student Centre",
            parent=self.department,
            slug="student-centre",
            display_parent=False,
        )
        self.student_centre.save()

        self.web_editors = Entity(
            name="Group of web editors",
            parent=self.school,
            slug="web-editors",
            abstract_entity=True,
        )
        self.web_editors.save()

        # set up a Person - we will add memberships later in the tests
        self.smith = Person(slug="smith")
        self.smith.save()