Skip to content

Commit d7163b8

Browse files
committed
Add non existent url test
1 parent 6fb6f03 commit d7163b8

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tests/integration/test_dataset.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ def test_public_url(self, api_token: str, api_url: str, api_public_url: str) ->
6060
finally:
6161
dataset.delete()
6262

63+
def test_public_url_nonexistent_host(self, api_token: str) -> None:
64+
dataset_name = 'whatever'
65+
non_existent_url = 'http://10.0.88.214:8010'
66+
apify_client = ApifyClient(token=api_token, api_url=non_existent_url)
67+
kvs_client = apify_client.dataset(dataset_id=dataset_name)
68+
assert kvs_client._url() == f'{non_existent_url}/v2/datasets/{dataset_name}'
69+
assert kvs_client._url(public=True) == f'{DEFAULT_API_URL}/v2/datasets/{dataset_name}'
70+
6371

6472
class TestDatasetAsync:
6573
async def test_dataset_should_create_public_items_expiring_url_with_params(
@@ -115,3 +123,11 @@ async def test_public_url(self, api_token: str, api_url: str, api_public_url: st
115123
)
116124
finally:
117125
await dataset.delete()
126+
127+
def test_public_url_nonexistent_host(self, api_token: str) -> None:
128+
dataset_name = 'whatever'
129+
non_existent_url = 'http://10.0.88.214:8010'
130+
apify_client = ApifyClientAsync(token=api_token, api_url=non_existent_url)
131+
kvs_client = apify_client.dataset(dataset_id=dataset_name)
132+
assert kvs_client._url() == f'{non_existent_url}/v2/datasets/{dataset_name}'
133+
assert kvs_client._url(public=True) == f'{DEFAULT_API_URL}/v2/datasets/{dataset_name}'

tests/integration/test_key_value_store.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ def test_public_url(self, api_token: str, api_url: str, api_public_url: str) ->
6060
finally:
6161
kvs.delete()
6262

63+
def test_public_url_nonexistent_host(self, api_token: str) -> None:
64+
kvs_name = 'whatever'
65+
non_existent_url = 'http://10.0.88.214:8010'
66+
apify_client = ApifyClient(token=api_token, api_url=non_existent_url)
67+
kvs_client = apify_client.key_value_store(key_value_store_id=kvs_name)
68+
assert kvs_client._url() == f'{non_existent_url}/v2/key-value-stores/{kvs_name}'
69+
assert kvs_client._url(public=True) == f'{DEFAULT_API_URL}/v2/key-value-stores/{kvs_name}'
70+
6371

6472
class TestKeyValueStoreAsync:
6573
async def test_key_value_store_should_create_expiring_keys_public_url_with_params(
@@ -119,3 +127,11 @@ async def test_public_url(self, api_token: str, api_url: str, api_public_url: st
119127
)
120128
finally:
121129
await kvs.delete()
130+
131+
async def test_public_url_nonexistent_host(self, api_token: str) -> None:
132+
kvs_name = 'whatever'
133+
non_existent_url = 'http://10.0.88.214:8010'
134+
apify_client = ApifyClientAsync(token=api_token, api_url=non_existent_url)
135+
kvs_client = apify_client.key_value_store(key_value_store_id=kvs_name)
136+
assert kvs_client._url() == f'{non_existent_url}/v2/key-value-stores/{kvs_name}'
137+
assert kvs_client._url(public=True) == f'{DEFAULT_API_URL}/v2/key-value-stores/{kvs_name}'

0 commit comments

Comments
 (0)