| |
@@ -0,0 +1,19 @@
|
| |
+ from collections import OrderedDict
|
| |
+ from unittest.mock import ANY, MagicMock, patch
|
| |
+
|
| |
+ import toddlers.utils.requests
|
| |
+
|
| |
+
|
| |
+ @patch("requests.sessions.extract_cookies_to_jar", new=MagicMock())
|
| |
+ @patch("requests.adapters.HTTPAdapter.send")
|
| |
+ def test_make_session(send):
|
| |
+ resp = MagicMock()
|
| |
+ resp.url = "http://localhost"
|
| |
+ resp.is_redirect = False
|
| |
+ send.return_value = resp
|
| |
+ session = toddlers.utils.requests.make_session(timeout=1)
|
| |
+ session.get("http://localhost")
|
| |
+
|
| |
+ send.assert_called_once_with(
|
| |
+ ANY, timeout=None, verify=True, proxies=OrderedDict(), stream=False, cert=None
|
| |
+ )
|
| |
Nice way of recycling the mocked class object for the mocked instance, too! :wink: