1616DUMMY_ENTRIES = [MagicMock (), MagicMock (), None ]
1717
1818
19- @fixture ( autouse = True )
19+ @fixture
2020def httpx_post_mock (mocker ):
2121 post_mock = mocker .patch ("simplejustwatchapi.justwatch.post" )
2222 post_mock .return_value .json .return_value = DUMMY_RESPONSE
@@ -27,7 +27,7 @@ def httpx_post_mock(mocker):
2727
2828@patch ("simplejustwatchapi.justwatch.parse_search_response" , return_value = DUMMY_ENTRIES )
2929@patch ("simplejustwatchapi.justwatch.prepare_search_request" , return_value = DUMMY_REQUEST )
30- def test_search (requests_mock , parser_mock ):
30+ def test_search (requests_mock , parser_mock , httpx_post_mock ):
3131 results = search (* SEARCH_INPUT )
3232 requests_mock .assert_called_with (* SEARCH_INPUT )
3333 parser_mock .assert_called_with (DUMMY_RESPONSE )
@@ -37,7 +37,7 @@ def test_search(requests_mock, parser_mock):
3737@patch ("simplejustwatchapi.justwatch.parse_details_response" )
3838@patch ("simplejustwatchapi.justwatch.prepare_details_request" , return_value = DUMMY_REQUEST )
3939@mark .parametrize ("parse_results" , [DUMMY_ENTRIES , None ])
40- def test_details (requests_mock , parser_mock , parse_results ):
40+ def test_details (requests_mock , parser_mock , parse_results , httpx_post_mock ):
4141 parser_mock .return_value = parse_results
4242 results = details (* DETAILS_INPUT )
4343 requests_mock .assert_called_with (* DETAILS_INPUT )
@@ -48,7 +48,7 @@ def test_details(requests_mock, parser_mock, parse_results):
4848@patch ("simplejustwatchapi.justwatch.parse_seasons_response" )
4949@patch ("simplejustwatchapi.justwatch.prepare_seasons_request" , return_value = DUMMY_REQUEST )
5050@mark .parametrize ("parse_results" , [DUMMY_ENTRIES , None ])
51- def test_seasons (requests_mock , parser_mock , parse_results ):
51+ def test_seasons (requests_mock , parser_mock , parse_results , httpx_post_mock ):
5252 parser_mock .return_value = parse_results
5353 results = seasons (* DETAILS_INPUT )
5454 requests_mock .assert_called_with (* DETAILS_INPUT )
@@ -59,7 +59,7 @@ def test_seasons(requests_mock, parser_mock, parse_results):
5959@patch ("simplejustwatchapi.justwatch.parse_episodes_response" )
6060@patch ("simplejustwatchapi.justwatch.prepare_episodes_request" , return_value = DUMMY_REQUEST )
6161@mark .parametrize ("parse_results" , [DUMMY_ENTRIES , None ])
62- def test_episodes (requests_mock , parser_mock , parse_results ):
62+ def test_episodes (requests_mock , parser_mock , parse_results , httpx_post_mock ):
6363 parser_mock .return_value = parse_results
6464 results = episodes (* DETAILS_INPUT )
6565 requests_mock .assert_called_with (* DETAILS_INPUT )
@@ -73,13 +73,21 @@ def test_episodes(requests_mock, parser_mock, parse_results):
7373@patch (
7474 "simplejustwatchapi.justwatch.prepare_offers_for_countries_request" , return_value = DUMMY_REQUEST
7575)
76- def test_offers_for_countries (requests_mock , parser_mock ):
76+ def test_offers_for_countries (requests_mock , parser_mock , httpx_post_mock ):
7777 results = offers_for_countries (* OFFERS_INPUT )
7878 requests_mock .assert_called_with (* OFFERS_INPUT )
7979 parser_mock .assert_called_with (DUMMY_RESPONSE , OFFERS_COUNTRIES_INPUT )
8080 assert results == DUMMY_ENTRIES
8181
8282
83- def test_offers_for_countries_returns_empty_dict_for_empty_countries_set ():
83+ @patch ("simplejustwatchapi.justwatch.parse_offers_for_countries_response" )
84+ @patch ("simplejustwatchapi.justwatch.prepare_offers_for_countries_request" )
85+ @patch ("simplejustwatchapi.justwatch.post" )
86+ def test_offers_for_countries_returns_empty_dict_for_empty_countries_set (
87+ requests_mock , parser_mock , httpx_post_mock
88+ ):
8489 results = offers_for_countries ("" , set (), "" , False )
8590 assert not results
91+ requests_mock .assert_not_called ()
92+ parser_mock .assert_not_called ()
93+ httpx_post_mock .assert_not_called ()
0 commit comments