def test_api_prefix(self): api = API('test_domain.freshdesk.com', 'test_key') self.assertEqual(api._api_prefix, 'https://test_domain.freshdesk.com/api/v2/') api = API('test_domain.freshdesk.com/', 'test_key') self.assertEqual(api._api_prefix, 'https://test_domain.freshdesk.com/api/v2/')
def test_errors(status_code, exception): responses.add(responses.GET, "https://{}/api/v2/tickets/1".format(DOMAIN), status=status_code) api = API("pythonfreshdesk.freshdesk.com", "test_key") with pytest.raises(exception): api.tickets.get_ticket(1)
def test_403_error(self): responses.add(responses.GET, 'https://{}/api/v2/tickets/1'.format(DOMAIN), status=403) api = API('pythonfreshdesk.freshdesk.com', 'invalid_api_key') from requests.exceptions import HTTPError with self.assertRaises(HTTPError): api.tickets.get_ticket(1)
def test_custom_cname(self): with self.assertRaises(AttributeError): API('custom_cname_domain', 'invalid_api_key')
def test_api_prefix(): api = API("test_domain.freshdesk.com", "test_key") assert api._api_prefix == "https://test_domain.freshdesk.com/api/v2/" api = API("test_domain.freshdesk.com/", "test_key") assert api._api_prefix == "https://test_domain.freshdesk.com/api/v2/"
def test_custom_cname(): with pytest.raises(AttributeError): API("custom_cname_domain", "invalid_api_key")
def test_api_prefix(): api = API('test_domain.freshdesk.com', 'test_key') assert api._api_prefix == 'https://test_domain.freshdesk.com/api/v2/' api = API('test_domain.freshdesk.com/', 'test_key') assert api._api_prefix == 'https://test_domain.freshdesk.com/api/v2/'
def test_custom_cname(): with pytest.raises(AttributeError): API('custom_cname_domain', 'invalid_api_key')