feat: refactor forms/grids/views/templates per wuttaweb compat
this starts to get things more aligned between wuttaweb and tailbone. the use case in mind so far is for a wuttaweb view to be included in a tailbone app. form and grid classes now have some new methods to match wuttaweb, so templates call the shared method names where possible. templates can no longer assume they have tailbone-native master view, form, grid etc. so must inspect context more closely in some cases.
This commit is contained in:
parent
b53479f8e4
commit
a6ce5eb21d
39 changed files with 1037 additions and 300 deletions
|
@ -3,14 +3,14 @@
|
|||
import os
|
||||
from unittest import TestCase
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from pyramid.config import Configurator
|
||||
|
||||
from wuttjamaican.testing import FileConfigTestCase
|
||||
|
||||
from rattail.config import RattailConfig
|
||||
from rattail.exceptions import ConfigurationError
|
||||
from rattail.db import Session as RattailSession
|
||||
|
||||
from tailbone import app
|
||||
from tailbone.db import Session as TailboneSession
|
||||
from rattail.config import RattailConfig
|
||||
from tailbone import app as mod
|
||||
from tests.util import DataTestCase
|
||||
|
||||
|
||||
class TestRattailConfig(TestCase):
|
||||
|
@ -18,15 +18,34 @@ class TestRattailConfig(TestCase):
|
|||
config_path = os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), 'data', 'tailbone.conf'))
|
||||
|
||||
def tearDown(self):
|
||||
# may or may not be necessary depending on test
|
||||
TailboneSession.remove()
|
||||
|
||||
def test_settings_arg_must_include_config_path_by_default(self):
|
||||
# error raised if path not provided
|
||||
self.assertRaises(ConfigurationError, app.make_rattail_config, {})
|
||||
self.assertRaises(ConfigurationError, mod.make_rattail_config, {})
|
||||
# get a config object if path provided
|
||||
result = app.make_rattail_config({'rattail.config': self.config_path})
|
||||
result = mod.make_rattail_config({'rattail.config': self.config_path})
|
||||
# nb. cannot test isinstance(RattailConfig) b/c now uses wrapper!
|
||||
self.assertIsNotNone(result)
|
||||
self.assertTrue(hasattr(result, 'get'))
|
||||
|
||||
|
||||
class TestMakePyramidConfig(DataTestCase):
|
||||
|
||||
def make_config(self):
|
||||
myconf = self.write_file('web.conf', """
|
||||
[rattail.db]
|
||||
default.url = sqlite://
|
||||
""")
|
||||
|
||||
self.settings = {
|
||||
'rattail.config': myconf,
|
||||
'mako.directories': 'tailbone:templates',
|
||||
}
|
||||
return mod.make_rattail_config(self.settings)
|
||||
|
||||
def test_basic(self):
|
||||
model = self.app.model
|
||||
model.Base.metadata.create_all(bind=self.config.appdb_engine)
|
||||
|
||||
# sanity check
|
||||
pyramid_config = mod.make_pyramid_config(self.settings)
|
||||
self.assertIsInstance(pyramid_config, Configurator)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue