def test_get_movies_list_upcoming_length(monkeypatch): my_mock = Mock() response = my_mock.return_value response.json.return_value = upcoming_movies monkeypatch.setattr("tmdb_client.requests.get", my_mock) movies = tc.call_tmdb_api("movie/?list_type=upcoming") assert len(movies) == len(upcoming_movies)
def test_call_tmdb_api(monkeypatch): mock_endpoint = 'some' requests_mock = register_default_mock(monkeypatch) response = requests_mock.return_value response.json.return_value = mock_endpoint api = tmdb_client.call_tmdb_api(endpoint="movie/some") assert api == mock_endpoint
def test_get_single_movie_title(monkeypatch): mock_movie_title = {"title": "Harry Potter and the Philosopher's Stone"} my_mock = Mock() response = my_mock.return_value response.json.return_value = mock_movie_title monkeypatch.setattr("tmdb_client.requests.get", my_mock) movie = tc.call_tmdb_api("movie/671") assert movie['title'] == mock_movie_title['title']
def test_call_tmdb_api(monkeypatch): full_url_mock = f"website" requsts_mock = Mock() response = requsts_mock.return_value response.json.return_value = full_url_mock monkeypatch.setattr("tmdb_client.requests.get", requsts_mock) full_url = tmdb_client.call_tmdb_api(f"none") assert full_url == full_url_mock
def test_get_single_movie_cast(monkeypatch): mock_movie_actor = {'name': 'Daniel Radcliffe'} my_mock = Mock() response = my_mock.return_value response.json.return_value = mock_movie_actor monkeypatch.setattr("tmdb_client.requests.get", my_mock) movie_cast = tc.call_tmdb_api("movie/671/credits") assert movie_cast['name'] == mock_movie_actor['name']
def test_get_single_movie_images_2(monkeypatch): mock_movie_image_file_path = { 'file_path': '/4GlSMUpzSd3cliYGFJVziSDX53S.jpg' } my_mock = Mock() response = my_mock.return_value response.json.return_value = mock_movie_image_file_path monkeypatch.setattr("tmdb_client.requests.get", my_mock) movie_images = tc.call_tmdb_api("movie/671/images") assert movie_images['file_path'] == mock_movie_image_file_path['file_path']