fix(scada): use project-scoped metadata
This commit is contained in:
@@ -1,48 +1,7 @@
|
||||
import asyncio
|
||||
from datetime import datetime, timezone
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from types import ModuleType
|
||||
|
||||
|
||||
def _load_time_api_module():
|
||||
module_path = (
|
||||
Path(__file__).resolve().parents[2] / "app" / "services" / "time_api.py"
|
||||
)
|
||||
spec = importlib.util.spec_from_file_location("tests_time_api_under_test", module_path)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
assert spec and spec.loader
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
def _load_realtime_repository():
|
||||
time_api_module = _load_time_api_module()
|
||||
app_module = ModuleType("app")
|
||||
services_module = ModuleType("app.services")
|
||||
services_module.time_api = time_api_module
|
||||
app_module.services = services_module
|
||||
sys.modules["app"] = app_module
|
||||
sys.modules["app.services"] = services_module
|
||||
sys.modules["app.services.time_api"] = time_api_module
|
||||
|
||||
module_path = (
|
||||
Path(__file__).resolve().parents[2]
|
||||
/ "app"
|
||||
/ "infra"
|
||||
/ "db"
|
||||
/ "timescaledb"
|
||||
/ "repositories"
|
||||
/ "realtime.py"
|
||||
)
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
"tests_realtime_repo_under_test", module_path
|
||||
)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
assert spec and spec.loader
|
||||
spec.loader.exec_module(module)
|
||||
return module.RealtimeRepository
|
||||
from app.infra.db.timescaledb.repositories.realtime import RealtimeRepository
|
||||
|
||||
|
||||
class _FakeCursor:
|
||||
@@ -71,7 +30,6 @@ class _FakeConnection:
|
||||
|
||||
|
||||
def test_get_links_by_time_range_normalizes_inputs_to_utc():
|
||||
RealtimeRepository = _load_realtime_repository()
|
||||
conn = _FakeConnection()
|
||||
|
||||
asyncio.run(
|
||||
@@ -91,7 +49,6 @@ def test_get_links_by_time_range_normalizes_inputs_to_utc():
|
||||
|
||||
|
||||
def test_get_nodes_by_time_range_normalizes_inputs_to_utc():
|
||||
RealtimeRepository = _load_realtime_repository()
|
||||
conn = _FakeConnection()
|
||||
|
||||
asyncio.run(
|
||||
|
||||
Reference in New Issue
Block a user