Skip to content

🕷️ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev

test(cookies): Adjust cookies unit tests to the new changes

Karim shoair32686172402d
diff --git a/tests/fetchers/async/test_camoufox.py b/tests/fetchers/async/test_camoufox.py
index 4aaef57..0041e14 100644
--- a/tests/fetchers/async/test_camoufox.py
+++ b/tests/fetchers/async/test_camoufox.py
@@ -61,7 +61,8 @@ class TestStealthyFetcher:
async def test_cookies_loading(self, fetcher, urls):
"""Test if cookies are set after the request"""
response = await fetcher.async_fetch(urls["cookies_url"])
- assert response.cookies == {"test": "value"}
+ cookies = {response.cookies[0]['name']: response.cookies[0]['value']}
+ assert cookies == {"test": "value"}
async def test_automation(self, fetcher, urls):
"""Test if automation break the code or not"""
diff --git a/tests/fetchers/async/test_playwright.py b/tests/fetchers/async/test_playwright.py
index 169e5bd..732bba1 100644
--- a/tests/fetchers/async/test_playwright.py
+++ b/tests/fetchers/async/test_playwright.py
@@ -57,7 +57,8 @@ class TestPlayWrightFetcherAsync:
async def test_cookies_loading(self, fetcher, urls):
"""Test if cookies are set after the request"""
response = await fetcher.async_fetch(urls["cookies_url"])
- assert response.cookies == {"test": "value"}
+ cookies = {response.cookies[0]['name']: response.cookies[0]['value']}
+ assert cookies == {"test": "value"}
@pytest.mark.asyncio
async def test_automation(self, fetcher, urls):
diff --git a/tests/fetchers/sync/test_camoufox.py b/tests/fetchers/sync/test_camoufox.py
index b38bace..02413eb 100644
--- a/tests/fetchers/sync/test_camoufox.py
+++ b/tests/fetchers/sync/test_camoufox.py
@@ -51,7 +51,9 @@ class TestStealthyFetcher:
def test_cookies_loading(self, fetcher):
"""Test if cookies are set after the request"""
- assert fetcher.fetch(self.cookies_url).cookies == {"test": "value"}
+ response = fetcher.fetch(self.cookies_url)
+ cookies = {response.cookies[0]['name']: response.cookies[0]['value']}
+ assert cookies == {"test": "value"}
def test_automation(self, fetcher):
"""Test if automation break the code or not"""
diff --git a/tests/fetchers/sync/test_playwright.py b/tests/fetchers/sync/test_playwright.py
index 689500a..cadb9b5 100644
--- a/tests/fetchers/sync/test_playwright.py
+++ b/tests/fetchers/sync/test_playwright.py
@@ -51,7 +51,9 @@ class TestPlayWrightFetcher:
def test_cookies_loading(self, fetcher):
"""Test if cookies are set after the request"""
- assert fetcher.fetch(self.cookies_url).cookies == {"test": "value"}
+ response = fetcher.fetch(self.cookies_url)
+ cookies = {response.cookies[0]['name']: response.cookies[0]['value']}
+ assert cookies == {"test": "value"}
def test_automation(self, fetcher):
"""Test if automation break the code or not"""