def import_city(): """ runs city import every minute """ city_uri = 'city.csv' data = get_remote_content(URL+city_uri, USERNAME, PASSWORD) save_city(data)
def import_hotel(): """ runs hotel import every two minutes """ hotel_uri = 'hotel.csv' data = get_remote_content(URL+hotel_uri, USERNAME, PASSWORD) save_hotel(data)
def import_hotel_data(self): """ Test: get hotel.csv remotely """ file_uri = 'hotel.csv' remote_data = get_remote_content(self.url+file_uri, self.username, self.password) self.assertEqual(remote_data['response_code'], 200)
def import_hotel_data(self): """ Test: get hotel.csv remotely """ file_uri = 'hotel.csv' remote_data = get_remote_content(self.url + file_uri, self.username, self.password) self.assertEqual(remote_data['response_code'], 200)
def handle(self, *args, **options): path = options.get('local') city_data = None if path: city_data = get_local_content(path) else: if len(args) < 3: raise CommandError('Insert URL username password') city_data = get_remote_content(args[0], args[1], args[2]) save_city(city_data['data'])
def store_city(self): """ Store cities from csv in base """ file_uri = self.city_csv_uri data = get_remote_content(self.url+file_uri, self.username, self.password) csv_city = data['data'] save_city(csv_city) total_new_cities = City.objects.all().count() self.assertEqual(total_new_cities, 6)
def store_city(self): """ Store cities from csv in base """ file_uri = self.city_csv_uri data = get_remote_content(self.url + file_uri, self.username, self.password) csv_city = data['data'] save_city(csv_city) total_new_cities = City.objects.all().count() self.assertEqual(total_new_cities, 6)
def store_hotel(self): """ Store hotel from csv in base """ # first get the cities self.store_city() file_uri = self.hotel_csv_uri data = get_remote_content(self.url+file_uri, self.username, self.password) hotel_csv = data['data'] save_hotel(hotel_csv) total_new_hotels = Hotel.objects.all().count() self.assertEqual(total_new_hotels, 196)
def store_hotel(self): """ Store hotel from csv in base """ # first get the cities self.store_city() file_uri = self.hotel_csv_uri data = get_remote_content(self.url + file_uri, self.username, self.password) hotel_csv = data['data'] save_hotel(hotel_csv) total_new_hotels = Hotel.objects.all().count() self.assertEqual(total_new_hotels, 196)