Esempio n. 1
0
 def test_lookup_country_valid_postcode1(self):
     responses.add(responses.GET,
                   MAPS_API_GEOCODE_JSON + 'components=postal_code:AL10 9NE',
                   body=read_json_from_file(datafile('al109ne.json')),
                   match_querystring=True,
                   content_type='application/json')
     result = lookup_country('AL10 9NE')
     self.assertEqual(result, (None, 'GB', 'Hatfield', 51.7623259, -0.2438929))
 def test_lookup_country_valid_postcode1(self):
     responses.add(responses.GET,
                   MAPS_API_GEOCODE_JSON + 'components=postal_code:AL10 9NE',
                   body=read_json_from_file(datafile('al109ne.json')),
                   match_querystring=True,
                   content_type='application/json')
     result = lookup_country('AL10 9NE')
     self.assertEqual(result, (None, 'GB', 'Hatfield', 51.7623259, -0.2438929))
 def test_lookup_country_valid_postcode1(self):
     responses.add(responses.GET,
                   MAPS_API_GEOCODE_JSON + 'components=postal_code:SW72AZ',
                   body=read_json_from_file(datafile('sw72az.json')),
                   match_querystring=True,
                   content_type='application/json')
     result = lookup_country('SW72AZ')
     self.assertEqual(result, (None, 'GB', 'London', 51.5005046, -0.1782187))
Esempio n. 4
0
 def test_lookup_country_valid_postcode1(self):
     responses.add(responses.GET,
                   MAPS_API_GEOCODE_JSON + 'components=postal_code:SW72AZ',
                   body=read_json_from_file(datafile('sw72az.json')),
                   match_querystring=True,
                   content_type='application/json')
     result = lookup_country('SW72AZ')
     self.assertEqual(result, (None, 'GB', 'London', 51.5005046, -0.1782187))
 def test_lookup_country_invalid_postcode_zero_results(self):
     responses.add(responses.GET,
                   MAPS_API_GEOCODE_JSON + 'components=postal_code:xxxxx',
                   body=read_json_from_file(datafile('xxxxx.json')),
                   match_querystring=True,
                   content_type='application/json')
     error, country, town, lat, lng = lookup_country('xxxxx')
     assert 'API error' in error
     self.assert_default_country_and_coord(country, town, lat, lng)
Esempio n. 6
0
 def test_lookup_country_invalid_postcode_zero_results(self):
     responses.add(responses.GET,
                   MAPS_API_GEOCODE_JSON + 'components=postal_code:xxxxx',
                   body=read_json_from_file(datafile('xxxxx.json')),
                   match_querystring=True,
                   content_type='application/json')
     error, country, town, lat, lng = lookup_country('xxxxx')
     assert 'API error' in error
     self.assert_default_country_and_coord(country, town, lat, lng)
 def test_lookup_country_request_error_404(self):
     responses.add(responses.GET,
                   MAPS_API_GEOCODE_JSON + 'components=postal_code:AL109NE',
                   body=read_json_from_file(datafile('al109ne.json')),
                   status=requests.codes.not_found,
                   match_querystring=True,
                   content_type='application/json')
     error, country, town, lat, lng = lookup_country('AL109NE')
     assert 'Request error' in error
     self.assert_default_country_and_coord(country, town, lat, lng)
Esempio n. 8
0
 def test_lookup_country_request_error_404(self):
     responses.add(responses.GET,
                   MAPS_API_GEOCODE_JSON + 'components=postal_code:AL109NE',
                   body=read_json_from_file(datafile('al109ne.json')),
                   status=requests.codes.not_found,
                   match_querystring=True,
                   content_type='application/json')
     error, country, town, lat, lng = lookup_country('AL109NE')
     assert 'Request error' in error
     self.assert_default_country_and_coord(country, town, lat, lng)
 def test_lookup_country_valid_postcode1(self):
     responses.add(
         responses.GET,
         MAPS_API_GEOCODE_JSON + "components=postal_code:SW72AZ",
         body=read_json_from_file(datafile("sw72az.json")),
         match_querystring=True,
         content_type="application/json",
     )
     result = lookup_country("SW72AZ")
     self.assertEqual(result, (None, "GB", "London", 51.5005046, -0.1782187))
 def test_lookup_country_valid_postcode1(self):
     responses.add(
         responses.GET,
         MAPS_API_GEOCODE_JSON + "components=postal_code:AL10 9NE",
         body=read_json_from_file(datafile("al109ne.json")),
         match_querystring=True,
         content_type="application/json",
     )
     result = lookup_country("AL10 9NE")
     self.assertEqual(result, (None, "GB", "Hatfield", 51.7623259, -0.2438929))
    def populate_country(apps, schema_editor):

        School = apps.get_model("portal", "School")
        for school in School.objects.all():
            error, country, town, lat, lng = location.lookup_country(school.postcode)
            school.country = str(country)
            school.town = town
            school.lat = lat
            school.lng = lng
            school.save()
    def populate_country(apps, schema_editor):

        School = apps.get_model("portal", "School")
        for school in School.objects.all():
            error, country, town, lat, lng = location.lookup_country(school.postcode)
            school.country = str(country)
            school.town = town
            school.lat = lat
            school.lng = lng
            school.save()
 def test_lookup_country_valid_postcode1(self):
     responses.add(
         responses.GET,
         MAPS_API_GEOCODE_JSON + "components=postal_code:AL10 9NE",
         body=read_json_from_file(datafile("al109ne.json")),
         match_querystring=True,
         content_type="application/json",
     )
     result = lookup_country("AL10 9NE")
     self.assertEqual(result,
                      (None, "GB", "Hatfield", 51.7623259, -0.2438929))
 def test_lookup_country_valid_postcode1(self):
     responses.add(
         responses.GET,
         MAPS_API_GEOCODE_JSON + "components=postal_code:SW72AZ",
         body=read_json_from_file(datafile("sw72az.json")),
         match_querystring=True,
         content_type="application/json",
     )
     result = lookup_country("SW72AZ")
     self.assertEqual(result,
                      (None, "GB", "London", 51.5005046, -0.1782187))
 def test_lookup_country_connection_error(self):
     error, country, town, lat, lng = lookup_country("xxxxx")
     assert "Connection error" in error
 def test_lookup_country_connection_error(self):
     error, country, town, lat, lng = lookup_country("xxxxx")
     assert "Connection error" in error
 def test_lookup_country_connection_error(self):
     error, country, town, lat, lng = lookup_country('xxxxx')
     assert 'Connection error' in error
Esempio n. 18
0
 def test_lookup_country_connection_error(self):
     error, country, town, lat, lng = lookup_country('xxxxx')
     assert 'Connection error' in error