2
2
import responses
3
3
import requests
4
4
5
- from mock import patch
5
+ from mock import patch , MagicMock
6
6
7
7
from presser .presser import Presser
8
8
from presser .exceptions import Presser404Error , PresserURLError , PresserInvalidVineIdError , PresserJavaScriptParseError , PresserRequestError
@@ -30,7 +30,7 @@ def test_not_a_valid_vine_id(self):
30
30
@patch ('presser.presser.Presser.get_data_for_vine_id' )
31
31
def test_vine_id_extraction (self , vine_response ):
32
32
vine = self .presser .get_data_for_vine_from_url (VINE_URL )
33
- self .presser .get_data_for_vine_id .assert_called_with (VINE_ID )
33
+ self .presser .get_data_for_vine_id .assert_called_with (VINE_ID , timeout = 30 )
34
34
35
35
@responses .activate
36
36
def test_vine_data_extraction (self ):
@@ -84,4 +84,10 @@ def test_error_request(self):
84
84
85
85
@patch ("requests.models.Response.ok" , False )
86
86
def test_page_not_okay (self ):
87
- self .assertRaises (PresserURLError , self .presser .get_data_for_vine_from_url , VINE_URL )
87
+ self .assertRaises (PresserURLError , self .presser .get_data_for_vine_from_url , VINE_URL )
88
+
89
+ @patch ("requests.get" )
90
+ def test_timeout_passed_through (self , request_mock ):
91
+ #Yes this is hacky, BUT responses doesn't record the timeout parameter
92
+ self .assertRaises (TypeError , self .presser .get_data_for_vine_from_url , VINE_URL , timeout = 5 )
93
+ requests .get .assert_called_with (VINE_URL , timeout = 5 )
0 commit comments