示例#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"
示例#2
0
 def test_exception_breaks_everything(self):
     with pytest.raises(AttributeError):
         make_client_result(None)
示例#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"
示例#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
示例#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"
示例#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'] == {}
示例#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
示例#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"
示例#9
0
 def test_payload_loads(self, stub_response):
     response = stub_response(json_text={})
     result = make_client_result(response)
     assert result['payload'] == {}
示例#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"
示例#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