def import_from_api(self, movie_title="Frozen"): self.success_imports += 1 if USE_MOCKS: OMDBApiService._request_api = mocks.OMDBMock._request_api_success OMDBApiService.import_movie(movie_title, "") movie = models.Movie.objects.get(title=movie_title) pprint(movie.__dict__) pprint(movie.genre.all()) pprint(movie.actors.all()) pprint(movie.director.all()) self.assertIsNotNone(movie)
def import_movie(request): movie = api.get_or_import_movie(request.GET.get("movie_title")) if movie: return HttpResponse(movie.__str__()) else: return HttpResponse("Not found! :(")
def test_import_error(self): if USE_MOCKS: OMDBApiService._request_api = mocks.OMDBMock._request_api_error OMDBApiService.import_movie("no_real_movie", "") self.assertEqual(0, models.Movie.objects.count())