3
0
Fork 0

test: add 'nodb' test runner

ensure things work as expected if sqlalchemy is not installed
This commit is contained in:
Lance Edgar 2024-07-04 08:00:42 -05:00
parent 132073177c
commit f5825e964c
5 changed files with 193 additions and 148 deletions

View file

@ -7,10 +7,9 @@ import warnings
from unittest import TestCase
from unittest.mock import patch, MagicMock
import sqlalchemy as sa
from sqlalchemy import orm
import pytest
from wuttjamaican import app, db
from wuttjamaican import app
from wuttjamaican.conf import WuttaConfig
@ -46,6 +45,11 @@ class TestAppHandler(TestCase):
shutil.rmtree(tempdir)
def test_make_session(self):
try:
from wuttjamaican import db
except ImportError:
pytest.skip("test is not relevant without sqlalchemy")
session = self.app.make_session()
self.assertIsInstance(session, db.Session.class_)
@ -60,6 +64,12 @@ class TestAppHandler(TestCase):
foo='bar', factory=self.app.make_session)
def test_get_setting(self):
try:
import sqlalchemy as sa
from sqlalchemy import orm
except ImportError:
pytest.skip("test is not relevant without sqlalchemy")
Session = orm.sessionmaker()
engine = sa.create_engine('sqlite://')
session = Session(bind=engine)