def test_normal(self): """Return the full API URL when called with correct parameters.""" end = Endpoint(client=self.client, endpoint=self.ep_path) suffix = "/help" url = f"{self.api_url}{suffix}" # Make sure the values match self.assertEqual(end._url(suffix), url)
def test_many_slashes(self): """Return the full API URL when called with a suffix with too many slashes.""" end = Endpoint(client=self.client, endpoint=self.ep_path) suffix = "//help///" url = f"{self.api_url}/help" # Make sure the values match self.assertEqual(end._url(suffix), url)
def test_no_slashes(self): """Return the full API URL when called with a suffix with no slash.""" end = Endpoint(client=self.client, endpoint=self.ep_path) suffix = "help" url = f"{self.api_url}/{suffix}" # Make sure the values match self.assertEqual(end._url(suffix), url)
def test_normal(self): """Return the API URL when called with correct parameters.""" url = Endpoint.create_api_url(self.cfixt.base_url, self.ep_path, self.api_version) # Make sure the values match self.assertEqual(url, self.api_url)
def test_extra_slashes(self): """Return a clean API URL when called with parameters containing extra slashes.""" url = Endpoint.create_api_url(f"{self.cfixt.base_url}///", f"//{self.ep_path}", f"////{self.api_version}") # Make sure the values match self.assertEqual(url, self.api_url)
def test_defaults(self): """Parameters should be set correctly inside the class using defaults.""" end = Endpoint(client=self.client, endpoint=self.ep_path) # Check all the internal values self.assertEqual(end._client, self.client) self.assertEqual(end._api_version, self.api_version) self.assertEqual(end._api_url, self.api_url)
def test_version(self): """Parameters should be set correctly inside the class with a custom version.""" version = "v2" api_url = self.cfixt.base_url + self.ep_path + "/" + version end = Endpoint(client=self.client, endpoint=self.ep_path, api_version=version) # Check all the internal values self.assertEqual(end._client, self.client) self.assertEqual(end._api_version, version) self.assertEqual(end._api_url, api_url)
def test_api_url(self): """Return the internal _api_url value.""" end = Endpoint(client=self.client, endpoint=self.ep_path) # Make sure the values match self.assertEqual(end.api_url, self.api_url)