mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 10:15:27 -04:00
Fix fresh checkout test failures
Make .env optional in tests and prevent endpoint resolver stubs from leaking into model route tests.
This commit is contained in:
@@ -8,7 +8,7 @@ from unittest.mock import MagicMock
|
|||||||
for mod in [
|
for mod in [
|
||||||
'sqlalchemy', 'sqlalchemy.orm', 'sqlalchemy.ext', 'sqlalchemy.ext.declarative',
|
'sqlalchemy', 'sqlalchemy.orm', 'sqlalchemy.ext', 'sqlalchemy.ext.declarative',
|
||||||
'sqlalchemy.ext.hybrid', 'sqlalchemy.sql', 'sqlalchemy.sql.expression',
|
'sqlalchemy.ext.hybrid', 'sqlalchemy.sql', 'sqlalchemy.sql.expression',
|
||||||
'src.database', 'src.endpoint_resolver',
|
'src.database',
|
||||||
'src.agent_tools',
|
'src.agent_tools',
|
||||||
'core.models', 'core.database',
|
'core.models', 'core.database',
|
||||||
]:
|
]:
|
||||||
|
|||||||
+8
-5
@@ -32,10 +32,13 @@ class TestAppStructure:
|
|||||||
src_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "src")
|
src_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "src")
|
||||||
assert os.path.exists(src_path), "src directory should exist"
|
assert os.path.exists(src_path), "src directory should exist"
|
||||||
|
|
||||||
def test_env_file_exists(self):
|
def test_env_file_is_optional_and_ignored(self):
|
||||||
"""Test that .env file exists"""
|
"""A fresh checkout should not require a private .env file."""
|
||||||
env_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), ".env")
|
root = os.path.dirname(os.path.dirname(__file__))
|
||||||
assert os.path.exists(env_path), ".env file should exist"
|
gitignore_path = os.path.join(root, ".gitignore")
|
||||||
|
with open(gitignore_path, encoding="utf-8") as fh:
|
||||||
|
ignored = {line.strip() for line in fh}
|
||||||
|
assert ".env" in ignored, ".env should stay local and ignored"
|
||||||
|
|
||||||
def test_env_example_exists(self):
|
def test_env_example_exists(self):
|
||||||
"""Test that .env.example exists"""
|
"""Test that .env.example exists"""
|
||||||
@@ -92,4 +95,4 @@ class TestRouteFiles:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
pytest.main([__file__, "-v"])
|
pytest.main([__file__, "-v"])
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from unittest.mock import MagicMock
|
|||||||
for mod in [
|
for mod in [
|
||||||
'sqlalchemy', 'sqlalchemy.orm', 'sqlalchemy.ext', 'sqlalchemy.ext.declarative',
|
'sqlalchemy', 'sqlalchemy.orm', 'sqlalchemy.ext', 'sqlalchemy.ext.declarative',
|
||||||
'sqlalchemy.ext.hybrid', 'sqlalchemy.sql', 'sqlalchemy.sql.expression',
|
'sqlalchemy.ext.hybrid', 'sqlalchemy.sql', 'sqlalchemy.sql.expression',
|
||||||
'src.database', 'src.endpoint_resolver',
|
'src.database',
|
||||||
'core.models', 'core.database',
|
'core.models', 'core.database',
|
||||||
]:
|
]:
|
||||||
if mod not in sys.modules:
|
if mod not in sys.modules:
|
||||||
|
|||||||
@@ -6,6 +6,13 @@ from unittest.mock import MagicMock
|
|||||||
import httpx
|
import httpx
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
_endpoint_resolver = sys.modules.get("src.endpoint_resolver")
|
||||||
|
if _endpoint_resolver is not None and not getattr(_endpoint_resolver, "__file__", None):
|
||||||
|
# Other tests stub this module during collection. These helper tests need
|
||||||
|
# the real URL normalization helpers so Anthropic /v1 handling is covered.
|
||||||
|
sys.modules.pop("src.endpoint_resolver", None)
|
||||||
|
sys.modules.pop("routes.model_routes", None)
|
||||||
|
|
||||||
if "core.database" not in sys.modules:
|
if "core.database" not in sys.modules:
|
||||||
_core_db = types.ModuleType("core.database")
|
_core_db = types.ModuleType("core.database")
|
||||||
for _name in [
|
for _name in [
|
||||||
|
|||||||
Reference in New Issue
Block a user