2
0
Fork 0
wuttjamaican/tests/db/test_util.py
Lance Edgar 4c51189d41 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
2024-08-30 20:30:09 -05:00

41 lines
1.1 KiB
Python

# -*- coding: utf-8; -*-
from unittest import TestCase
try:
import sqlalchemy as sa
from wuttjamaican.db import util as mod
from wuttjamaican.db.model.base import Setting
except ImportError:
pass
else:
class TestModelBase(TestCase):
def test_dict_behavior(self):
setting = 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 = mod.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 = mod.uuid_fk_column('foo.bar')
self.assertIsInstance(column, sa.Column)
self.assertIsInstance(column.type, sa.String)
self.assertEqual(column.type.length, 32)