Skip to content

Commit

Permalink
Remove references to partial URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
katarina-vardic-4ss authored Jan 31, 2023
1 parent 84bdf24 commit 7987e74
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 51 deletions.
2 changes: 1 addition & 1 deletion fourinsight/campaigns/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def _url(self, relative_url, api_version=None):
if api_version is None:
api_version = self._API_VERSION

url = f"/{api_version}/Campaigns"
url = f"https://api.4insight.io/{api_version}/Campaigns"
if relative_url:
url += f"/{relative_url.lstrip('/')}"
return url
Expand Down
48 changes: 24 additions & 24 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,35 @@
)

DATA_MAP = {
"/v1.1/campaigns": CAMPAIGNS_DATA,
"https://api.4insight.io/v1.1/campaigns": CAMPAIGNS_DATA,
"campaigns next link": CAMPAIGNS_NEXT_DATA,
"/v1.1/campaigns/1234/events": EVENTS_DATA,
"/v1.1/campaigns/1234/sensors": SENSORS_DATA,
"/v1.0/campaigns/1234/lowerstack": LOWERSTACK_DATA,
"/v1.1/campaigns/swimops": SWIMOPS_DATA,
"/v1.1/campaigns/1234/swimops": SWIMOPS_CAMPAIGN_DATA,
"/v1.1/campaigns/1234/logs": LOGS_DATA,
"/v1.1/campaigns/1234/sensors/3fa85f64-5717-4562-b3fc-2c963f66afa6/channels": CHANNELS_DATA,
"/v1.1/campaigns/1234/sensors/<wh sensor id>/channels": CHANNELS_DATA,
"/v1.0/campaigns/1234": CAMPAIGN_DATA_SWIM,
"/v1.0/campaigns/test_generic_id": CAMPAIGN_DATA_GENERIC,
"/v1.0/campaigns/test_swim_id": CAMPAIGN_DATA_SWIM,
"https://api.4insight.io/v1.1/campaigns/1234/events": EVENTS_DATA,
"https://api.4insight.io/v1.1/campaigns/1234/sensors": SENSORS_DATA,
"https://api.4insight.io/v1.0/campaigns/1234/lowerstack": LOWERSTACK_DATA,
"https://api.4insight.io/v1.1/campaigns/swimops": SWIMOPS_DATA,
"https://api.4insight.io/v1.1/campaigns/1234/swimops": SWIMOPS_CAMPAIGN_DATA,
"https://api.4insight.io/v1.1/campaigns/1234/logs": LOGS_DATA,
"https://api.4insight.io/v1.1/campaigns/1234/sensors/3fa85f64-5717-4562-b3fc-2c963f66afa6/channels": CHANNELS_DATA,
"https://api.4insight.io/v1.1/campaigns/1234/sensors/<wh sensor id>/channels": CHANNELS_DATA,
"https://api.4insight.io/v1.0/campaigns/1234": CAMPAIGN_DATA_SWIM,
"https://api.4insight.io/v1.0/campaigns/test_generic_id": CAMPAIGN_DATA_GENERIC,
"https://api.4insight.io/v1.0/campaigns/test_swim_id": CAMPAIGN_DATA_SWIM,
}

