示例#1
0
    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)
示例#2
0
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! :(")
示例#3
0
 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())