mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
37a01b806d
- incremental sync on watch - sync non-markdown files in knowledge base - experimental `read_resource` tool for reading non-markdown files in raw form (pdf, image)
64 lines
2.0 KiB
Python
64 lines
2.0 KiB
Python
"""Tests for MemoryUrl parsing."""
|
|
|
|
from basic_memory.schemas.memory import memory_url, memory_url_path, normalize_memory_url
|
|
|
|
|
|
def test_basic_permalink():
|
|
"""Test basic permalink parsing."""
|
|
url = memory_url.validate_strings("memory://specs/search")
|
|
assert str(url) == "memory://specs/search"
|
|
assert memory_url_path(url) == "specs/search"
|
|
|
|
|
|
def test_glob_pattern():
|
|
"""Test pattern matching."""
|
|
url = memory_url.validate_python("memory://specs/search/*")
|
|
assert memory_url_path(url) == "specs/search/*"
|
|
|
|
|
|
def test_related_prefix():
|
|
"""Test related content prefix."""
|
|
url = memory_url.validate_python("memory://related/specs/search")
|
|
assert memory_url_path(url) == "related/specs/search"
|
|
|
|
|
|
def test_context_prefix():
|
|
"""Test context prefix."""
|
|
url = memory_url.validate_python("memory://context/current")
|
|
assert memory_url_path(url) == "context/current"
|
|
|
|
|
|
def test_complex_pattern():
|
|
"""Test multiple glob patterns."""
|
|
url = memory_url.validate_python("memory://specs/*/search/*")
|
|
assert memory_url_path(url) == "specs/*/search/*"
|
|
|
|
|
|
def test_path_with_dashes():
|
|
"""Test path with dashes and other chars."""
|
|
url = memory_url.validate_python("memory://file-sync-and-note-updates-implementation")
|
|
assert memory_url_path(url) == "file-sync-and-note-updates-implementation"
|
|
|
|
|
|
def test_str_representation():
|
|
"""Test converting back to string."""
|
|
url = memory_url.validate_python("memory://specs/search")
|
|
assert url == "memory://specs/search"
|
|
|
|
|
|
def test_normalize_memory_url():
|
|
"""Test converting back to string."""
|
|
url = normalize_memory_url("memory://specs/search")
|
|
assert url == "memory://specs/search"
|
|
|
|
|
|
def test_normalize_memory_url_no_prefix():
|
|
"""Test converting back to string."""
|
|
url = normalize_memory_url("specs/search")
|
|
assert url == "memory://specs/search"
|
|
|
|
|
|
def test_normalize_memory_url_empty():
|
|
"""Test converting back to string."""
|
|
assert normalize_memory_url("") == ""
|