DATA_MAP_CAMELCASE = {
"/v1.1/campaigns": CAMPAIGNS_DATA_CAMELCASE,
"https://api.4insight.io/v1.1/campaigns": CAMPAIGNS_DATA_CAMELCASE,
"campaigns next link": CAMPAIGNS_NEXT_DATA_CAMELCASE,
"/v1.1/campaigns/1234/events": EVENTS_DATA_CAMELCASE,
"/v1.1/campaigns/1234/sensors": SENSORS_DATA_CAMELCASE,
"/v1.0/campaigns/1234/lowerstack": LOWERSTACK_DATA_CAMELCASE,
"/v1.1/campaigns/swimops": SWIMOPS_DATA_CAMELCASE,
"/v1.1/campaigns/1234/swimops": SWIMOPS_CAMPAIGN_DATA_CAMELCASE,
"/v1.1/campaigns/1234/logs": LOGS_DATA_CAMELCASE,
"/v1.1/campaigns/1234/sensors/3fa85f64-5717-4562-b3fc-2c963f66afa6/channels": CHANNELS_DATA_CAMELCASE,
"/v1.1/campaigns/1234/sensors/<wh sensor id>/channels": CHANNELS_DATA_CAMELCASE,
"/v1.0/campaigns/1234": CAMPAIGN_DATA_SWIM_CAMELCASE,
"/v1.0/campaigns/test_generic_id": CAMPAIGN_DATA_GENERIC_CAMELCASE,
"/v1.0/campaigns/test_swim_id": CAMPAIGN_DATA_SWIM_CAMELCASE,
"https://api.4insight.io/v1.1/campaigns/1234/events": EVENTS_DATA_CAMELCASE,
"https://api.4insight.io/v1.1/campaigns/1234/sensors": SENSORS_DATA_CAMELCASE,
"https://api.4insight.io/v1.0/campaigns/1234/lowerstack": LOWERSTACK_DATA_CAMELCASE,
"https://api.4insight.io/v1.1/campaigns/swimops": SWIMOPS_DATA_CAMELCASE,
"https://api.4insight.io/v1.1/campaigns/1234/swimops": SWIMOPS_CAMPAIGN_DATA_CAMELCASE,
"https://api.4insight.io/v1.1/campaigns/1234/logs": LOGS_DATA_CAMELCASE,
"https://api.4insight.io/v1.1/campaigns/1234/sensors/3fa85f64-5717-4562-b3fc-2c963f66afa6/channels": CHANNELS_DATA_CAMELCASE,
"https://api.4insight.io/v1.1/campaigns/1234/sensors/<wh sensor id>/channels": CHANNELS_DATA_CAMELCASE,
"https://api.4insight.io/v1.0/campaigns/1234": CAMPAIGN_DATA_SWIM_CAMELCASE,
"https://api.4insight.io/v1.0/campaigns/test_generic_id": CAMPAIGN_DATA_GENERIC_CAMELCASE,
"https://api.4insight.io/v1.0/campaigns/test_swim_id": CAMPAIGN_DATA_SWIM_CAMELCASE,
}


Expand Down
58 changes: 32 additions & 26 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,28 @@ def test_init(self, campaigns_api, auth_session):
assert campaigns_api._session == auth_session

def test__url_bare(self, campaigns_api):
assert campaigns_api._url("") == "/v1.1/Campaigns"
assert campaigns_api._url("") == "https://api.4insight.io/v1.1/Campaigns"

def test__url_something(self, campaigns_api):
assert campaigns_api._url("something") == "/v1.1/Campaigns/something"
assert campaigns_api._url("/something") == "/v1.1/Campaigns/something"
assert (
campaigns_api._url("something")
== "https://api.4insight.io/v1.1/Campaigns/something"
)
assert (
campaigns_api._url("/something")
== "https://api.4insight.io/v1.1/Campaigns/something"
)

def test__url_version(self, campaigns_api):
assert (
campaigns_api._url("", api_version="test_version")
== "/test_version/Campaigns"
== "https://api.4insight.io/test_version/Campaigns"
)

