Esempio n. 1
0
def test_find_no_results(mock_env, tv_media_items):
    responses.add(responses.GET,
                  _FIND_URL,
                  json={
                      "page": 1,
                      "total_results": 0,
                      "total_pages": 0,
                      "results": []
                  },
                  status=200,
                  match_querystring=True)

    with pytest.raises(ValueError) as error:
        testee.find(tv_media_items[0])

    assert (
        error.value.args[0] == 'No media information found for title [Title]')
Esempio n. 2
0
def test_find_not_found(mock_env, tv_media_items):
    responses.add(responses.GET,
                  _FIND_URL,
                  json={
                      "success":
                      False,
                      "status_code":
                      34,
                      "status_message":
                      "The resource you requested could not be found."
                  },
                  status=404,
                  match_querystring=True)

    with pytest.raises(ValueError) as error:
        testee.find(tv_media_items[0])

    assert (error.value.args[0] == 'Error obtaining media information. '
            'Status: [404], reason: [Not Found]')
Esempio n. 3
0
def _enrich_media_items(media_items: List[TvMediaItem]):
    if len(media_items) > 0:
        tmdb_item = tmdb_client.find(media_items[0])
        if tmdb_item.type is MediaType.tv:
            episodes = tmdb_client.get_episodes_for_season(
                tmdb_item, media_items[0].season_number)
            for item in media_items:
                episode = _find_episode_by_number(int(item.episode_number),
                                                  episodes)
                if episode:
                    item.episode_name = episode.name
Esempio n. 4
0
def test_find_other_result_and_abort(mock_env, mocker, tv_media_items):
    responses.add(responses.GET,
                  _FIND_URL,
                  json={
                      "page":
                      1,
                      "total_results":
                      0,
                      "total_pages":
                      0,
                      "results": [{
                          "id": 4546,
                          "name": "Other title",
                          "media_type": "tv"
                      }]
                  },
                  status=200,
                  match_querystring=True)
    mocker.patch('builtins.input', return_value='n')

    with pytest.raises(SystemExit) as pytest_wrapped_e:
        testee.find(tv_media_items[0])

    assert pytest_wrapped_e.type == SystemExit
Esempio n. 5
0
def test_find_single_result(mock_env, tv_media_items, tmdb_item):
    responses.add(responses.GET,
                  _FIND_URL,
                  json={
                      "page":
                      1,
                      "total_results":
                      0,
                      "total_pages":
                      0,
                      "results": [{
                          "original_name":
                          "Title",
                          "genre_ids": [35],
                          "media_type":
                          "tv",
                          "name":
                          "Title",
                          "popularity":
                          36.208,
                          "origin_country": ["US"],
                          "vote_count":
                          368,
                          "first_air_date":
                          "2000-10-15",
                          "backdrop_path":
                          "/eNSIkGIYqXVFNmT85P4X7BsXkYI.jpg",
                          "original_language":
                          "en",
                          "id":
                          4546,
                          "vote_average":
                          8.1,
                          "overview":
                          "The off-kilter, unscripted comic ...",
                          "poster_path":
                          "/kWQDOnLs5DK0ta8xQZLsaienIHp.jpg"
                      }]
                  },
                  status=200,
                  match_querystring=True)

    actual = testee.find(tv_media_items[0])

    assert actual == tmdb_item
Esempio n. 6
0
def test_find_other_result_and_continue(mock_env, mocker, tv_media_items):
    expected = TmdbItem(id=4546, name='Other title', type=MediaType.tv)
    responses.add(responses.GET,
                  _FIND_URL,
                  json={
                      "page":
                      1,
                      "total_results":
                      0,
                      "total_pages":
                      0,
                      "results": [{
                          "id": 4546,
                          "name": "Other title",
                          "media_type": "tv"
                      }]
                  },
                  status=200,
                  match_querystring=True)
    mocker.patch('builtins.input', return_value='y')

    actual = testee.find(tv_media_items[0])

    assert actual == expected
Esempio n. 7
0
def test_find_multiple_results(mock_env, tv_media_items, tmdb_item):
    responses.add(responses.GET,
                  _FIND_URL,
                  json={
                      "page":
                      1,
                      "total_results":
                      0,
                      "total_pages":
                      0,
                      "results": [{
                          "original_name":
                          "Title",
                          "genre_ids": [35],
                          "media_type":
                          "tv",
                          "name":
                          "Title",
                          "popularity":
                          36.208,
                          "origin_country": ["US"],
                          "vote_count":
                          368,
                          "first_air_date":
                          "2000-10-15",
                          "backdrop_path":
                          "/eNSIkGIYqXVFNmT85P4X7BsXkYI.jpg",
                          "original_language":
                          "en",
                          "id":
                          4546,
                          "vote_average":
                          8.1,
                          "overview":
                          "The off-kilter, unscripted comic ...",
                          "poster_path":
                          "/kWQDOnLs5DK0ta8xQZLsaienIHp.jpg"
                      }, {
                          "original_name":
                          "The Sopranos",
                          "genre_ids": [18],
                          "media_type":
                          "tv",
                          "name":
                          "The Sopranos",
                          "popularity":
                          51.79,
                          "origin_country": ["US"],
                          "vote_count":
                          1162,
                          "first_air_date":
                          "1999-01-10",
                          "backdrop_path":
                          "/3ltpFyIfAtGjRMRJdECFoQQCfzx.jpg",
                          "original_language":
                          "en",
                          "id":
                          1398,
                          "vote_average":
                          8.4,
                          "overview":
                          "The story of New Jersey-based ...",
                          "poster_path":
                          "/6nNZnnUkXcI3DvdrkclulanYXzg.jpg"
                      }]
                  },
                  status=200,
                  match_querystring=True)

    actual = testee.find(tv_media_items[0])

    assert actual == tmdb_item