Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(api): enable strict typing for website crawl controller tests (#43507)
Eddy ZHANG3be01cbb7ada
diff --git a/api/tests/unit_tests/controllers/console/datasets/test_website.py b/api/tests/unit_tests/controllers/console/datasets/test_website.pyindex a88577547d2..8af09aa06e2 100644--- a/api/tests/unit_tests/controllers/console/datasets/test_website.py+++ b/api/tests/unit_tests/controllers/console/datasets/test_website.py@@ -1,3 +1,5 @@+import inspect+import pytestfrom flask import Flaskfrom pytest_mock import MockerFixture@@ -16,22 +18,15 @@ from services.data_source.website_service import ()-def unwrap(func):- """Recursively unwrap decorated functions."""- while hasattr(func, "__wrapped__"):- func = func.__wrapped__- return func--@pytest.fixture-def app():+def app() -> Flask:app = Flask("test_website_crawl")app.config["TESTING"] = Truereturn app@pytest.fixture(autouse=True)-def bypass_auth_and_setup(mocker: MockerFixture):+def bypass_auth_and_setup(mocker: MockerFixture) -> None:"""Bypass setup/login/account decorators."""mocker.patch("controllers.console.datasets.website.login_required",@@ -48,9 +43,9 @@ def bypass_auth_and_setup(mocker: MockerFixture):class TestWebsiteCrawlApi:- def test_crawl_success(self, app: Flask, mocker: MockerFixture):+ def test_crawl_success(self, app: Flask, mocker: MockerFixture) -> None:api = WebsiteCrawlApi()- method = unwrap(api.post)+ method = inspect.unwrap(api.post)payload = {"provider": "firecrawl",@@ -74,14 +69,14 @@ class TestWebsiteCrawlApi:WebsiteCrawlApiRequest(provider="firecrawl", url="https://example.com", options={"depth": 1}))- def test_crawl_invalid_payload(self, app: Flask, mocker: MockerFixture):+ def test_crawl_invalid_payload(self, app: Flask, mocker: MockerFixture) -> None:api = WebsiteCrawlApi()- method = unwrap(api.post)+ method = inspect.unwrap(api.post)payload = {"provider": "firecrawl","url": "bad-url",- "options": {},+ "options": dict[str, object](),}req_data = WebsiteCrawlPayload.model_validate(payload)@@ -95,9 +90,9 @@ class TestWebsiteCrawlApi:with pytest.raises(WebsiteCrawlError, match="invalid payload"):method(api, req_data)- def test_crawl_service_error(self, app: Flask, mocker: MockerFixture):+ def test_crawl_service_error(self, app: Flask, mocker: MockerFixture) -> None:api = WebsiteCrawlApi()- method = unwrap(api.post)+ method = inspect.unwrap(api.post)payload = {"provider": "firecrawl",@@ -122,9 +117,9 @@ class TestWebsiteCrawlApi:class TestWebsiteCrawlStatusApi:- def test_get_status_success(self, app: Flask, mocker: MockerFixture):+ def test_get_status_success(self, app: Flask, mocker: MockerFixture) -> None:api = WebsiteCrawlStatusApi()- method = unwrap(api.get)+ method = inspect.unwrap(api.get)job_id = "job-123"req_data = WebsiteCrawlStatusQuery.model_validate({"provider": "firecrawl"})@@ -142,9 +137,9 @@ class TestWebsiteCrawlStatusApi:assert result["status"] == "completed"get_status.assert_called_once_with(WebsiteCrawlStatusApiRequest(provider="firecrawl", job_id=job_id))- def test_get_status_invalid_provider(self, app: Flask, mocker: MockerFixture):+ def test_get_status_invalid_provider(self, app: Flask, mocker: MockerFixture) -> None:api = WebsiteCrawlStatusApi()- method = unwrap(api.get)+ method = inspect.unwrap(api.get)job_id = "job-123"req_data = WebsiteCrawlStatusQuery.model_validate({"provider": "firecrawl"})@@ -159,9 +154,9 @@ class TestWebsiteCrawlStatusApi:with pytest.raises(WebsiteCrawlError, match="invalid provider"):method(api, req_data, job_id)- def test_get_status_service_error(self, app: Flask, mocker: MockerFixture):+ def test_get_status_service_error(self, app: Flask, mocker: MockerFixture) -> None:api = WebsiteCrawlStatusApi()- method = unwrap(api.get)+ method = inspect.unwrap(api.get)job_id = "job-123"req_data = WebsiteCrawlStatusQuery.model_validate({"provider": "firecrawl"})diff --git a/api/tests/unit_tests/pyrefly.toml b/api/tests/unit_tests/pyrefly.tomlindex 3b6f9a039ea..119df67c075 100644--- a/api/tests/unit_tests/pyrefly.toml+++ b/api/tests/unit_tests/pyrefly.toml@@ -89,7 +89,6 @@ project-excludes = ["controllers/console/datasets/test_hit_testing.py","controllers/console/datasets/test_hit_testing_base.py","controllers/console/datasets/test_metadata.py",- "controllers/console/datasets/test_website.py","controllers/console/explore/test_audio.py","controllers/console/explore/test_banner.py","controllers/console/explore/test_completion.py",