コード例 #1
0
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)
コード例 #2
0
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
コード例 #3
0
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']
コード例 #4
0
ファイル: test_tmdb.py プロジェクト: DomiBar/movies_catalogue
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
コード例 #5
0
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']
コード例 #6
0
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']