def test_req_wrap_post_exception_exhaust(mocker, mock_requests, mock_sleep): mock_requests.post.side_effect = [ ValueError, ValueError, ValueError, ValueError, ValueError, ] with pytest.raises(ValueError): post()
def login_and_save_cookie() -> None: """ Logs in to NHLTV.com and saves the auth cookie for later use """ user = _get_username_and_password() authorization = get_auth_cookie_value() if authorization: HEADERS.update({"Authorization": authorization}) login_data = { "nhlCredentials": { "email": user.username, "password": user.password } } tprint("Logging in to NHL.com..") req = requests.post( LOGIN_URL, headers={ **HEADERS, "Authorization": authorization }, json=login_data, ) verify_request_200(req) save_cookie(req.cookies)
def test_req_wrap_post_exception(mocker, mock_requests, mock_sleep): mock_requests.post.side_effect = [ValueError, 1] assert post() == 1 mock_sleep.assert_called_once_with(15)
def test_req_wrap_post_both(mocker, mock_requests): post(1, test=2) mock_requests.post.assert_called_once_with(1, test=2)
def test_req_wrap_post_kw(mocker, mock_requests): post(test=1) mock_requests.post.assert_called_once_with(test=1)
def test_req_wrap_post(mocker, mock_requests, mock_sleep): post(1) mock_requests.post.assert_called_once_with(1)