fix: move model base class out of model subpkg
and other things, used by other packages (rattail) otherwise when rattail imports them, the whole WJ model comes along with it and it can interfere with sqlalchemy-continuum versioning
This commit is contained in:
parent
e9507fb5a4
commit
4c51189d41
7 changed files with 134 additions and 82 deletions
|
@ -3,42 +3,16 @@
|
|||
from unittest import TestCase
|
||||
|
||||
try:
|
||||
import sqlalchemy as sa
|
||||
from wuttjamaican.db.model import base as model
|
||||
from wuttjamaican.db.model import base as mod
|
||||
from wuttjamaican.db.model.auth import User
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
|
||||
class TestModelBase(TestCase):
|
||||
|
||||
def test_dict_behavior(self):
|
||||
setting = model.Setting()
|
||||
self.assertEqual(list(iter(setting)), [('name', None), ('value', None)])
|
||||
self.assertIsNone(setting['name'])
|
||||
setting.name = 'foo'
|
||||
self.assertEqual(setting['name'], 'foo')
|
||||
|
||||
class TestUUIDColumn(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
column = model.uuid_column()
|
||||
self.assertIsInstance(column, sa.Column)
|
||||
self.assertIsInstance(column.type, sa.String)
|
||||
self.assertEqual(column.type.length, 32)
|
||||
|
||||
class TestUUIDFKColumn(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
column = model.uuid_fk_column('foo.bar')
|
||||
self.assertIsInstance(column, sa.Column)
|
||||
self.assertIsInstance(column.type, sa.String)
|
||||
self.assertEqual(column.type.length, 32)
|
||||
|
||||
class TestSetting(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
setting = model.Setting()
|
||||
setting = mod.Setting()
|
||||
self.assertEqual(str(setting), "")
|
||||
setting.name = 'foo'
|
||||
self.assertEqual(str(setting), "foo")
|
||||
|
@ -46,13 +20,13 @@ else:
|
|||
class TestPerson(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
person = model.Person()
|
||||
person = mod.Person()
|
||||
self.assertEqual(str(person), "")
|
||||
person.full_name = "Barney Rubble"
|
||||
self.assertEqual(str(person), "Barney Rubble")
|
||||
|
||||
def test_users(self):
|
||||
person = model.Person()
|
||||
person = mod.Person()
|
||||
self.assertIsNone(person.user)
|
||||
|
||||
user = User()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue