2024-07-11 12:55:55 -05:00
|
|
|
# -*- coding: utf-8; -*-
|
|
|
|
|
|
|
|
from unittest import TestCase
|
|
|
|
|
|
|
|
try:
|
|
|
|
import sqlalchemy as sa
|
|
|
|
from wuttjamaican.db.model import base as model
|
2024-07-14 15:47:39 -05:00
|
|
|
from wuttjamaican.db.model.auth import User
|
2024-07-11 12:55:55 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
|
|
|
|
class TestUUIDColumn(TestCase):
|
|
|
|
|
|
|
|
def test_basic(self):
|
|
|
|
column = model.uuid_column()
|
|
|
|
self.assertIsInstance(column, sa.Column)
|
2024-07-13 23:25:20 -05:00
|
|
|
self.assertIsInstance(column.type, sa.String)
|
|
|
|
self.assertEqual(column.type.length, 32)
|
2024-07-11 12:55:55 -05:00
|
|
|
|
2024-07-13 23:25:20 -05:00
|
|
|
class TestUUIDFKColumn(TestCase):
|
|
|
|
|
|
|
|
def test_basic(self):
|
2024-07-14 14:45:52 -05:00
|
|
|
column = model.uuid_fk_column('foo.bar')
|
2024-07-13 23:25:20 -05:00
|
|
|
self.assertIsInstance(column, sa.Column)
|
|
|
|
self.assertIsInstance(column.type, sa.String)
|
|
|
|
self.assertEqual(column.type.length, 32)
|
2024-07-11 12:55:55 -05:00
|
|
|
|
|
|
|
class TestSetting(TestCase):
|
|
|
|
|
|
|
|
def test_basic(self):
|
|
|
|
setting = model.Setting()
|
|
|
|
self.assertEqual(str(setting), "")
|
|
|
|
setting.name = 'foo'
|
|
|
|
self.assertEqual(str(setting), "foo")
|
2024-07-14 15:47:39 -05:00
|
|
|
|
|
|
|
class TestPerson(TestCase):
|
|
|
|
|
|
|
|
def test_basic(self):
|
|
|
|
person = model.Person()
|
|
|
|
self.assertEqual(str(person), "")
|
|
|
|
person.full_name = "Barney Rubble"
|
|
|
|
self.assertEqual(str(person), "Barney Rubble")
|
|
|
|
|
|
|
|
def test_users(self):
|
|
|
|
person = model.Person()
|
|
|
|
self.assertIsNone(person.user)
|
|
|
|
|
|
|
|
user = User()
|
|
|
|
person.users.append(user)
|
|
|
|
self.assertIs(person.user, user)
|