Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Delete 30 test files that catch no production regression (#8390)
Shuchang Zheng3fbfcf603093
diff --git a/skyvern/core/script_generations/CLAUDE.md b/skyvern/core/script_generations/CLAUDE.mdindex a8eaffdab..59e73af11 100644--- a/skyvern/core/script_generations/CLAUDE.md+++ b/skyvern/core/script_generations/CLAUDE.md@@ -123,7 +123,7 @@ When modifying regeneration or caching logic, test these scenarios:```bash# Run script-related tests-python -m pytest tests/unit/ -k "script" --ignore=tests/unit/test_security.py -v+python -m pytest tests/unit/ -k "script" -v# Run conditional caching tests specificallypython -m pytest tests/unit/test_conditional_script_caching.py -vdiff --git a/tests/unit/forge/sdk/db/test_base_repository.py b/tests/unit/forge/sdk/db/test_base_repository.pydeleted file mode 100644index c7eaef2e8..000000000--- a/tests/unit/forge/sdk/db/test_base_repository.py+++ /dev/null@@ -1,56 +0,0 @@-from unittest.mock import MagicMock--from sqlalchemy.exc import OperationalError--from skyvern.forge.sdk.db.base_repository import BaseRepository-from skyvern.forge.sdk.db.protocols import RunReader, TaskReader, WorkflowParameterReader, WorkflowReader-from skyvern.forge.sdk.db.utils import serialize_proxy_location-from skyvern.schemas.runs import GeoTarget, ProxyLocation---class TestSerializeProxyLocation:- def test_none(self):- assert serialize_proxy_location(None) is None-- def test_geo_target(self):- geo = GeoTarget(country="US", state="CA")- result = serialize_proxy_location(geo)- assert result is not None- assert "US" in result-- def test_enum(self):- result = serialize_proxy_location(ProxyLocation.RESIDENTIAL)- assert result == "RESIDENTIAL"---class TestBaseRepository:- def test_init_with_defaults(self):- mock_session = MagicMock()- repo = BaseRepository(session_factory=mock_session, debug_enabled=True)- assert repo.Session is mock_session- assert repo.debug_enabled is True-- def test_is_retryable_error_default(self):- mock_session = MagicMock()- repo = BaseRepository(session_factory=mock_session)- error = OperationalError("statement", {}, Exception("server closed the connection unexpectedly"))- assert repo.is_retryable_error(error) is False # default returns False-- def test_is_retryable_error_custom(self):- mock_session = MagicMock()-- def custom_fn(e):- return "closed" in str(e).lower()-- repo = BaseRepository(session_factory=mock_session, is_retryable_error_fn=custom_fn)- error = OperationalError("statement", {}, Exception("server closed the connection"))- assert repo.is_retryable_error(error) is True---class TestProtocols:- def test_protocols_importable(self):- """Protocols should be importable and runtime-checkable."""- assert TaskReader is not None- assert WorkflowReader is not None- assert WorkflowParameterReader is not None- assert RunReader is not Nonediff --git a/tests/unit/forge/sdk/db/test_sentinels.py b/tests/unit/forge/sdk/db/test_sentinels.pydeleted file mode 100644index 290672b0c..000000000--- a/tests/unit/forge/sdk/db/test_sentinels.py+++ /dev/null@@ -1,18 +0,0 @@-"""Tests for the _UNSET sentinel value."""--from skyvern.forge.sdk.db._sentinels import _UNSET---def test_unset_is_unique_sentinel() -> None:- """_UNSET should be distinguishable from None and other values."""- assert _UNSET is not None- assert _UNSET is not False- assert _UNSET != 0- assert _UNSET != ""---def test_unset_identity() -> None:- """_UNSET should be the same object across imports."""- from skyvern.forge.sdk.db._sentinels import _UNSET as second_import-- assert _UNSET is second_importdiff --git a/tests/unit/test_browser_artifacts_remote_browser_session_id.py b/tests/unit/test_browser_artifacts_remote_browser_session_id.pydeleted file mode 100644index fb7df3b69..000000000--- a/tests/unit/test_browser_artifacts_remote_browser_session_id.py+++ /dev/null@@ -1,21 +0,0 @@-"""``BrowserArtifacts.remote_browser_session_id`` is an opaque identifier for-a remote browser session. The OSS package carries only the id; downstream-creators populate it. This test pins the default (``None``) and the contract-that consumers can read/write it through normal pydantic semantics — nothing-more.-"""--from __future__ import annotations--from skyvern.webeye.browser_artifacts import BrowserArtifacts---def test_remote_browser_session_id_defaults_to_none() -> None:- artifacts = BrowserArtifacts()- assert artifacts.remote_browser_session_id is None---def test_remote_browser_session_id_round_trips() -> None:- artifacts = BrowserArtifacts()- artifacts.remote_browser_session_id = "opaque-session-handle"- assert artifacts.remote_browser_session_id == "opaque-session-handle"diff --git a/tests/unit/test_captcha_solve_timing_prompt.py b/tests/unit/test_captcha_solve_timing_prompt.pydeleted file mode 100644index 08b371dc7..000000000--- a/tests/unit/test_captcha_solve_timing_prompt.py+++ /dev/null@@ -1,45 +0,0 @@-"""Verify extract-action prompts contain captcha solve-timing guidance.--Captcha tokens expire quickly, so the prompt must instruct the LLM to-place SOLVE_CAPTCHA immediately before the protected submit — not before-a long form-fill sequence.-"""--from typing import Any--import pytest--from skyvern.forge.prompts import prompt_engine--_BASE_KWARGS: dict[str, Any] = {- "navigation_goal": "fill out the privacy request form and submit",- "navigation_payload_str": "{}",- "starting_url": "https://example.test/start",- "current_url": "https://example.test/form",- "data_extraction_goal": None,- "action_history": "[]",- "error_code_mapping_str": None,- "local_datetime": "2026-06-03T10:00:00Z",- "verification_code_check": False,- "complete_criterion": None,- "terminate_criterion": None,- "show_close_page_action": False,- "open_tabs_context": None,- "elements": "<html></html>",- "recent_dialog_messages_str": None,-}--[email protected]("template", ["extract-action", "extract-action-static"])-def test_prompt_contains_captcha_timing_guidance(template: str) -> None:- rendered = prompt_engine.load_prompt(template, **_BASE_KWARGS)- assert "expire" in rendered.lower(), "Prompt must mention token expiry"- assert "submit" in rendered.lower() and "captcha" in rendered.lower(), (- "Prompt must connect captcha timing to submit"- )--[email protected]("template", ["extract-action", "extract-action-static"])-def test_prompt_captcha_guidance_says_fill_first(template: str) -> None:- rendered = prompt_engine.load_prompt(template, **_BASE_KWARGS).lower()- assert "fill all form fields first" in rendered, "Prompt must instruct filling form fields first before captcha"diff --git a/tests/unit/test_domutils_deprecated_marker.py b/tests/unit/test_domutils_deprecated_marker.pydeleted file mode 100644index 71ab5da8d..000000000--- a/tests/unit/test_domutils_deprecated_marker.py+++ /dev/null@@ -1,49 +0,0 @@-"""Source-contract test for the deprecated visual bounding box overlay helpers.--The visual overlay helpers in ``domUtils.js`` are retained briefly for backwards-compatibility and are scheduled for removal. Future cleanup should be-intentional, so this test pins two contracts:--1. The helpers still exist (we have not silently deleted them mid-deprecation).-2. Each helper carries a clear ``DEPRECATED`` marker so the next reader knows- the path is on its way out.-"""--from __future__ import annotations--from pathlib import Path--_DOM_UTILS = Path(__file__).resolve().parents[2] / "skyvern" / "webeye" / "scraper" / "domUtils.js"---DEPRECATED_OVERLAY_HELPERS = (- "drawBoundingBoxes",- "buildElementsAndDrawBoundingBoxes",- "removeBoundingBoxes",-)---def _function_decl_line(source_lines: list[str], helper: str) -> int:- """Return 1-based line number of the helper's ``function`` declaration."""-- for idx, line in enumerate(source_lines):- if f"function {helper}(" in line:- return idx + 1- raise AssertionError(f"could not find function declaration for {helper}() in domUtils.js")---def test_deprecated_overlay_helpers_still_present() -> None:- source = _DOM_UTILS.read_text()- for helper in DEPRECATED_OVERLAY_HELPERS:- assert f"function {helper}(" in source, f"{helper} was unexpectedly removed before its scheduled cleanup"---def test_deprecated_overlay_helpers_have_marker_comment() -> None:- source_lines = _DOM_UTILS.read_text().splitlines()- for helper in DEPRECATED_OVERLAY_HELPERS:- decl_line = _function_decl_line(source_lines, helper)- # Look at the 6 lines preceding the declaration for a DEPRECATED marker.- preceding = source_lines[max(0, decl_line - 7) : decl_line - 1]- assert any("DEPRECATED" in line for line in preceding), (- f"{helper}() must carry a DEPRECATED marker in the preceding comment block; checked lines: {preceding!r}"- )diff --git a/tests/unit/test_download_action_dedup.py b/tests/unit/test_download_action_dedup.pydeleted file mode 100644index 2852e317f..000000000--- a/tests/unit/test_download_action_dedup.py+++ /dev/null@@ -1,157 +0,0 @@-"""Tests for the download action file dedup/cleanup logic in handler.py.--These tests exercise the dedup block inline in handle_action by creating-real files in tmp_path and calling the same logic the handler uses:-re-scan → remove 0-byte → checksum dedup.-"""--import os-from pathlib import Path--from skyvern.forge.sdk.api.files import calculate_sha256_for_file, list_files_in_directory---def _run_dedup(download_dir: Path, list_files_before: list[str]) -> list[str]:- """Reproduce the dedup block from handle_action (post-rescan version)."""- list_files_after = list_files_in_directory(download_dir)- new_file_paths = set(list_files_after) - set(list_files_before)- seen_checksums: dict[str, str] = {}- deduplicated_paths: list[str] = []- for fp in sorted(new_file_paths):- if not os.path.isfile(fp):- deduplicated_paths.append(fp)- continue- if os.path.getsize(fp) == 0:- os.remove(fp)- continue- checksum = calculate_sha256_for_file(fp)- if checksum in seen_checksums:- os.remove(fp)- else:- seen_checksums[checksum] = fp- deduplicated_paths.append(fp)- return [os.path.basename(fp) for fp in deduplicated_paths]---class TestRescanCatchesLateFiles:- def test_file_appearing_after_initial_snapshot(self, tmp_path: Path) -> None:- """A file that appears after the polling-loop snapshot should be- caught by re-scanning the directory."""- before: list[str] = []-- # Simulate: polling loop sees file_a and breaks- (tmp_path / "file_a.pdf").write_bytes(b"content_a")- stale_snapshot = list_files_in_directory(tmp_path)- assert len(stale_snapshot) == 1-- # Simulate: browser-native download completes after the break- (tmp_path / "file_b.pdf").write_bytes(b"content_b")-- # Re-scan picks up both- result = _run_dedup(tmp_path, before)- assert sorted(result) == ["file_a.pdf", "file_b.pdf"]-- def test_late_duplicate_removed_by_rescan(self, tmp_path: Path) -> None:- """A late-arriving file with identical content should be deduped."""- before: list[str] = []- content = b"same pdf content"-- (tmp_path / "xhr_capture.pdf").write_bytes(content)- # Browser-native download arrives later with different name- (tmp_path / "abc123.pdf").write_bytes(content)-- result = _run_dedup(tmp_path, before)- assert len(result) == 1- # Only one file should remain on disk- remaining = list(tmp_path.iterdir())- assert len(remaining) == 1---class TestZeroByteFileRemoval:- def test_zero_byte_file_removed(self, tmp_path: Path) -> None:- """A 0-byte file should be deleted, not included in results."""- before: list[str] = []- (tmp_path / "good.pdf").write_bytes(b"real content")- (tmp_path / "empty.pdf").write_bytes(b"")-- result = _run_dedup(tmp_path, before)- assert result == ["good.pdf"]- assert not (tmp_path / "empty.pdf").exists()-- def test_only_zero_byte_file_yields_empty_result(self, tmp_path: Path) -> None:- """If the only new file is 0 bytes, result is empty."""- before: list[str] = []- (tmp_path / "broken.pdf").write_bytes(b"")-- result = _run_dedup(tmp_path, before)- assert result == []- assert not (tmp_path / "broken.pdf").exists()---class TestChecksumDedup:- def test_identical_files_deduped(self, tmp_path: Path) -> None:- """Two files with same content: keep first (sorted), remove second."""- before: list[str] = []- content = b"identical content"- (tmp_path / "a_first.pdf").write_bytes(content)- (tmp_path / "b_second.pdf").write_bytes(content)-- result = _run_dedup(tmp_path, before)- assert result == ["a_first.pdf"]- assert (tmp_path / "a_first.pdf").exists()- assert not (tmp_path / "b_second.pdf").exists()-- def test_different_files_both_kept(self, tmp_path: Path) -> None:- before: list[str] = []- (tmp_path / "report_a.pdf").write_bytes(b"content_a")- (tmp_path / "report_b.pdf").write_bytes(b"content_b")-- result = _run_dedup(tmp_path, before)- assert sorted(result) == ["report_a.pdf", "report_b.pdf"]---class TestRemoteUriSafety:- def test_remote_uri_not_hashed_or_deleted(self, tmp_path: Path) -> None:- """Remote URIs (s3://, azure://) should be passed through without- hashing or deletion attempts."""- before: list[str] = []- (tmp_path / "local.pdf").write_bytes(b"local content")-- # Simulate browser-session files as remote URIs in list_files_after- remote_uri = "s3://bucket/org/browser_sessions/bs_123/downloads/report.pdf"- list_files_after = list_files_in_directory(tmp_path) + [remote_uri]-- new_file_paths = set(list_files_after) - set(before)- deduplicated_paths: list[str] = []- seen_checksums: dict[str, str] = {}- for fp in sorted(new_file_paths):- if not os.path.isfile(fp):- # Remote URIs pass through here (not a local file)- deduplicated_paths.append(fp)- continue- if os.path.getsize(fp) == 0:- os.remove(fp)- continue- checksum = calculate_sha256_for_file(fp)- if checksum in seen_checksums:- os.remove(fp)- else:- seen_checksums[checksum] = fp- deduplicated_paths.append(fp)-- basenames = sorted(os.path.basename(fp) for fp in deduplicated_paths)- assert basenames == ["local.pdf", "report.pdf"]- assert (tmp_path / "local.pdf").exists()---class TestPreExistingFilesExcluded:- def test_files_present_before_action_not_in_result(self, tmp_path: Path) -> None:- """Files in list_files_before should not appear in new_file_paths."""- (tmp_path / "old.pdf").write_bytes(b"old")- before = list_files_in_directory(tmp_path)-- (tmp_path / "new.pdf").write_bytes(b"new")-- result = _run_dedup(tmp_path, before)- assert result == ["new.pdf"]- assert (tmp_path / "old.pdf").exists()diff --git a/tests/unit/test_sdk_artifact_client_surface.py b/tests/unit/test_sdk_artifact_client_surface.pydeleted file mode 100644index cc3365bc4..000000000--- a/tests/unit/test_sdk_artifact_client_surface.py+++ /dev/null@@ -1,9 +0,0 @@-from skyvern.client.client import AsyncSkyvern, Skyvern---def test_clients_do_not_expose_removed_artifacts_subclient() -> None:- """Artifact operations stay on the root clients, not a removed subclient."""- assert callable(Skyvern.get_run_artifacts)- assert callable(AsyncSkyvern.get_run_artifacts)- assert not hasattr(Skyvern(api_key="test"), "artifacts")- assert not hasattr(AsyncSkyvern(api_key="test"), "artifacts")diff --git a/tests/unit/test_security.py b/tests/unit/test_security.pydeleted file mode 100644index 8bd285255..000000000--- a/tests/unit/test_security.py+++ /dev/null@@ -1,16 +0,0 @@-import pytest-from freezegun import freeze_time--from skyvern.forge.sdk.core.security import (- create_access_token,- generate_skyvern_webhook_signature,-)--[email protected](reason="Skipping test_generate_skyvern_signature")-@freeze_time("2023-11-30 00:00:00")-def test_generate_skyvern_signature() -> None:- api_key = create_access_token("o_12345")- payload = {"task_id": "t_12345", "float": 1.0}- signed_data = generate_skyvern_webhook_signature(payload, api_key)- assert signed_data.signature == "1fac4204e1abc7cb0bdf1a42eb17d27f6f1feba065d5726777d5eb77581298c1"diff --git a/tests/unit/test_vertex_cache_model_extraction.py b/tests/unit/test_vertex_cache_model_extraction.pydeleted file mode 100644index 422995105..000000000--- a/tests/unit/test_vertex_cache_model_extraction.py+++ /dev/null@@ -1,176 +0,0 @@-"""-Tests for Vertex AI cache model name extraction from LLMRouterConfig.--This tests the fix for the issue where GEMINI_3_0_FLASH_WITH_FALLBACK was-incorrectly using 'gemini-3.0-flash' instead of 'gemini-3-flash-preview'.-"""--import re-from dataclasses import dataclass---@dataclass-class MockLLMRouterModelConfig:- model_name: str- litellm_params: dict---@dataclass-class MockLLMRouterConfig:- model_name: str- model_list: list- main_model_group: str- required_env_vars: list = None-- def __post_init__(self):- if self.required_env_vars is None:- self.required_env_vars = []---@dataclass-class MockLLMConfig:- model_name: str- required_env_vars: list = None- litellm_params: dict = None-- def __post_init__(self):- if self.required_env_vars is None:- self.required_env_vars = []---class TestVertexCacheModelExtraction:- """Test that model names are correctly extracted for Vertex AI caching."""-- def _extract_model_name(self, llm_config, resolved_llm_key: str) -> str:- """- Mimics the model name extraction logic from _create_vertex_cache_for_task.- """- model_name = "gemini-2.5-flash" # Default- extracted_name = None-- # For router configs (LLMRouterConfig), extract from model_list primary model FIRST- # This must be checked before model_name since router model_name is just an identifier- # (e.g., "gemini-3.0-flash-gpt-5-mini-fallback-router"), not an actual Vertex model- if hasattr(llm_config, "model_list") and hasattr(llm_config, "main_model_group"):- # Find the primary model in model_list by matching main_model_group- for model_entry in llm_config.model_list:- if model_entry.model_name == llm_config.main_model_group:- # Extract actual model name from litellm_params- model_param = model_entry.litellm_params.get("model", "")- if "vertex_ai/" in model_param:- extracted_name = model_param.split("/")[-1]- elif model_param.startswith("gemini-"):- extracted_name = model_param- break-- # Try to extract from model_name if it contains "vertex_ai/" or starts with "gemini-"- if not extracted_name and hasattr(llm_config, "model_name") and isinstance(llm_config.model_name, str):- if "vertex_ai/" in llm_config.model_name:- # Direct Vertex config: "vertex_ai/gemini-2.5-flash" -> "gemini-2.5-flash"- extracted_name = llm_config.model_name.split("/")[-1]- elif llm_config.model_name.startswith("gemini-"):- # Already in correct format- extracted_name = llm_config.model_name-- # For router/fallback configs, extract from api_base or infer from key name- if not extracted_name and hasattr(llm_config, "litellm_params") and llm_config.litellm_params:- params = llm_config.litellm_params- api_base = params.get("api_base") if isinstance(params, dict) else getattr(params, "api_base", None)- if api_base and isinstance(api_base, str) and "/models/" in api_base:- # Extract from URL: .../models/gemini-2.5-flash -> "gemini-2.5-flash"- extracted_name = api_base.split("/models/")[-1]-- # For router configs without api_base, infer from the llm_key itself- if not extracted_name:- # Extract version from llm_key- version_match = re.search(r"GEMINI[_-](\d+[._-]\d+)", resolved_llm_key, re.IGNORECASE)- version = version_match.group(1).replace("_", ".").replace("-", ".") if version_match else "2.5"-- # Determine flavor- if "_PRO_" in resolved_llm_key or resolved_llm_key.endswith("_PRO"):- extracted_name = f"gemini-{version}-pro"- elif "_FLASH_LITE_" in resolved_llm_key or resolved_llm_key.endswith("_FLASH_LITE"):- extracted_name = f"gemini-{version}-flash-lite"- else:- # Default to flash flavor- extracted_name = f"gemini-{version}-flash"-- if extracted_name:- model_name = extracted_name-- # Normalize model name to the canonical Vertex identifier- # Preserve preview suffixes so we don't strip required identifiers (e.g., gemini-3-flash-preview).- match = re.search(r"(gemini-\d+(?:\.\d+)?-(?:flash-lite|flash|pro)(?:-preview)?)", model_name, re.IGNORECASE)- if match:- model_name = match.group(1).lower()-- return model_name-- def test_router_config_extracts_gemini_3_flash_preview(self):- """- GEMINI_3_0_FLASH_WITH_FALLBACK should extract 'gemini-3-flash-preview',- NOT 'gemini-3.0-flash'.- """- # Create a mock router config that matches the real GEMINI_3_0_FLASH_WITH_FALLBACK- router_config = MockLLMRouterConfig(- model_name="gemini-3.0-flash-gpt-5-mini-fallback-router",- model_list=[- MockLLMRouterModelConfig(- model_name="vertex-gemini-3.0-flash",- litellm_params={"model": "vertex_ai/gemini-3-flash-preview"},- ),- MockLLMRouterModelConfig(- model_name="gpt-5-mini-fallback",- litellm_params={"model": "gpt-5-mini-2025-08-07"},- ),- ],- main_model_group="vertex-gemini-3.0-flash",- )-- model_name = self._extract_model_name(router_config, "GEMINI_3_0_FLASH_WITH_FALLBACK")-- # Should extract the correct model name with -preview suffix- assert model_name == "gemini-3-flash-preview", (- f"Expected 'gemini-3-flash-preview' but got '{model_name}'. "- "The router config should extract from model_list, not infer from llm_key."- )-- def test_direct_vertex_config_extracts_correctly(self):- """Direct VERTEX_GEMINI_3.0_FLASH should extract correctly."""- direct_config = MockLLMConfig(- model_name="vertex_ai/gemini-3-flash-preview",- )-- model_name = self._extract_model_name(direct_config, "VERTEX_GEMINI_3.0_FLASH")- assert model_name == "gemini-3-flash-preview"-- def test_router_config_extracts_gemini_2_5_flash(self):- """GEMINI_2_5_FLASH_WITH_FALLBACK should extract 'gemini-2.5-flash'."""- router_config = MockLLMRouterConfig(- model_name="gemini-2.5-flash-gpt-5-mini-fallback-router",- model_list=[- MockLLMRouterModelConfig(- model_name="vertex-gemini-2.5-flash",- litellm_params={"model": "vertex_ai/gemini-2.5-flash"},- ),- MockLLMRouterModelConfig(- model_name="gpt-5-mini-fallback",- litellm_params={"model": "gpt-5-mini-2025-08-07"},- ),- ],- main_model_group="vertex-gemini-2.5-flash",- )-- model_name = self._extract_model_name(router_config, "GEMINI_2_5_FLASH_WITH_FALLBACK")- assert model_name == "gemini-2.5-flash"-- def test_fallback_to_llm_key_inference_when_no_model_list(self):- """When there's no model_list, should fall back to llm_key inference."""- # A config that doesn't have model_list (not a router config)- simple_config = MockLLMConfig(- model_name="some-unrelated-name",- )-- model_name = self._extract_model_name(simple_config, "GEMINI_2_5_FLASH")- # Should fall back to inference from llm_key- assert model_name == "gemini-2.5-flash"diff --git a/tests/unit_tests/test_url_validators.py b/tests/unit_tests/test_url_validators.pydeleted file mode 100644index 736813bee..000000000--- a/tests/unit_tests/test_url_validators.py+++ /dev/null@@ -1,43 +0,0 @@-import sys-import types-from importlib import import_module-from pathlib import Path--import pytest--pytest.skip("Dependencies missing", allow_module_level=True)--sys.path.insert(0, str(Path(__file__).resolve().parents[2]))-ddtrace_stub = types.SimpleNamespace(tracer=None, filters=types.SimpleNamespace(FilterRequestsOnUrl=lambda x: None))-sys.modules.setdefault("ddtrace", ddtrace_stub)-sys.modules.setdefault("ddtrace.filters", ddtrace_stub.filters)--encode_url = import_module("skyvern.utils.url_validators").encode_url---def test_encode_url_basic():- """Test basic URL encoding with simple path"""- url = "https://example.com/path with spaces"- expected = "https://example.com/path%20with%20spaces"- assert encode_url(url) == expected---def test_encode_url_with_query_params():- """Test URL encoding with query parameters"""- url = "https://example.com/search?q=hello world&type=test"- expected = "https://example.com/search?q=hello%20world&type=test"- assert encode_url(url) == expected---def test_encode_url_with_special_chars():- """Test URL encoding with special characters"""- url = "https://example.com/path/with/special#chars?param=value&other=test@123"- expected = "https://example.com/path/with/special#chars?param=value&other=test@123"- assert encode_url(url) == expected---def test_encode_url_with_pre_encoded_chars():- """Test URL encoding with pre-encoded characters in query parameters"""- url = "https://example.com/search?q=hello world&type=test%20test"- expected = "https://example.com/search?q=hello%20world&type=test%20test"- assert encode_url(url) == expected