2024-08-05 21:49:18 -05:00
|
|
|
# -*- coding: utf-8; -*-
|
|
|
|
|
|
|
|
from wuttjamaican.conf import WuttaConfig
|
2024-08-25 12:20:28 -05:00
|
|
|
from wuttjamaican.testing import FileConfigTestCase
|
2024-08-12 21:17:08 -05:00
|
|
|
from wuttaweb.menus import MenuHandler
|
2024-08-05 21:49:18 -05:00
|
|
|
|
|
|
|
|
2024-08-25 12:20:28 -05:00
|
|
|
class DataTestCase(FileConfigTestCase):
|
2024-08-05 21:49:18 -05:00
|
|
|
"""
|
2024-08-12 21:17:08 -05:00
|
|
|
Base class for test suites requiring a full (typical) database.
|
2024-08-05 21:49:18 -05:00
|
|
|
"""
|
|
|
|
|
|
|
|
def setUp(self):
|
2024-08-12 21:17:08 -05:00
|
|
|
self.setup_db()
|
2024-08-05 21:49:18 -05:00
|
|
|
|
2024-08-12 21:17:08 -05:00
|
|
|
def setup_db(self):
|
2024-08-25 12:20:28 -05:00
|
|
|
self.setup_files()
|
2024-08-05 21:49:18 -05:00
|
|
|
self.config = WuttaConfig(defaults={
|
|
|
|
'wutta.db.default.url': 'sqlite://',
|
|
|
|
})
|
2024-08-12 21:17:08 -05:00
|
|
|
self.app = self.config.get_app()
|
2024-08-05 21:49:18 -05:00
|
|
|
|
2024-08-12 21:17:08 -05:00
|
|
|
# init db
|
|
|
|
model = self.app.model
|
|
|
|
model.Base.metadata.create_all(bind=self.config.appdb_engine)
|
|
|
|
self.session = self.app.make_session()
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
self.teardown_db()
|
|
|
|
|
|
|
|
def teardown_db(self):
|
2024-08-25 12:20:28 -05:00
|
|
|
self.teardown_files()
|
2024-08-12 21:17:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
class NullMenuHandler(MenuHandler):
|
|
|
|
"""
|
|
|
|
Dummy menu handler for testing.
|
|
|
|
"""
|
|
|
|
def make_menus(self, request, **kwargs):
|
|
|
|
return []
|