def test_get_children(self):
     family = FamilyFactory()
     kids = [
         PersonFactory(membertype=Person.CHILD, family=family)
         for i in range(randint(1, 10))
     ]
     family_kids = family.get_children()
     for kid in kids:
         self.assertTrue(kid in family_kids)
     self.assertEqual(len(kids), len(family_kids))
Exemple #2
0
    def test_send_login_link_email(self):
        self.template = EmailTemplate(
            idname="LINK",
            name="TEMPLATE NAME",
            description="TEMPLATE DESCRIPTION",
            subject="TEMPLATE SUBJECT",
            body_html="TEMPLATE HTML",
            body_text="TEMPLATE TEXT",
        )
        self.template.save()

        family = FamilyFactory()
        family.send_link_email()
        EmailSendCronJob().do()
        self.assertEqual(1, len(mail.outbox))
        self.assertEqual("TEMPLATE SUBJECT", mail.outbox[0].subject)
    def test_send_login_link_email(self):
        self.template = EmailTemplate(
            idname="LINK",
            name="TEMPLATE NAME",
            description="TEMPLATE DESCRIPTION",
            subject="TEMPLATE SUBJECT",
            body_html="TEMPLATE HTML",
            body_text="TEMPLATE TEXT"
        )
        self.template.save()

        family = FamilyFactory()
        family.send_link_email()
        EmailSendCronJob().do()
        self.assertEqual(1, len(mail.outbox))
        self.assertEqual("TEMPLATE SUBJECT", mail.outbox[0].subject)
Exemple #4
0
    def test_saving_and_retrieving_family(self):
        family = FamilyFactory()
        PersonFactory(family=family)
        PersonFactory(family=family, membertype=Person.CHILD)

        self.assertEqual(family, Family.objects.first())
        self.assertEqual(1, Family.objects.count())
        self.assertEqual(2, Person.objects.count())
Exemple #5
0
 def setUp(self):
     self.email = "*****@*****.**"
     self.browser = webdriver.Remote("http://selenium:4444/wd/hub",
                                     DesiredCapabilities.CHROME)
     self.family = FamilyFactory()
     self.person = PersonFactory.create(family=self.family)
     self.first_kid = PersonFactory.create(family=self.family,
                                           membertype="CH")
     self.second_kid = PersonFactory.create(family=self.family,
                                            membertype="CH")
     self.activity = ActivityFactory.create(
         start_date=date.today(),
         signup_closing=date.today(),
         open_invite=True,
         max_participants=2,
         min_age=0,
         max_age=100,
     )
Exemple #6
0
 def test_string_representation(self):
     family = FamilyFactory(email="*****@*****.**")
     self.assertEqual("*****@*****.**", str(family))
Exemple #7
0
 def test_cannot_create_two_families_with_same_email(self):
     FamilyFactory(email="*****@*****.**")
     with self.assertRaises(IntegrityError):
         FamilyFactory(email="*****@*****.**")
Exemple #8
0
 def test_get_first_parent_when_guardian(self):
     family = FamilyFactory()
     p1 = PersonFactory(family=family, membertype=Person.GUARDIAN)
     PersonFactory(family=family, membertype=Person.PARENT)
     PersonFactory(family=family, membertype=Person.PARENT)
     self.assertEqual(p1, family.get_first_parent())
Exemple #9
0
 def test_get_first_parent(self):
     family = FamilyFactory()
     p1 = PersonFactory(family=family, membertype=Person.PARENT)
     PersonFactory(family=family, membertype=Person.PARENT)
     PersonFactory(family=family, membertype=Person.CHILD)
     self.assertEqual(p1, family.get_first_parent())
Exemple #10
0
 def test_get_first_parent_none_when_no_parents(self):
     family = FamilyFactory()
     PersonFactory(family=family, membertype=Person.CHILD)
     self.assertIsNone(family.get_first_parent())
Exemple #11
0
 def test_defaults_to_dont_send_mails(self):
     family = FamilyFactory()
     self.assertFalse(family.dont_send_mails)
 def test_get_first_parent_when_guardian(self):
     family = FamilyFactory()
     p1 = PersonFactory(family=family, membertype=Person.GUARDIAN)
     PersonFactory(family=family, membertype=Person.PARENT)
     PersonFactory(family=family, membertype=Person.PARENT)
     self.assertEqual(p1, family.get_first_parent())
 def test_get_first_parent(self):
     family = FamilyFactory()
     p1 = PersonFactory(family=family, membertype=Person.PARENT)
     PersonFactory(family=family, membertype=Person.PARENT)
     PersonFactory(family=family, membertype=Person.CHILD)
     self.assertEqual(p1, family.get_first_parent())
 def test_get_first_parent_none_when_no_parents(self):
     family = FamilyFactory()
     PersonFactory(family=family, membertype=Person.CHILD)
     self.assertIsNone(family.get_first_parent())