@@ -136,25 +136,26 @@ async def test_actor_create_request_list_from_url() -> None:
136
136
async def test_actor_create_request_list_from_url_additional_inputs () -> None :
137
137
"""Test that all generated request properties are correctly populated from input values."""
138
138
expected_simple_url = 'https://www.someurl.com'
139
- example_actor_input : dict [str , Any ] = {ActorInputKeys .startUrls :[
140
- {ActorInputKeys .startUrls .requestsFromUrl : 'https://crawlee.dev/file.txt' , 'method' : 'POST' ,
141
- ActorInputKeys .startUrls .headers : {'key' : 'value' },
142
- ActorInputKeys .startUrls .payload : 'some_payload' ,
143
- ActorInputKeys .startUrls .userData : {'another_key' : 'another_value' }},
144
- ]}
139
+ example_start_url_input = {
140
+ ActorInputKeys .startUrls .requestsFromUrl : 'https://crawlee.dev/file.txt' ,
141
+ ActorInputKeys .startUrls .method : 'POST' ,
142
+ ActorInputKeys .startUrls .headers : {'key' : 'value' },
143
+ ActorInputKeys .startUrls .payload : 'some_payload' ,
144
+ ActorInputKeys .startUrls .userData : {'another_key' : 'another_value' }}
145
+ example_actor_input : dict [str , Any ] = {ActorInputKeys .startUrls :[example_start_url_input ]}
145
146
response_bodies = iter ((expected_simple_url ,))
146
147
http_client = HttpxHttpClient ()
147
148
with mock .patch .object (http_client , 'send_request' , return_value = _create_dummy_response (response_bodies )):
148
149
generated_input = await Input .read (example_actor_input , http_client = http_client )
149
150
request = await generated_input .start_urls .fetch_next_request ()
150
151
151
152
# Check all properties correctly created for request
153
+ example_start_url_input = example_actor_input [ActorInputKeys .startUrls ][0 ]
152
154
assert request
153
155
assert request .url == expected_simple_url
154
- assert request .method == example_actor_input [ActorInputKeys .startUrls ][0 ][ActorInputKeys .startUrls .method ]
155
- assert request .headers .root == example_actor_input [ActorInputKeys .startUrls ][0 ][ActorInputKeys .startUrls .headers ]
156
- assert request .payload == example_actor_input [ActorInputKeys .startUrls ][0 ][ActorInputKeys .startUrls .payload ].encode (
157
- 'utf-8' )
156
+ assert request .method == example_start_url_input [ActorInputKeys .startUrls .method ]
157
+ assert request .headers .root == example_start_url_input [ActorInputKeys .startUrls .headers ]
158
+ assert request .payload == str (example_start_url_input [ActorInputKeys .startUrls .payload ]).encode ('utf-8' )
158
159
expected_user_data = UserData ()
159
160
for key , value in example_actor_input [ActorInputKeys .startUrls ][0 ][ActorInputKeys .startUrls .userData ].items ():
160
161
expected_user_data [key ] = value
@@ -174,7 +175,7 @@ async def test_actor_create_request_list_from_url_additional_inputs() -> None:
174
175
'http://www.something.com/somethignelse.txt' ,
175
176
'http://non-english-chars-áíéåü.com' ,
176
177
'http://www.port.com:1234' ,
177
- 'http://username:password@something.apify .com'
178
+ 'http://username:password@something.else .com'
178
179
])
179
180
def test_url_no_commas_regex_true_positives (true_positive : str ) -> None :
180
181
example_string = f'Some text { true_positive } some more text'
0 commit comments