def testQueryThrowsException(self): with HTTMock(billomat_mock_exception): client = base.Client() self.assertRaisesRegexp( base.BillomatRequestException, 'request failed.*', client.query, ('test', ), )
def testQueryThrowsExceptionOnInvalidResponse(self): with HTTMock(billomat_mock_return_malformed): client = base.Client() self.assertRaisesRegexp( base.BillomatRequestException, 'malformed.*', client.query, ('test', ), )
def testQueryThrowsExceptionWithMessage(self): with HTTMock(billomat_mock_return_error): client = base.Client() self.assertRaisesRegexp( base.BillomatRequestException, FIXTURE_MESSAGE, client.query, ('test', ), )
def testQueryThrowsExceptionOnNoneResponse(self): with HTTMock(billomat_mock_return_none): client = base.Client() self.assertRaisesRegexp( base.BillomatRequestException, 'null.*', client.query, ('test', ), )
def get_client(self): client = base.Client() client.api_key = '' return client
def testQueryOk(self): with HTTMock(billomat_mock_ok): client = base.Client() result = client.query('test') self.assertEqual(result, FIXTURE_OBJECT)
def testQueryReturnsEmptyList(self): with HTTMock(billomat_mock_return_empty): client = base.Client() result = client.query('test') self.assertEqual(result, {})