コード例 #1
0
 def test_update_person_form_not_standing_no_party_no_constituency(self):
     form = UpdatePersonForm(
         {
             "name": "John Doe",
             "source": "Just testing...",
             "standing_2015": "not-standing",
         },
         initial={"person": self.person},
     )
     self.assertTrue(form.is_valid())
コード例 #2
0
 def test_update_person_form_standing_party_and_gb_constituency(self):
     form = UpdatePersonForm(
         {
             "name": "John Doe",
             "source": "Just testing...",
             "standing_2015": "standing",
             "constituency_2015": "65808",
             "party_GB_2015": self.conservative_party.id,
         },
         initial={"person": self.person},
     )
     self.assertTrue(form.is_valid())
コード例 #3
0
 def test_update_person_form_standing_no_party_but_gb_constituency(self):
     form = UpdatePersonForm(
         {
             "name": "John Doe",
             "source": "Just testing...",
             "standing_2015": "standing",
             "constituency_2015": "65808",
         },
         initial={"person": self.person},
     )
     self.assertFalse(form.is_valid())
     self.assertEqual(
         form.errors,
         {
             "__all__":
             ["You must specify a party for the 2015 General Election"]
         },
     )
コード例 #4
0
 def test_update_person_form_standing_no_party_no_constituency(self):
     form = UpdatePersonForm(
         {
             "name": "John Doe",
             "source": "Just testing...",
             "standing_2015": "standing",
         },
         initial={"person": self.person},
     )
     self.assertFalse(form.is_valid())
     self.assertEqual(
         form.errors,
         {
             "__all__": [
                 "If you mark the candidate as standing in the 2015 General Election, you must select a post"
             ]
         },
     )