Skip to content

Commit de2d658

Browse files
committed
Adding playwright/camoufox tests for cookies and improve the timeout test
1 parent 239e2c7 commit de2d658

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

tests/fetchers/test_camoufox.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ def setUp(self):
1515
self.status_501 = f'{url}/status/501'
1616
self.basic_url = f'{url}/get'
1717
self.html_url = f'{url}/html'
18+
self.delayed_url = f'{url}/delay/10' # 10 Seconds delay response
19+
self.cookies_url = f"{url}/cookies/set/test/value"
1820

1921
def test_basic_fetch(self):
2022
"""Test doing basic fetch request with multiple statuses"""
@@ -35,6 +37,10 @@ def test_waiting_selector(self):
3537
"""Test if waiting for a selector make page does not finish loading or not"""
3638
self.assertEqual(self.fetcher.fetch(self.html_url, wait_selector='h1').status, 200)
3739

40+
def test_cookies_loading(self):
41+
"""Test if cookies are set after the request"""
42+
self.assertEqual(self.fetcher.fetch(self.cookies_url).cookies, {'test': 'value'})
43+
3844
def test_automation(self):
3945
"""Test if automation break the code or not"""
4046
def scroll_page(page):
@@ -53,4 +59,4 @@ def test_properties(self):
5359

5460
def test_infinite_timeout(self):
5561
"""Test if infinite timeout breaks the code or not"""
56-
self.assertEqual(self.fetcher.fetch(self.html_url, timeout=None).status, 200)
62+
self.assertEqual(self.fetcher.fetch(self.delayed_url, timeout=None).status, 200)

tests/fetchers/test_playwright.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ def setUp(self):
1515
self.status_501 = f'{url}/status/501'
1616
self.basic_url = f'{url}/get'
1717
self.html_url = f'{url}/html'
18+
self.delayed_url = f'{url}/delay/10' # 10 Seconds delay response
19+
self.cookies_url = f"{url}/cookies/set/test/value"
1820

1921
def test_basic_fetch(self):
2022
"""Test doing basic fetch request with multiple statuses"""
@@ -34,6 +36,10 @@ def test_waiting_selector(self):
3436
"""Test if waiting for a selector make page does not finish loading or not"""
3537
self.assertEqual(self.fetcher.fetch(self.html_url, wait_selector='h1').status, 200)
3638

39+
def test_cookies_loading(self):
40+
"""Test if cookies are set after the request"""
41+
self.assertEqual(self.fetcher.fetch(self.cookies_url).cookies, {'test': 'value'})
42+
3743
def test_automation(self):
3844
"""Test if automation break the code or not"""
3945
def scroll_page(page):
@@ -65,4 +71,4 @@ def test_cdp_url(self):
6571

6672
def test_infinite_timeout(self):
6773
"""Test if infinite timeout breaks the code or not"""
68-
self.assertEqual(self.fetcher.fetch(self.html_url, timeout=None).status, 200)
74+
self.assertEqual(self.fetcher.fetch(self.delayed_url, timeout=None).status, 200)

0 commit comments

Comments
 (0)