def test_get_geotrack(self, campaigns_api, auth_session, response, headers_expect):
out = campaigns_api.get_geotrack("1234")
auth_session.get.assert_called_once_with(
"/v1.0/Campaigns/1234",
"https://api.4insight.io/v1.0/Campaigns/1234",
headers=headers_expect,
)
response.raise_for_status.assert_called()
Expand All @@ -68,7 +74,7 @@ def test_get_geotrack_camelcase(
):
out = campaigns_api_camelcase.get_geotrack("1234")
auth_session_camelcase.get.assert_called_once_with(
"/v1.0/Campaigns/1234",
"https://api.4insight.io/v1.0/Campaigns/1234",
headers=headers_expect,
)
response_camelcase.raise_for_status.assert_called()
Expand All @@ -84,7 +90,7 @@ def test_get_campaigns(self, campaigns_api, auth_session, response, headers_expe
out = campaigns_api.get_campaigns()
call_list = [
call(
"/v1.1/Campaigns",
"https://api.4insight.io/v1.1/Campaigns",
headers=headers_expect,
),
call(
Expand Down Expand Up @@ -155,7 +161,7 @@ def test_get_campaigns_camelcase(
out = campaigns_api_camelcase.get_campaigns()
call_list = [
call(
"/v1.1/Campaigns",
"https://api.4insight.io/v1.1/Campaigns",
headers=headers_expect,
),
call(
Expand Down Expand Up @@ -219,7 +225,7 @@ def test_get_campaigns_camelcase(
def test_get_campaign(self, campaigns_api, auth_session, response, headers_expect):
out = campaigns_api.get_campaign("1234")
auth_session.get.assert_called_once_with(
"/v1.0/Campaigns/1234",
"https://api.4insight.io/v1.0/Campaigns/1234",
headers=headers_expect,
)
response.raise_for_status.assert_called()
Expand Down Expand Up @@ -249,7 +255,7 @@ def test_get_campaign_camelcase(
):
out = campaigns_api_camelcase.get_campaign("1234")
auth_session_camelcase.get.assert_called_once_with(
"/v1.0/Campaigns/1234",
"https://api.4insight.io/v1.0/Campaigns/1234",
headers=headers_expect,
)
response_camelcase.raise_for_status.assert_called()
Expand All @@ -273,7 +279,7 @@ def test_get_campaign_camelcase(
def test_get_events(self, campaigns_api, auth_session, response, headers_expect):
out = campaigns_api.get_events("1234")
auth_session.get.assert_called_once_with(
"/v1.1/Campaigns/1234/Events",
"https://api.4insight.io/v1.1/Campaigns/1234/Events",
headers=headers_expect,
)
response.raise_for_status.assert_called()
Expand Down Expand Up @@ -315,7 +321,7 @@ def test_get_events_camelcase(
):
out = campaigns_api_camelcase.get_events("1234")
auth_session_camelcase.get.assert_called_once_with(
"/v1.1/Campaigns/1234/Events",
"https://api.4insight.io/v1.1/Campaigns/1234/Events",
headers=headers_expect,
)
response_camelcase.raise_for_status.assert_called()
Expand Down Expand Up @@ -352,11 +358,11 @@ def test_get_sensors(self, campaigns_api, auth_session, response, headers_expect
out = campaigns_api.get_sensors("1234")
call_list = [
call(
"/v1.1/Campaigns/1234/Sensors",
"https://api.4insight.io/v1.1/Campaigns/1234/Sensors",
headers=headers_expect,
),
call(
"/v1.1/Campaigns/1234/Sensors/3fa85f64-5717-4562-b3fc-2c963f66afa6/channels",
"https://api.4insight.io/v1.1/Campaigns/1234/Sensors/3fa85f64-5717-4562-b3fc-2c963f66afa6/channels",
headers=headers_expect,
),
]
Expand Down Expand Up @@ -417,11 +423,11 @@ def test_get_sensors_camelcase(
out = campaigns_api_camelcase.get_sensors("1234")
call_list = [
call(
"/v1.1/Campaigns/1234/Sensors",
"https://api.4insight.io/v1.1/Campaigns/1234/Sensors",
headers=headers_expect,
),
call(
"/v1.1/Campaigns/1234/Sensors/3fa85f64-5717-4562-b3fc-2c963f66afa6/channels",
"https://api.4insight.io/v1.1/Campaigns/1234/Sensors/3fa85f64-5717-4562-b3fc-2c963f66afa6/channels",
headers=headers_expect,
),
]
Expand Down Expand Up @@ -475,7 +481,7 @@ def test_get_sensors_camelcase(
def test__get_sensors(self, campaigns_api, auth_session, response, headers_expect):
out = campaigns_api._get_sensors("1234")
auth_session.get.assert_called_once_with(
"/v1.1/Campaigns/1234/Sensors",
"https://api.4insight.io/v1.1/Campaigns/1234/Sensors",
headers=headers_expect,
)
response.raise_for_status.assert_called()
Expand Down Expand Up @@ -517,7 +523,7 @@ def test__get_sensors_camelcase(
):
out = campaigns_api_camelcase._get_sensors("1234")
auth_session_camelcase.get.assert_called_once_with(
"/v1.1/Campaigns/1234/Sensors",
"https://api.4insight.io/v1.1/Campaigns/1234/Sensors",
headers=headers_expect,
)
response_camelcase.raise_for_status.assert_called()
Expand Down Expand Up @@ -553,7 +559,7 @@ def test__get_sensors_camelcase(
def test__get_channels(self, campaigns_api, auth_session, response, headers_expect):
out = campaigns_api._get_channels("1234", "<wh sensor id>")
auth_session.get.assert_called_once_with(
"/v1.1/Campaigns/1234/Sensors/<wh sensor id>/channels",
"https://api.4insight.io/v1.1/Campaigns/1234/Sensors/<wh sensor id>/channels",
headers=headers_expect,
)
response.raise_for_status.assert_called()
Expand All @@ -577,7 +583,7 @@ def test__get_channels_camelcase(
):
out = campaigns_api_camelcase._get_channels("1234", "<wh sensor id>")
auth_session_camelcase.get.assert_called_once_with(
"/v1.1/Campaigns/1234/Sensors/<wh sensor id>/channels",
"https://api.4insight.io/v1.1/Campaigns/1234/Sensors/<wh sensor id>/channels",
headers=headers_expect,
)
response_camelcase.raise_for_status.assert_called()
Expand All @@ -597,7 +603,7 @@ def test_get_lowerstack(
):
out = campaigns_api.get_lowerstack("1234")
auth_session.get.assert_called_once_with(
"/v1.0/Campaigns/1234/LowerStack",
"https://api.4insight.io/v1.0/Campaigns/1234/LowerStack",
headers=headers_expect,
)
response.raise_for_status.assert_called()
Expand Down Expand Up @@ -625,7 +631,7 @@ def test_get_lowerstack_camelcase(
):
out = campaigns_api_camelcase.get_lowerstack("1234")
auth_session_camelcase.get.assert_called_once_with(
"/v1.0/Campaigns/1234/LowerStack",
"https://api.4insight.io/v1.0/Campaigns/1234/LowerStack",
headers=headers_expect,
)
response_camelcase.raise_for_status.assert_called()
Expand All @@ -649,7 +655,7 @@ def test_get_swimops_campaign(
):
out = campaigns_api.get_swimops_campaign("1234")
auth_session.get.assert_called_once_with(
"/v1.1/Campaigns/1234/Swimops",
"https://api.4insight.io/v1.1/Campaigns/1234/Swimops",
headers=headers_expect,
)
response.raise_for_status.assert_called()
Expand Down Expand Up @@ -682,7 +688,7 @@ def test_get_swimops_campaign_camelcase(
):
out = campaigns_api_camelcase.get_swimops_campaign("1234")
auth_session_camelcase.get.assert_called_once_with(
"/v1.1/Campaigns/1234/Swimops",
"https://api.4insight.io/v1.1/Campaigns/1234/Swimops",
headers=headers_expect,
)
response_camelcase.raise_for_status.assert_called()
Expand All @@ -709,7 +715,7 @@ def test_get_swimops_campaign_camelcase(
def test_get_swimops(self, campaigns_api, auth_session, response, headers_expect):
out = campaigns_api.get_swimops()
auth_session.get.assert_called_once_with(
"/v1.1/Campaigns/Swimops",
"https://api.4insight.io/v1.1/Campaigns/Swimops",
headers=headers_expect,
)
response.raise_for_status.assert_called()
Expand Down Expand Up @@ -744,7 +750,7 @@ def test_get_swimops_camelcase(
):
out = campaigns_api_camelcase.get_swimops()
auth_session_camelcase.get.assert_called_once_with(
"/v1.1/Campaigns/Swimops",
"https://api.4insight.io/v1.1/Campaigns/Swimops",
headers=headers_expect,
)
response_camelcase.raise_for_status.assert_called()
Expand Down

0 comments on commit 7987e74

Please sign in to comment.