summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2021-08-29 12:09:08 +0300
committerAlex Grönholm <alex.gronholm@nextday.fi>2021-08-29 12:09:08 +0300
commit77f6c89d2a93e474a4917938512403eb20a1cb93 (patch)
tree0c7c269b325300a4eea147f385515c08ce816bbd /tests
parentba68a3f21162d9dee6fed41a22bf1a1f04dd8701 (diff)
downloadapscheduler-77f6c89d2a93e474a4917938512403eb20a1cb93.tar.gz
Made it possible to skip tests involving external databases
Diffstat (limited to 'tests')
-rw-r--r--tests/conftest.py28
1 files changed, 11 insertions, 17 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 970ea07..068590f 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -45,16 +45,8 @@ def setup_memory_store() -> Generator[DataStore, None, None]:
def setup_mongodb_store() -> Generator[DataStore, None, None]:
from apscheduler.datastores.sync.mongodb import MongoDBDataStore
from pymongo import MongoClient
- from pymongo.errors import ConnectionFailure
- client = MongoClient(tz_aware=True, serverSelectionTimeoutMS=1000)
- try:
- client.admin.command('ismaster')
- except ConnectionFailure:
- pytest.skip('MongoDB server not available')
- raise
-
- with client:
+ with MongoClient(tz_aware=True, serverSelectionTimeoutMS=1000) as client:
yield MongoDBDataStore(client, start_from_scratch=True)
@@ -96,16 +88,17 @@ async def setup_async_sqlalchemy_store() -> AsyncGenerator[AsyncDataStore, None]
@pytest.fixture(params=[
pytest.param(setup_memory_store, id='memory'),
- pytest.param(setup_mongodb_store, id='mongodb'),
- pytest.param(setup_sqlalchemy_store, id='sqlalchemy')
+ pytest.param(setup_mongodb_store, id='mongodb', marks=[pytest.mark.externaldb]),
+ pytest.param(setup_sqlalchemy_store, id='sqlalchemy', marks=[pytest.mark.externaldb])
])
def setup_sync_store(request) -> ContextManager[DataStore]:
return request.param
@pytest.fixture(params=[
- pytest.param(setup_postgresql_store, id='postgresql'),
- pytest.param(setup_async_sqlalchemy_store, id='async_sqlalchemy')
+ pytest.param(setup_postgresql_store, id='postgresql', marks=[pytest.mark.externaldb]),
+ pytest.param(setup_async_sqlalchemy_store, id='async_sqlalchemy',
+ marks=[pytest.mark.externaldb])
])
def setup_async_store(request) -> AsyncContextManager[AsyncDataStore]:
return request.param
@@ -113,10 +106,11 @@ def setup_async_store(request) -> AsyncContextManager[AsyncDataStore]:
@pytest.fixture(params=[
pytest.param(setup_memory_store, id='memory'),
- pytest.param(setup_mongodb_store, id='mongodb'),
- pytest.param(setup_sqlalchemy_store, id='sqlalchemy'),
- pytest.param(setup_postgresql_store, id='postgresql'),
- pytest.param(setup_async_sqlalchemy_store, id='async_sqlalchemy')
+ pytest.param(setup_mongodb_store, id='mongodb', marks=[pytest.mark.externaldb]),
+ pytest.param(setup_sqlalchemy_store, id='sqlalchemy', marks=[pytest.mark.externaldb]),
+ pytest.param(setup_postgresql_store, id='postgresql', marks=[pytest.mark.externaldb]),
+ pytest.param(setup_async_sqlalchemy_store, id='async_sqlalchemy',
+ marks=[pytest.mark.externaldb])
])
async def datastore_cm(request):
cm = request.param()