Add Home Assistant inbound gateway
This commit is contained in:
+3
-23
@@ -8,7 +8,7 @@ from alembic.config import Config
|
||||
from sqlalchemy import create_engine, text
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
import app.db
|
||||
import app.db as app_db
|
||||
from app.main import create_app
|
||||
from scripts.location_db_adopt import (
|
||||
EXPECTED_USER_VERSION,
|
||||
@@ -23,26 +23,6 @@ def _make_alembic_config(database_url: str) -> Config:
|
||||
config.set_main_option("sqlalchemy.url", database_url)
|
||||
return config
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def location_client(ready_location_database, monkeypatch: pytest.MonkeyPatch):
|
||||
database_url = ready_location_database["location_url"]
|
||||
|
||||
engine = create_engine(database_url, connect_args={"check_same_thread": False})
|
||||
session_local = sessionmaker(bind=engine, autoflush=False, autocommit=False)
|
||||
|
||||
monkeypatch.setattr(app.db, "engine", engine)
|
||||
monkeypatch.setattr(app.db, "SessionLocal", session_local)
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
fastapi_app = create_app()
|
||||
with TestClient(fastapi_app) as client:
|
||||
yield client, engine
|
||||
|
||||
engine.dispose()
|
||||
|
||||
|
||||
def test_location_record_endpoint_writes_row(location_client) -> None:
|
||||
client, engine = location_client
|
||||
|
||||
@@ -243,8 +223,8 @@ def test_legacy_style_location_db_can_be_stamped_and_adopted(
|
||||
|
||||
engine = create_engine(database_url, connect_args={"check_same_thread": False})
|
||||
session_local = sessionmaker(bind=engine, autoflush=False, autocommit=False)
|
||||
monkeypatch.setattr(app.db, "engine", engine)
|
||||
monkeypatch.setattr(app.db, "SessionLocal", session_local)
|
||||
monkeypatch.setattr(app_db, "engine", engine)
|
||||
monkeypatch.setattr(app_db, "SessionLocal", session_local)
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
Reference in New Issue
Block a user