4c51189d41
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
41 lines
1.1 KiB
Python
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)
|