Exemplo n.º 1
0
    def test_parsing_common_phrase_mock(self):
        with mock.patch('requests.post') as MockRequestsPost:
            auth_server_response = TestJellyfinCroft.mocked_responses[
                "jellyfin"]["3.5.2.0"]["auth_server_response"]
            response = MockResponse(200, auth_server_response)
            MockRequestsPost.return_value = response
            jellyfin_croft = JellyfinCroft(HOST, USERNAME, PASSWORD, "none")

            for phrase in TestJellyfinCroft.common_phrases:
                match_type = TestJellyfinCroft.common_phrases[phrase][
                    "match_type"]

                search_response = TestJellyfinCroft.mocked_responses[
                    "jellyfin"]["3.5.2.0"]["common_play"][match_type][
                        "search_response"]
                get_songs_response = TestJellyfinCroft.mocked_responses[
                    "jellyfin"]["3.5.2.0"]["common_play"][match_type][
                        "songs_response"]
                with mock.patch('requests.get') as MockRequestsGet:
                    responses = [
                        MockResponse(200, search_response),
                        MockResponse(200, get_songs_response)
                    ]
                    MockRequestsGet.side_effect = responses

                    match_type, songs = jellyfin_croft.parse_common_phrase(
                        phrase)

                    assert match_type == TestJellyfinCroft.common_phrases[
                        phrase]["match_type"]
                    assert songs
Exemplo n.º 2
0
    def test_parsing_common_phrase(self):

        jellyfin_croft = JellyfinCroft(HOST, USERNAME, PASSWORD, "none")

        for phrase in TestJellyfinCroft.common_phrases:
            match_type, songs = jellyfin_croft.parse_common_phrase(phrase)

            assert match_type == TestJellyfinCroft.common_phrases[phrase][
                'match_type']
            assert songs