Exemple #1
0
 def test_401_failure_message(self, stub_response):
     response = stub_response(status_code=401, text=None)
     result = make_client_result(response)
     assert result[
         'error'] == "Unauthorized - please check your username/password"
Exemple #2
0
 def test_exception_breaks_everything(self):
     with pytest.raises(AttributeError):
         make_client_result(None)
Exemple #3
0
 def test_payload_loads_fallsback_on_invalid_fails(self, stub_response):
     response = stub_response(status_code=500, text="invalid json")
     result = make_client_result(response)
     assert result['error'] == "invalid json"
Exemple #4
0
 def test_result_is_success(self, stub_response):
     response = stub_response()
     result = make_client_result(response)
     assert result['httpcode'] == 200
     assert result['success'] is True
Exemple #5
0
 def test_raw_payload_fails(self, stub_response):
     response = stub_response(status_code=500, text="raw json")
     result = make_client_result(response, raw=True)
     assert result['error'] == "raw json"
Exemple #6
0
 def test_payload_loads_fails(self, stub_response):
     response = stub_response(status_code=500, json_text={})
     result = make_client_result(response)
     assert result['error'] == {}
Exemple #7
0
 def test_result_fails(self, stub_response):
     response = stub_response(status_code=500)
     result = make_client_result(response)
     assert result['success'] is False
Exemple #8
0
 def test_payload_loads_fallsback_on_invalid(self, stub_response):
     response = stub_response(text="invalid json")
     result = make_client_result(response)
     assert result['payload'] == "invalid json"
Exemple #9
0
 def test_payload_loads(self, stub_response):
     response = stub_response(json_text={})
     result = make_client_result(response)
     assert result['payload'] == {}
Exemple #10
0
 def test_raw_payload(self, stub_response):
     response = stub_response(text="raw json")
     result = make_client_result(response, raw=True)
     assert result['payload'] == "raw json"
Exemple #11
0
 def test_success_in_200_range(self, stub_response, code):
     response = stub_response(status_code=code)
     result = make_client_result(response)
     assert result['success'] is True