Exemplo n.º 1
0
    def test_both_names_account_form(self):
        """
        Filling out both name fields produces a valid save.
        """

        data = {"given_name": "Alicia", "family_name": "Smith", "gravatar": "*****@*****.**"}
        form = EditAccountForm(data, **{"user": self.user})
        self.assertTrue(form.is_valid())
Exemplo n.º 2
0
 def test_partial_name_account_form(self):
     """
     Filling out only the first name or only the last name produces an error.
     """
     data = {"given_name": "Alicia", "gravatar": "*****@*****.**", "user": self.user}
     form = EditAccountForm(data, **{"user": self.user})
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors["family_name"][0], "Both a first and last name required.")
Exemplo n.º 3
0
 def test_no_name_account_form(self):
     """
     Leaving both the first and last name fields blank produces a valid save.
     It also deletes the primary name object from the Name model.
     """
     data = {"gravatar": "*****@*****.**", "user": self.user}
     form = EditAccountForm(data, **{"user": self.user})
     self.assertTrue(form.is_valid())
     form.save(self.user)
     self.assertEqual(Name.objects.count(), 0)
Exemplo n.º 4
0
 def test_no_name_account_form(self):
     """
     Leaving both the first and last name fields blank produces a valid save.
     It also deletes the primary name object from the Name model.
     """
     data = {"gravatar": "*****@*****.**", "user": self.user}
     form = EditAccountForm(data, **{'user': self.user})
     self.assertTrue(form.is_valid())
     form.save(self.user)
     self.assertEqual(Name.objects.count(), 0)
Exemplo n.º 5
0
    def test_both_names_account_form(self):
        """
        Filling out both name fields produces a valid save.
        """

        data = {
            "given_name": "Alicia",
            "family_name": "Smith",
            "gravatar": "*****@*****.**"
        }
        form = EditAccountForm(data, **{'user': self.user})
        self.assertTrue(form.is_valid())
Exemplo n.º 6
0
 def test_partial_name_account_form(self):
     """
     Filling out only the first name or only the last name produces an error.
     """
     data = {
         "given_name": "Alicia",
         "gravatar": "*****@*****.**",
         "user": self.user
     }
     form = EditAccountForm(data, **{'user': self.user})
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors['family_name'][0],
                      "Both a first and last name required.")
Exemplo n.º 7
0
 def setUp(self):
     self.user = UserFactory()
     self.form = EditAccountForm(user=self.user, data={})
     self.context = Context({'form': self.form})
     self.template = Template(
         '{% load form_tags %}'
         '{% add_required_label form.visible_fields.2 %}')