Esempio n. 1
0
def ghibli_fetch_movies(**kwargs):
    logger.info('Starting fetching data from API')
    movies = fetch_movies_with_people()
    if movies:
        logger.info('Saving data from API')
        cache.set(settings.GHIBLI_CACHE_KEY, movies, timeout=None)
    logger.info('Fetching data succeeded')
Esempio n. 2
0
 def test_fetch_movies_with_people_timeout_when_get_get_person(self, m):
     m.get(ghibli.FILMS_URL, json=FILMS)
     m.get('{}/1'.format(ghibli.PEOPLE_URL),
           exc=requests.exceptions.Timeout)
     result = ghibli.fetch_movies_with_people()
     self.assertEqual(result, [])
Esempio n. 3
0
 def test_fetch_movies_with_people_timeout_when_get_films(self, m):
     m.get(ghibli.FILMS_URL, exc=requests.exceptions.Timeout)
     result = ghibli.fetch_movies_with_people()
     self.assertEqual(result, [])
Esempio n. 4
0
 def test_fetch_movies_with_people_when_people_without_id(self, m):
     m.get(ghibli.FILMS_URL, json=FILMS2)
     m.get(ghibli.PEOPLE_URL, json=PEOPLE)
     result = ghibli.fetch_movies_with_people()
     expected_result = [{'id': 1, 'title': 'movie1', 'people': [PERSON1]}]
     self.assertEqual(result, expected_result)
Esempio n. 5
0
 def test_fetch_movies_with_people_not_ok_status_code_when_get_person(
         self, m):
     m.get(ghibli.FILMS_URL, json=FILMS)
     m.get('{}/1'.format(ghibli.PEOPLE_URL), status_code=404)
     result = ghibli.fetch_movies_with_people()
     self.assertEqual(result, [])
Esempio n. 6
0
 def test_fetch_movies_with_people_not_ok_status_code_when_get_films(
         self, m):
     m.get(ghibli.FILMS_URL, status_code=404)
     result = ghibli.fetch_movies_with_people()
     self.assertEqual(result, [])
Esempio n. 7
0
 def test_fetch_movies_with_people_expected_result(self, m):
     m.get(ghibli.FILMS_URL, json=FILMS)
     m.get('{}/1'.format(ghibli.PEOPLE_URL), json=PERSON1)
     result = ghibli.fetch_movies_with_people()
     expected_result = [{'id': 1, 'title': 'movie1', 'people': [PERSON1]}]
     self.assertEqual(result, expected_result)