Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

1.4 KB
Raw Blame
"""Simple test for URL utility functions without pytest."""

from local_deep_research.utilities.url_utils import normalize_url


def test_url_normalization():
    """Test the normalize_url function."""

    # Test localhost without scheme
    assert normalize_url("localhost:11434") == "http://localhost:11434"
    assert normalize_url("127.0.0.1:11434") == "http://127.0.0.1:11434"

    # Test external host without scheme
    assert normalize_url("example.com:11434") == "https://example.com:11434"

    # Test malformed URL with scheme
    assert normalize_url("http:localhost:11434") == "http://localhost:11434"
    assert (
        normalize_url("https:example.com:11434") == "https://example.com:11434"
    )

    # Test well-formed URLs
    assert normalize_url("http://localhost:11434") == "http://localhost:11434"
    assert (
        normalize_url("https://example.com:11434")
        == "https://example.com:11434"
    )

    # Test URLs with double slash prefix
    assert normalize_url("//localhost:11434") == "http://localhost:11434"
    assert normalize_url("//example.com:11434") == "https://example.com:11434"

    # Test empty URL (should raise ValueError)
    try:
        normalize_url("")
    except ValueError:
        pass  # Expected
    else:
        raise AssertionError("Expected ValueError for empty URL")

    print("All tests passed!")


if __name__ == "__main__":
    test_url_normalization()