@@ -74,38 +74,43 @@ def test_key_value_store_should_create_public_keys_non_expiring_url(self, apify_
74
74
store .delete ()
75
75
assert apify_client .key_value_store (created_store ['id' ]).get () is None
76
76
77
- @pytest .mark .parametrize ('signature ' , [None , 'custom-signature ' ])
77
+ @pytest .mark .parametrize ('signing_key ' , [None , 'custom-signing-key ' ])
78
78
@parametrized_api_urls
79
- def test_public_url (self , api_token : str , api_url : str , api_public_url : str , signature : str ) -> None :
79
+ def test_public_url (self , api_token : str , api_url : str , api_public_url : str , signing_key : str ) -> None :
80
80
apify_client = ApifyClient (token = api_token , api_url = api_url , api_public_url = api_public_url )
81
81
kvs = apify_client .key_value_store ('someID' )
82
82
83
83
# Mock the API call to return predefined response
84
84
with mock .patch .object (
85
85
apify_client .http_client ,
86
86
'call' ,
87
- return_value = Mock (text = _get_mocked_api_kvs_response (signing_key = signature )),
87
+ return_value = Mock (text = _get_mocked_api_kvs_response (signing_key = signing_key )),
88
88
):
89
89
public_url = kvs .create_keys_public_url ()
90
- expected_signature = f'?signature={ public_url .split ("signature=" )[1 ]} ' if signature else ''
90
+ expected_signature = f'?signature={ public_url .split ("signature=" )[1 ]} ' if signing_key else ''
91
91
assert public_url == (
92
92
f'{ (api_public_url or DEFAULT_API_URL ).strip ("/" )} /v2/key-value-stores/someID/keys{ expected_signature } '
93
93
)
94
94
95
- @pytest .mark .parametrize ('signature' , [None , 'custom-signature' ])
96
- def test_record_public_url (self , api_token : str , signature : str ) -> None :
97
- apify_client = ApifyClient (token = api_token )
95
+ @pytest .mark .parametrize ('signing_key' , [None , 'custom-signing-key' ])
96
+ @parametrized_api_urls
97
+ def test_record_public_url (self , api_token : str , api_url : str , api_public_url : str , signing_key : str ) -> None :
98
+ apify_client = ApifyClient (token = api_token , api_url = api_url , api_public_url = api_public_url )
98
99
kvs = apify_client .key_value_store ('someID' )
99
100
100
101
# Mock the API call to return predefined response
101
102
with mock .patch .object (
102
103
apify_client .http_client ,
103
104
'call' ,
104
- return_value = Mock (text = _get_mocked_api_kvs_response (signing_key = signature )),
105
+ return_value = Mock (text = _get_mocked_api_kvs_response (signing_key = signing_key )),
105
106
):
106
107
public_url = kvs .get_record_public_url (key = 'key' )
107
- expected_signature = f'?signature={ public_url .split ("signature=" )[1 ]} ' if signature else ''
108
- assert public_url == (f'{ DEFAULT_API_URL } /v2/key-value-stores/someID/records/key{ expected_signature } ' )
108
+ expected_signature = f'?signature={ public_url .split ("signature=" )[1 ]} ' if signing_key else ''
109
+ assert public_url == (
110
+ f'{ (api_public_url or DEFAULT_API_URL ).strip ("/" )} /v2/key-value-stores/someID/records/key{
111
+ expected_signature
112
+ } '
113
+ )
109
114
110
115
111
116
class TestKeyValueStoreAsync :
@@ -151,35 +156,40 @@ async def test_key_value_store_should_create_public_keys_non_expiring_url(
151
156
await store .delete ()
152
157
assert await apify_client_async .key_value_store (created_store ['id' ]).get () is None
153
158
154
- @pytest .mark .parametrize ('signature ' , [None , 'custom-signature ' ])
159
+ @pytest .mark .parametrize ('signing_key ' , [None , 'custom-signing-key ' ])
155
160
@parametrized_api_urls
156
- async def test_record_public_url (self , api_token : str , api_url : str , api_public_url : str , signature : str ) -> None :
161
+ async def test_record_public_url (self , api_token : str , api_url : str , api_public_url : str , signing_key : str ) -> None :
157
162
apify_client = ApifyClientAsync (token = api_token , api_url = api_url , api_public_url = api_public_url )
158
163
kvs = apify_client .key_value_store ('someID' )
159
164
160
165
# Mock the API call to return predefined response
161
166
with mock .patch .object (
162
167
apify_client .http_client ,
163
168
'call' ,
164
- return_value = Mock (text = _get_mocked_api_kvs_response (signing_key = signature )),
169
+ return_value = Mock (text = _get_mocked_api_kvs_response (signing_key = signing_key )),
165
170
):
166
171
public_url = await kvs .create_keys_public_url ()
167
- expected_signature = f'?signature={ public_url .split ("signature=" )[1 ]} ' if signature else ''
172
+ expected_signature = f'?signature={ public_url .split ("signature=" )[1 ]} ' if signing_key else ''
168
173
assert public_url == (
169
174
f'{ (api_public_url or DEFAULT_API_URL ).strip ("/" )} /v2/key-value-stores/someID/keys{ expected_signature } '
170
175
)
171
176
172
- @pytest .mark .parametrize ('signature' , [None , 'custom-signature' ])
173
- async def test_public_url (self , api_token : str , signature : str ) -> None :
174
- apify_client = ApifyClientAsync (token = api_token )
177
+ @pytest .mark .parametrize ('signing_key' , [None , 'custom-signing-key' ])
178
+ @parametrized_api_urls
179
+ async def test_public_url (self , api_token : str , api_url : str , api_public_url : str , signing_key : str ) -> None :
180
+ apify_client = ApifyClientAsync (token = api_token , api_url = api_url , api_public_url = api_public_url )
175
181
kvs = apify_client .key_value_store ('someID' )
176
182
177
183
# Mock the API call to return predefined response
178
184
with mock .patch .object (
179
185
apify_client .http_client ,
180
186
'call' ,
181
- return_value = Mock (text = _get_mocked_api_kvs_response (signing_key = signature )),
187
+ return_value = Mock (text = _get_mocked_api_kvs_response (signing_key = signing_key )),
182
188
):
183
189
public_url = await kvs .get_record_public_url (key = 'key' )
184
- expected_signature = f'?signature={ public_url .split ("signature=" )[1 ]} ' if signature else ''
185
- assert public_url == (f'{ DEFAULT_API_URL } /v2/key-value-stores/someID/records/key{ expected_signature } ' )
190
+ expected_signature = f'?signature={ public_url .split ("signature=" )[1 ]} ' if signing_key else ''
191
+ assert public_url == (
192
+ f'{ (api_public_url or DEFAULT_API_URL ).strip ("/" )} /v2/key-value-stores/someID/records/key{
193
+ expected_signature
194
+ } '
195
+ )
0 commit comments