예제 #1
0
 def get_or_create_from_postcode(cls, postcode):
     az = Adzuna()
     try:
         locations = az.locations_for_postcode(postcode)
     except AssertionError:
         raise PostcodeNotFoundError()
     job_centre_label = None
     for location_label, location_list in settings.LOCATION_LABELS.items():
         if list(location_list['locations']) == locations:
             job_centre_label = location_label
             break
     obj, created = cls.objects.get_or_create(
         locations=locations, job_centre_label=job_centre_label)
     obj.save()
     return obj, created
예제 #2
0
 def get_or_create_from_postcode(cls, postcode):
     az = Adzuna()
     try:
         locations = az.locations_for_postcode(postcode)
     except AssertionError:
         raise PostcodeNotFoundError()
     job_centre_label = None
     for location_label, location_list in settings.LOCATION_LABELS.items():
         if list(location_list['locations']) == locations:
             job_centre_label = location_label
             break
     obj, created = cls.objects.get_or_create(
         locations=locations,
         job_centre_label=job_centre_label
     )
     obj.save()
     return obj, created
예제 #3
0
 def test_locations_for_valid_postcode(self):
     az = Adzuna()
     x = az.locations_for_postcode('SW1H0ET')
     self.assertEqual(len(list(x)), 3)
예제 #4
0
 def test_locations_for_valid_postcode(self):
     az = Adzuna()
     x = az.locations_for_postcode('SW1H0ET')
     self.assertEqual(len(list(x)), 3)