Пример #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