Exemplo n.º 1
0
    def test_parsing_common_phrase_mock(self):
        with mock.patch('requests.post') as MockRequestsPost:
            auth_server_response = TestEmbyCroft.mocked_responses["emby"][
                "3.5.2.0"]["auth_server_response"]
            response = MockResponse(200, auth_server_response)
            MockRequestsPost.return_value = response
            emby_croft = EmbyCroft(HOST, USERNAME, PASSWORD)

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

                search_response = TestEmbyCroft.mocked_responses["emby"][
                    "3.5.2.0"]["common_play"][match_type]["search_response"]
                get_songs_response = TestEmbyCroft.mocked_responses["emby"][
                    "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 = emby_croft.parse_common_phrase(phrase)

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

        emby_croft = EmbyCroft(HOST, USERNAME, PASSWORD)

        for phrase in TestEmbyCroft.common_phrases:
            match_type, songs = emby_croft.parse_common_phrase(phrase)

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