def test_invalid_postcode(self): result = functions.find_stores('xyz', 25) self.assertEqual(result, 'Invalid postcode', 'invalid postcode should return error message')
def test_postcode_outside_of_local_area(self): result = functions.find_stores('M3 5AL', 50) self.assertEqual(len(result), 0, 'Manchester postcode should return 0 stores')
def test_north_south_ordering_all_stores(self): result = functions.find_stores(self.postcode, 1000) self.assertEqual(result[-1]['name'], 'Eastbourne', 'most southerly store should be Eastbourne')
def test_kingsmeadow_postcode_with_radius_1000(self): result = functions.find_stores(self.postcode, 1000) self.assertEqual( len(result), 94, 'radius 1000 should return all except Bagshot (has nan values)')
def test_north_south_ordering_kingsmeadow_radius_10(self): result = functions.find_stores(self.postcode, 10) test = (result[-1]['latitude'] == min(store['latitude'] for store in result)) self.assertTrue( test, 'last store in result should have the lowest' + 'latitude')
def test_kingsmeadow_postcode_with_radius_10(self): result = functions.find_stores(self.postcode, 10) self.assertEqual( len(result), 6, 'radius 10 should return 6 stores Brentford, Richmond, Feltham,' + ' Wimbledon, New Malden, Walton-on-Thames')
def test_kingsmeadow_postcode_with_radius_0(self): result = functions.find_stores(self.postcode, 0) self.assertEqual(len(result), 0, 'radius 0 should return 0 stores')