def test_make_addresses_for_postcode(self): # Before the fix, we wrongly assume that we know the polling station postcode = 'KW15 88TF' rh = RoutingHelper(postcode) endpoint = rh.get_endpoint() self.assertEqual('postcode_view', endpoint.view) # Fix the addresses outside of the districts make_addresses_for_postcode(postcode, council_id="X01000001") # Now we should get offered an address lookup rh = RoutingHelper(postcode) endpoint = rh.get_endpoint() self.assertEqual('address_select_view', endpoint.view)
def test_make_addresses_for_postcode(self): # Before the fix, we wrongly assume that we know the polling station postcode = 'KW15 88TF' rh = RoutingHelper(postcode) endpoint = rh.get_endpoint() self.assertEqual('postcode_view', endpoint.view) # Fix the addresses outside of the districts make_addresses_for_postcode(postcode, council_id="X01000001") # Now we should get offered an address lookup rh = RoutingHelper(postcode) endpoint = rh.get_endpoint() self.assertEqual('address_select_view', endpoint.view)
def test_make_addresses_for_postcode(self): # Before the fix, we wrongly assume that we know the polling station postcode = 'KW15 88TF' rh = RoutingHelper(postcode) endpoint = rh.get_endpoint() self.assertEqual('postcode_view', endpoint.view) # Fix the addresses outside of the districts fixer = EdgeCaseFixer("X01000001", MockLogger()) fixer.make_addresses_for_postcode(postcode) fixer.get_address_set().save(1000) # Now we should get offered an address lookup rh = RoutingHelper(postcode) endpoint = rh.get_endpoint() self.assertEqual('address_select_view', endpoint.view)
def test_multiple_councils_view_override(self): # insert blacklist records for postcodes matching other conditions Blacklist.objects.create(postcode="AA11AA", lad="X01000001") Blacklist.objects.create(postcode="AA11AA", lad="W06000022") Blacklist.objects.create(postcode="BB11BB", lad="X01000001") Blacklist.objects.create(postcode="BB11BB", lad="W06000022") Blacklist.objects.create(postcode="CC11CC", lad="X01000001") Blacklist.objects.create(postcode="CC11CC", lad="W06000022") # check the blacklist overrides all other conditions rh = RoutingHelper("AA11AA") endpoint = rh.get_endpoint() self.assertEqual("multiple_councils_view", endpoint.view) rh = RoutingHelper("BB11BB") endpoint = rh.get_endpoint() self.assertEqual("multiple_councils_view", endpoint.view) rh = RoutingHelper("CC11CC") endpoint = rh.get_endpoint() self.assertEqual("multiple_councils_view", endpoint.view)
def test_multiple_councils_view_override(self): # insert blacklist records for postcodes matching other conditions Blacklist.objects.create(postcode='AA11AA', lad='X01000001') Blacklist.objects.create(postcode='AA11AA', lad='W06000022') Blacklist.objects.create(postcode='BB11BB', lad='X01000001') Blacklist.objects.create(postcode='BB11BB', lad='W06000022') Blacklist.objects.create(postcode='CC11CC', lad='X01000001') Blacklist.objects.create(postcode='CC11CC', lad='W06000022') # check the blacklist overrides all other conditions rh = RoutingHelper('AA11AA') endpoint = rh.get_endpoint() self.assertEqual('multiple_councils_view', endpoint.view) rh = RoutingHelper('BB11BB') endpoint = rh.get_endpoint() self.assertEqual('multiple_councils_view', endpoint.view) rh = RoutingHelper('CC11CC') endpoint = rh.get_endpoint() self.assertEqual('multiple_councils_view', endpoint.view)
def test_address_view(self): rh = RoutingHelper("AA11AA") endpoint = rh.get_endpoint() self.assertEqual("address_view", endpoint.view)
def test_multiple_councils_lowercase_postcode(self): # check we are directed to multiple_councils_view if # postcode is attached to multiple councils in the blacklist rh = RoutingHelper("dd11dd") endpoint = rh.get_endpoint() self.assertEqual("multiple_councils_view", endpoint.view)
def test_postcode_view(self): rh = RoutingHelper("CC11CC") endpoint = rh.get_endpoint() self.assertEqual("postcode_view", endpoint.view)
def test_address_select_view(self): rh = RoutingHelper("BB11BB") endpoint = rh.get_endpoint() self.assertEqual("address_select_view", endpoint.view)
def test_address_view(self): rh = RoutingHelper('AA11AA') endpoint = rh.get_endpoint() self.assertEqual('address_view', endpoint.view)
def test_multiple_councils_view(self): # check we are directed to multiple_councils_view if # postcode is attached to multiple councils in the blacklist rh = RoutingHelper('DD11DD') endpoint = rh.get_endpoint() self.assertEqual('multiple_councils_view', endpoint.view)
def test_postcode_view(self): rh = RoutingHelper('CC11CC') endpoint = rh.get_endpoint() self.assertEqual('postcode_view', endpoint.view)
def test_address_select_view(self): rh = RoutingHelper('BB11BB') endpoint = rh.get_endpoint() self.assertEqual('address_select_view', endpoint.view)
def test_address_view(self): rh = RoutingHelper('AA11AA') endpoint = rh.get_endpoint() self.assertEqual('address_view', endpoint.view)
def test_postcode_view(self): rh = RoutingHelper('CC11CC') endpoint = rh.get_endpoint() self.assertEqual('postcode_view', endpoint.view)
def test_address_select_view(self): rh = RoutingHelper('BB11BB') endpoint = rh.get_endpoint() self.assertEqual('address_select_view', endpoint.view)