コード例 #1
0
 def test_two_ballots_one_cancelled(self):
     ee = EveryElectionWrapper(postcode="AA11AA")
     self.assertTrue(ee.request_success)
     self.assertTrue(ee.has_election())
     cancelled_info = ee.get_cancelled_election_info()
     self.assertEqual(cancelled_info["cancelled"], False)
     self.assertEqual(cancelled_info["name"], None)
     self.assertEqual(cancelled_info["rescheduled_date"], None)
     self.assertEqual(cancelled_info["metadata"], None)
コード例 #2
0
 def test_one_cancelled_ballot_no_replacement(self):
     ee = EveryElectionWrapper(postcode="AA11AA")
     self.assertTrue(ee.request_success)
     self.assertFalse(ee.has_election())
     cancelled_info = ee.get_cancelled_election_info()
     self.assertEqual(cancelled_info["cancelled"], True)
     self.assertEqual(cancelled_info["name"], "some election")
     self.assertEqual(cancelled_info["rescheduled_date"], None)
     self.assertEqual(cancelled_info["metadata"], None)
コード例 #3
0
 def test_one_cancelled_ballot_with_metadata(self):
     ee = EveryElectionWrapper(postcode="AA11AA")
     self.assertTrue(ee.request_success)
     self.assertFalse(ee.has_election())
     cancelled_info = ee.get_cancelled_election_info()
     self.assertEqual(cancelled_info["cancelled"], True)
     self.assertEqual(cancelled_info["name"], "some election")
     self.assertEqual(cancelled_info["rescheduled_date"], None)
     self.assertTrue("Oh noes!" in cancelled_info["metadata"]
                     ["cancelled_election"]["detail"])
     self.assertTrue("cancelled_election" in ee.get_metadata())
コード例 #4
0
 def test_one_cancelled_ballot_with_replacement(self):
     ee = EveryElectionWrapper(postcode="AA11AA")
     self.assertTrue(ee.request_success)
     self.assertFalse(ee.has_election())
     cancelled_info = ee.get_cancelled_election_info()
     self.assertEqual(cancelled_info["cancelled"], True)
     self.assertEqual(cancelled_info["name"], "this election")
     self.assertEqual(
         cancelled_info["rescheduled_date"],
         (datetime.now() + timedelta(weeks=1)).strftime("%-d %B %Y"),
     )
     self.assertEqual(cancelled_info["metadata"], None)
コード例 #5
0
 def test_elections_group_and_ballot(self):
     ee = EveryElectionWrapper(postcode="AA11AA")
     self.assertTrue(ee.request_success)
     self.assertTrue(ee.has_election())
     self.assertEqual([], ee.get_explanations())
     cancelled_info = ee.get_cancelled_election_info()
     self.assertEqual(cancelled_info["cancelled"], False)
     self.assertEqual(None, ee.get_metadata())
     self.assertEqual(None, ee.get_id_pilot_info())
コード例 #6
0
 def test_non_charismatic_elections(self):
     # there are upcoming elections
     # but they aren't on NEXT_CHARISMATIC_ELECTION_DATE
     ee = EveryElectionWrapper(postcode="AA11AA")
     self.assertTrue(ee.request_success)
     self.assertFalse(ee.has_election())
     self.assertEqual([], ee.get_explanations())
     cancelled_info = ee.get_cancelled_election_info()
     self.assertEqual(cancelled_info["cancelled"], False)
     self.assertEqual(None, ee.get_metadata())
     self.assertEqual(None, ee.get_id_pilot_info())
コード例 #7
0
 def test_settings_override_true(self):
     ee = EveryElectionWrapper(postcode="AA11AA")
     # election is not really happening here
     self.assertFalse(ee.has_election())
     # manually override it to true
     with override_settings(EVERY_ELECTION={"CHECK": False, "HAS_ELECTION": True}):
         ee = EveryElectionWrapper(postcode="AA11AA")
         self.assertTrue(ee.has_election())
コード例 #8
0
 def test_elections(self):
     ee = EveryElectionWrapper(postcode="AA11AA")
     self.assertTrue(ee.request_success)
     self.assertTrue(ee.has_election())
     self.assertEqual(
         [{"title": "some election", "explanation": "some text"}],
         ee.get_explanations(),
     )
     cancelled_info = ee.get_cancelled_election_info()
     self.assertEqual(cancelled_info["cancelled"], False)
     self.assertEqual(
         {"voter_id": {"this election": "has an ID pilot"}}, ee.get_metadata()
     )
     self.assertEqual({"this election": "has an ID pilot"}, ee.get_id_pilot_info())
コード例 #9
0
 def get_ee_wrapper(self, postcode):
     return EveryElectionWrapper(postcode)
コード例 #10
0
 def test_all_blacklisted(self):
     ee = EveryElectionWrapper(postcode="AA11AA")
     self.assertTrue(ee.request_success)
     self.assertFalse(ee.has_election())
コード例 #11
0
 def get_ee_wrapper(self, address):
     rh = RoutingHelper(address.postcode)
     if not rh.address_have_single_station:
         if address.location:
             return EveryElectionWrapper(point=address.location)
     return EveryElectionWrapper(postcode=address.postcode)
コード例 #12
0
 def test_elections(self):
     ee = EveryElectionWrapper('AA11AA')
     self.assertTrue(ee.request_success)
     self.assertTrue(ee.has_election())
     self.assertEqual(['some text'], ee.get_explanations())