Skip to content

Commit

Permalink
Don't use live data stores in the repr() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Aug 2, 2024
1 parent edc3fd8 commit 27bfbb8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 0 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ async def psycopg_async_store() -> AsyncGenerator[DataStore, None]:

from apscheduler.datastores.sqlalchemy import SQLAlchemyDataStore

pytest.importorskip("psycopg", reason="psycopg not available")
engine = create_async_engine(
"postgresql+psycopg://postgres:secret@localhost/testdb"
)
Expand All @@ -178,7 +177,6 @@ def psycopg_sync_store() -> Generator[DataStore, None, None]:

from apscheduler.datastores.sqlalchemy import SQLAlchemyDataStore

pytest.importorskip("psycopg", reason="psycopg not available")
engine = create_engine("postgresql+psycopg://postgres:secret@localhost/testdb")
try:
with engine.begin() as conn:
Expand Down
27 changes: 18 additions & 9 deletions tests/test_datastores.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,18 +832,27 @@ class TestRepr:
async def test_memory(self, memory_store: MemoryDataStore) -> None:
assert repr(memory_store) == "MemoryDataStore()"

async def test_aiosqlite(
self, aiosqlite_store: SQLAlchemyDataStore, tmp_path: Path
) -> None:
assert repr(aiosqlite_store) == (
f"SQLAlchemyDataStore(url='sqlite+aiosqlite:///{tmp_path}/test.db')"
async def test_sqlite(self, tmp_path: Path) -> None:
from sqlalchemy import create_engine

engine = create_engine(f"sqlite:///{tmp_path}")
data_store = SQLAlchemyDataStore(engine)
assert repr(data_store) == (
f"SQLAlchemyDataStore(url='sqlite+sqlite:///{tmp_path}')"
)

async def test_psycopg(self, psycopg_async_store: SQLAlchemyDataStore) -> None:
assert repr(psycopg_async_store) == (
async def test_psycopg(self) -> None:
from sqlalchemy.ext.asyncio import create_async_engine

engine = create_async_engine(
"postgresql+psycopg://postgres:secret@localhost:5432/postgres"
)
data_store = SQLAlchemyDataStore(engine)
assert repr(data_store) == (
"SQLAlchemyDataStore(url='postgresql+psycopg://postgres:***@localhost/"
"testdb', schema='psycopg_async')"
)

async def test_mongodb(self, mongodb_store: MongoDBDataStore) -> None:
assert repr(mongodb_store) == "MongoDBDataStore(host=[('localhost', 27017)])"
async def test_mongodb(self) -> None:
data_store = MongoDBDataStore("mongo://localhost")
assert repr(data_store) == "MongoDBDataStore(host=[('localhost', 27017)])"

0 comments on commit 27bfbb8

Please sign in to comment.