예제 #1
0
파일: forms.py 프로젝트: panyang/MyJobs
 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.")
예제 #2
0
파일: forms.py 프로젝트: panyang/MyJobs
    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())
예제 #3
0
파일: forms.py 프로젝트: panyang/MyJobs
 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)
예제 #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)
예제 #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())
예제 #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.")