示例#1
0
 def test_api_structure_error(self, mocked_request):
     """
     Raises a QuickBaseException when the API returns an invalid structure
     which would cause an immediate parsing failure
     """
     with pytest.raises(QuickBaseException):
         _ResponseHandler(action='API_GetNumRecords', response=mocked_request)
示例#2
0
 def test_api_error(self):
     """
     Raises a QuickBaseException when the API returns a valid status code,
     and a non-zero errcode indicating a problem with the request
     """
     with pytest.raises(QuickBaseException):
         _ResponseHandler(action='API_GetNumRecords', response=mocked_request('QuickBaseException'))
示例#3
0
 def test_property_error(self):
     """Error property returns (errcode, errtext) tuple"""
     rh = _ResponseHandler(action='API_GetNumRecords', response=mocked_request('API_GetNumRecords'))
     assert rh.error == {
         'errcode': 0,
         'errtext': 'No error',
         'errdetail': None
     }
示例#4
0
 def test_api_unreachable(self):
     """
     Raises a RequestException when the API returns status code other than 200
     """
     with pytest.raises(RequestException):
         _ResponseHandler(action='API_GetNumRecords', response=mocked_request('RequestException'))
示例#5
0
 def test_property_action(self):
     """Action property returns the action  parameter from the response"""
     rh = _ResponseHandler(action='API_GetNumRecords', response=mocked_request('API_GetNumRecords'))
     assert rh.action == 'API_GetNumRecords'
示例#6
0
 def test_repr(self):
     """Test object representation"""
     rh = _ResponseHandler(action='API_GetNumRecords', response=mocked_request('API_GetNumRecords'))
     assert repr(rh) == 'ResponseHandler ({0}) at {1}'.format('API_GetNumRecords', hex(id(rh)))