44
55import pytest
66from scrapy import Request , Spider
7- from scrapy .http .headers import Headers
87
98from crawlee import Request as CrawleeRequest
9+ from crawlee ._types import HttpHeaders
1010
1111from apify .scrapy .requests import to_scrapy_request
1212
@@ -47,7 +47,7 @@ def test__to_scrapy_request__without_reconstruction_with_optional_fields(spider:
4747 method = 'GET' ,
4848 unique_key = 'https://crawlee.dev' ,
4949 id = 'fvwscO2UJLdr10B' ,
50- headers = {'Authorization' : 'Bearer access_token' },
50+ headers = HttpHeaders ( {'Authorization' : 'Bearer access_token' }) ,
5151 user_data = {'some_user_data' : 'test' },
5252 )
5353
@@ -58,7 +58,7 @@ def test__to_scrapy_request__without_reconstruction_with_optional_fields(spider:
5858 assert apify_request .method == scrapy_request .method
5959 assert apify_request .id == scrapy_request .meta .get ('apify_request_id' )
6060 assert apify_request .unique_key == scrapy_request .meta .get ('apify_request_unique_key' )
61- assert Headers ( apify_request .headers ) == scrapy_request .headers
61+ assert apify_request .headers . get ( 'authorization' ) == scrapy_request .headers . get ( 'authorization' ). decode ()
6262 assert apify_request .user_data == scrapy_request .meta .get ('userData' )
6363
6464
@@ -91,7 +91,7 @@ def test__to_scrapy_request__with_reconstruction_with_optional_fields(spider: Sp
9191 method = 'GET' ,
9292 id = 'fvwscO2UJLdr10B' ,
9393 unique_key = 'https://apify.com' ,
94- headers = {'Authorization' : 'Bearer access_token' },
94+ headers = HttpHeaders ( {'Authorization' : 'Bearer access_token' }) ,
9595 user_data = {
9696 'some_user_data' : 'hello' ,
9797 'scrapy_request' : 'gASVJgIAAAAAAAB9lCiMA3VybJSMEWh0dHBzOi8vYXBpZnkuY29tlIwIY2FsbGJhY2uUTowHZXJy\n YmFja5ROjAdoZWFkZXJzlH2UKEMGQWNjZXB0lF2UQz90ZXh0L2h0bWwsYXBwbGljYXRpb24veGh0\n bWwreG1sLGFwcGxpY2F0aW9uL3htbDtxPTAuOSwqLyo7cT0wLjiUYUMPQWNjZXB0LUxhbmd1YWdl\n lF2UQwJlbpRhQwpVc2VyLUFnZW50lF2UQyNTY3JhcHkvMi4xMS4wICgraHR0cHM6Ly9zY3JhcHku\n b3JnKZRhQw9BY2NlcHQtRW5jb2RpbmeUXZRDDWd6aXAsIGRlZmxhdGWUYXWMBm1ldGhvZJSMA0dF\n VJSMBGJvZHmUQwCUjAdjb29raWVzlH2UjARtZXRhlH2UKIwQYXBpZnlfcmVxdWVzdF9pZJSMD2Z2\n d3NjTzJVSkxkcjEwQpSMGGFwaWZ5X3JlcXVlc3RfdW5pcXVlX2tleZSMEWh0dHBzOi8vYXBpZnku\n Y29tlIwQZG93bmxvYWRfdGltZW91dJRHQGaAAAAAAACMDWRvd25sb2FkX3Nsb3SUjAlhcGlmeS5j\n b22UjBBkb3dubG9hZF9sYXRlbmN5lEc/tYIIAAAAAHWMCGVuY29kaW5nlIwFdXRmLTiUjAhwcmlv\n cml0eZRLAIwLZG9udF9maWx0ZXKUiYwFZmxhZ3OUXZSMCWNiX2t3YXJnc5R9lHUu\n ' , # noqa: E501
@@ -105,7 +105,7 @@ def test__to_scrapy_request__with_reconstruction_with_optional_fields(spider: Sp
105105 assert apify_request .method == scrapy_request .method
106106 assert apify_request .id == scrapy_request .meta .get ('apify_request_id' )
107107 assert apify_request .unique_key == scrapy_request .meta .get ('apify_request_unique_key' )
108- assert Headers ( apify_request .headers ) == scrapy_request .headers
108+ assert apify_request .headers . get ( 'authorization' ) == scrapy_request .headers . get ( 'authorization' ). decode ()
109109 assert apify_request .user_data == scrapy_request .meta .get ('userData' )
110110
111111
0 commit comments