예제 #1
0
 def test_verify_is_true_if_env_not_set(self, api_token):
     with patch("pythonanywhere.api.requests") as mock_requests:
         call_api("url", "post", foo="bar")
     args, kwargs = mock_requests.request.call_args
     assert kwargs["verify"] is True
예제 #2
0
 def test_passes_verify_from_environment(self, api_token, monkeypatch):
     monkeypatch.setenv("PYTHONANYWHERE_INSECURE_API", "true")
     with patch("pythonanywhere.api.requests") as mock_requests:
         call_api("url", "post", foo="bar")
     args, kwargs = mock_requests.request.call_args
     assert kwargs["verify"] is False
예제 #3
0
 def test_verify_is_true_if_env_not_set(self, api_token):
     with patch('pythonanywhere.api.requests') as mock_requests:
         call_api('url', 'post', foo='bar')
     args, kwargs = mock_requests.request.call_args
     assert kwargs["verify"] is True
예제 #4
0
 def test_raises_on_401(self, api_token, api_responses):
     url = "https://foo.com/"
     api_responses.add(responses.POST, url, status=401, body="nope")
     with pytest.raises(AuthenticationError) as e:
         call_api(url, "post")
     assert str(e.value) == "Authentication error 401 calling API: nope"
예제 #5
0
 def test_passes_verify_from_environment(self, api_token, monkeypatch):
     monkeypatch.setenv('PYTHONANYWHERE_INSECURE_API', 'true')
     with patch('pythonanywhere.api.requests') as mock_requests:
         call_api('url', 'post', foo='bar')
     args, kwargs = mock_requests.request.call_args
     assert kwargs["verify"] is False