Example #1
0
    def test_children_dont_get_reasigned(self):
        p1 = create_student_and_return('P1', child=False)
        p2 = create_student_and_return('P2', child=False)

        h1 = create_hobby_and_return('A')

        create_families_from_parents()

        s1 = create_student_and_return('S1', child=True)
        s1.hobbies.add(h1.id)

        assign_children_to_families()

        f1 = Family.objects.get(id=1)

        s1 = refresh_object(Student, s1)

        self.assertTrue(s1 in f1.children.all())
        self.assertTrue(s1.confirmed)

        p3 = create_student_and_return('P3', child=False)
        p4 = create_student_and_return('P4', child=False)
        p3.hobbies.add(h1.id)
        p4.hobbies.add(h1.id)

        create_families_from_parents()
        assign_children_to_families()

        f2 = Family.objects.get(id=2)

        self.assertFalse(s1 in f2.children.all())
Example #2
0
    def test_shows_parents_and_children_after_assignment(self):
        child = create_student_and_return('child', child=True)
        create_families_from_parents()
        assign_children_to_families()
        response = self.client.get(self.get_preferences_url(child.magic_id))
        self.assertContains(response, self.student1)
        self.assertContains(response, self.student2)

        response = self.client.get(
            self.get_preferences_url(self.student1.magic_id))
        self.assertContains(response, child)
Example #3
0
    def guys_can_get_assigned_to_anyone(self):
        create_student_and_return('P1', child=False, gender='F')
        create_student_and_return('P2', child=False, gender='F')

        s1 = create_student_and_return('S1', child=True, gender='M')

        create_families_from_parents()
        assign_children_to_families()

        s1 = refresh_object(Student, s1)

        self.assertNotEquals(s1.family_id, None)
Example #4
0
    def jmc_doesnt_get_comp_family(self):
        create_student_and_return('P1', child=False, course='C')
        create_student_and_return('P2', child=False, course='C')

        s1 = create_student_and_return('S1', child=True, course='J')

        create_families_from_parents()
        assign_children_to_families()

        s1 = refresh_object(Student, s1)

        self.assertEquals(s1.family_id, None)
Example #5
0
    def mixed_families_assign_correctly(self):
        create_student_and_return('P1', child=False, gender='M', course='J')
        create_student_and_return('P2', child=False, gender='F', course='C')

        s1 = create_student_and_return('S1', child=True, gender='F', course='J')
        s2 = create_student_and_return('S2', child=True, gender='M', course='C')

        create_families_from_parents()
        assign_children_to_families()

        s1 = refresh_object(Student, s1)
        s2 = refresh_object(Student, s2)

        self.assertNotEquals(s1.family_id, None)
        self.assertNotEquals(s2.family_id, None)
Example #6
0
    def test_family_set_after_assignment(self):
        p1 = create_student_and_return('P1', child=False)
        p2 = create_student_and_return('P2', child=False)

        create_families_from_parents()

        s1 = create_student_and_return('S1', child=True)

        assign_children_to_families()

        p1 = refresh_object(Student, p1)
        s1 = refresh_object(Student, s1)

        self.assertIsNotNone(p1.parents)
        self.assertIsNotNone(s1.parents)
Example #7
0
    def always_prefer_smaller_family_if_same_interest_overlap(self):
        create_student_and_return('P1', child=False)
        create_student_and_return('P2', child=False)
        create_student_and_return('P3', child=False)
        create_student_and_return('P4', child=False)

        s1 = create_student_and_return('S1', child=True)
        s2 = create_student_and_return('S2', child=True)

        create_families_from_parents()
        assign_children_to_families()

        s1 = refresh_object(Student, s1)
        s2 = refresh_object(Student, s2)

        self.assertNotEqual(s1.family, s2.family)
        self.assertNotEqual(s1.family, None)
        self.assertNotEqual(s2.family, None)
Example #8
0
    def test_assign_(self):
        p1 = create_student_and_return('P1', child=False)
        p2 = create_student_and_return('P2', child=False)
        p3 = create_student_and_return('P3', child=False)
        p4 = create_student_and_return('P4', child=False)

        h1 = create_hobby_and_return('A')
        h2 = create_hobby_and_return('B')

        p1.hobbies.add(h1.id)
        p2.hobbies.add(h2.id, h1.id)
        p3.hobbies.add(h2.id)
        p4.hobbies.add(h2.id)

        create_families_from_parents()

        p1 = refresh_object(Student, p1)
        p3 = refresh_object(Student, p3)

        self.assertEqual(p1.partner, p2)
        self.assertEqual(p3.partner, p4)

        s1 = create_student_and_return('S1', child=True)
        s2 = create_student_and_return('S2', child=True)

        s1.hobbies.add(h1.id, h2.id)
        s2.hobbies.add(h2.id)

        assign_children_to_families()

        s1 = refresh_object(Student, s1)
        s2 = refresh_object(Student, s2)

        f1 = Family.objects.get(id=1)
        f2 = Family.objects.get(id=2)

        self.assertTrue(s1 in f1.children.all())
        self.assertTrue(s2 in f2.children.all())