예제 #1
0
    def import_from_adzuna(self, job_area, count):
        """
        Method to import jobs from the Adzuna API
        """
        locations = job_area.locations
        args = list(locations) + [count]

        az = Adzuna()
        all_jobs = az.jobs_at_location(*args)
        for job in all_jobs:
            obj, created = JobAdvert.get_or_create_from_adzuna(job_area, job)
            if not created:
                break
예제 #2
0
    def import_from_adzuna(self, job_area, count):
        """
        Method to import jobs from the Adzuna API
        """
        locations = job_area.locations
        args = list(locations) + [count]

        az = Adzuna()
        all_jobs = az.jobs_at_location(*args)
        for job in all_jobs:
            obj, created = JobAdvert.get_or_create_from_adzuna(job_area, job)
            if not created:
                break
예제 #3
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
예제 #4
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
예제 #5
0
 def test_jobs_at_location(self):
     az = Adzuna()
     x = az.jobs_at_location('UK', 'London', 'South East London', 15)
     self.assertEqual(len(list(x)), 15)
예제 #6
0
 def test_locations_for_valid_postcode(self):
     az = Adzuna()
     x = az.locations_for_postcode('SW1H0ET')
     self.assertEqual(len(list(x)), 3)
예제 #7
0
 def test_locations_for_invalid_postcode(self):
     az = Adzuna()
     self.assertRaises(AssertionError, az.locations_for_postcode,
                       'not a postcode')
예제 #8
0
 def test_top_companies(self):
     az = Adzuna()
     x = az.top_companies('UK', 'London', 'South East London', 2)
     self.assertEqual(len(list(x)), 2)
예제 #9
0
 def test_jobs_at_location(self):
     az = Adzuna()
     x = az.jobs_at_location('UK', 'London', 'South East London', 15)
     self.assertEqual(len(list(x)), 15)
예제 #10
0
 def test_locations_for_valid_postcode(self):
     az = Adzuna()
     x = az.locations_for_postcode('SW1H0ET')
     self.assertEqual(len(list(x)), 3)
예제 #11
0
 def test_top_companies(self):
     az = Adzuna()
     x = az.top_companies('UK', 'London', 'South East London', 2)
     self.assertEqual(len(list(x)), 2)