tests: Updating tests according to the new changes

This commit is contained in:
Karim shoair
2025-06-22 02:12:39 +03:00
parent f28b4d3653
commit 8b46e3a3a5
2 changed files with 14 additions and 14 deletions
@@ -1,16 +1,16 @@
import pytest import pytest
import pytest_httpbin import pytest_httpbin
from scrapling import PlayWrightFetcher from scrapling import DynamicFetcher
PlayWrightFetcher.auto_match = True DynamicFetcher.auto_match = True
@pytest_httpbin.use_class_based_httpbin @pytest_httpbin.use_class_based_httpbin
class TestPlayWrightFetcherAsync: class TestDynamicFetcherAsync:
@pytest.fixture @pytest.fixture
def fetcher(self): def fetcher(self):
return PlayWrightFetcher return DynamicFetcher
@pytest.fixture @pytest.fixture
def urls(self, httpbin): def urls(self, httpbin):
@@ -94,10 +94,10 @@ class TestPlayWrightFetcherAsync:
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_cdp_url_invalid(self, fetcher, urls): async def test_cdp_url_invalid(self, fetcher, urls):
"""Test if invalid CDP URLs raise appropriate exceptions""" """Test if invalid CDP URLs raise appropriate exceptions"""
with pytest.raises(ValueError): with pytest.raises(TypeError):
await fetcher.async_fetch(urls["html_url"], cdp_url="blahblah") await fetcher.async_fetch(urls["html_url"], cdp_url="blahblah")
with pytest.raises(ValueError): with pytest.raises(TypeError):
await fetcher.async_fetch( await fetcher.async_fetch(
urls["html_url"], cdp_url="blahblah", nstbrowser_mode=True urls["html_url"], cdp_url="blahblah", nstbrowser_mode=True
) )
@@ -108,5 +108,5 @@ class TestPlayWrightFetcherAsync:
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_infinite_timeout(self, fetcher, urls): async def test_infinite_timeout(self, fetcher, urls):
"""Test if infinite timeout breaks the code or not""" """Test if infinite timeout breaks the code or not"""
response = await fetcher.async_fetch(urls["delayed_url"], timeout=None) response = await fetcher.async_fetch(urls["delayed_url"], timeout=0)
assert response.status == 200 assert response.status == 200
@@ -1,17 +1,17 @@
import pytest import pytest
import pytest_httpbin import pytest_httpbin
from scrapling import PlayWrightFetcher from scrapling import DynamicFetcher
PlayWrightFetcher.auto_match = True DynamicFetcher.auto_match = True
@pytest_httpbin.use_class_based_httpbin @pytest_httpbin.use_class_based_httpbin
class TestPlayWrightFetcher: class TestDynamicFetcher:
@pytest.fixture(scope="class") @pytest.fixture(scope="class")
def fetcher(self): def fetcher(self):
"""Fixture to create a StealthyFetcher instance for the entire test class""" """Fixture to create a StealthyFetcher instance for the entire test class"""
return PlayWrightFetcher return DynamicFetcher
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def setup_urls(self, httpbin): def setup_urls(self, httpbin):
@@ -85,10 +85,10 @@ class TestPlayWrightFetcher:
def test_cdp_url_invalid(self, fetcher): def test_cdp_url_invalid(self, fetcher):
"""Test if invalid CDP URLs raise appropriate exceptions""" """Test if invalid CDP URLs raise appropriate exceptions"""
with pytest.raises(ValueError): with pytest.raises(TypeError):
fetcher.fetch(self.html_url, cdp_url="blahblah") fetcher.fetch(self.html_url, cdp_url="blahblah")
with pytest.raises(ValueError): with pytest.raises(TypeError):
fetcher.fetch(self.html_url, cdp_url="blahblah", nstbrowser_mode=True) fetcher.fetch(self.html_url, cdp_url="blahblah", nstbrowser_mode=True)
with pytest.raises(Exception): with pytest.raises(Exception):
@@ -99,5 +99,5 @@ class TestPlayWrightFetcher:
fetcher, fetcher,
): ):
"""Test if infinite timeout breaks the code or not""" """Test if infinite timeout breaks the code or not"""
response = fetcher.fetch(self.delayed_url, timeout=None) response = fetcher.fetch(self.delayed_url, timeout=0)
assert response.status == 200 assert response.status == 200