feat: add basic data model support
wuttjamaican will provide a default data model with minimal tables; it's assumed each custom app will extend this model with other tables
This commit is contained in:
parent
7012409e1e
commit
375d0be638
19 changed files with 388 additions and 13 deletions
0
tests/db/model/__init__.py
Normal file
0
tests/db/model/__init__.py
Normal file
25
tests/db/model/test_base.py
Normal file
25
tests/db/model/test_base.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
try:
|
||||
import sqlalchemy as sa
|
||||
from wuttjamaican.db.model import base as model
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
|
||||
class TestUUIDColumn(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
column = model.uuid_column()
|
||||
self.assertIsInstance(column, sa.Column)
|
||||
|
||||
|
||||
class TestSetting(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
setting = model.Setting()
|
||||
self.assertEqual(str(setting), "")
|
||||
setting.name = 'foo'
|
||||
self.assertEqual(str(setting), "foo")
|
|
@ -88,6 +88,30 @@ class TestAppHandler(TestCase):
|
|||
value = self.app.get_setting(session, 'foo')
|
||||
self.assertEqual(value, 'bar')
|
||||
|
||||
def test_model(self):
|
||||
try:
|
||||
from wuttjamaican.db import model
|
||||
except ImportError:
|
||||
pytest.skip("test not relevant without sqlalchemy")
|
||||
else:
|
||||
self.assertNotIn('model', self.app.__dict__)
|
||||
self.assertIs(self.app.model, model)
|
||||
|
||||
def test_get_model(self):
|
||||
try:
|
||||
from wuttjamaican.db import model
|
||||
except ImportError:
|
||||
pytest.skip("test not relevant without sqlalchemy")
|
||||
else:
|
||||
self.assertIs(self.app.get_model(), model)
|
||||
|
||||
def test_get_title(self):
|
||||
self.assertEqual(self.app.get_title(), 'WuttJamaican')
|
||||
|
||||
def test_make_uuid(self):
|
||||
uuid = self.app.make_uuid()
|
||||
self.assertEqual(len(uuid), 32)
|
||||
|
||||
|
||||
class TestAppProvider(TestCase):
|
||||
|
||||
|
|
|
@ -4,10 +4,6 @@ import sys
|
|||
from unittest import TestCase
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
# nb. setuptools must be imported before distutils, else weird
|
||||
# behavior may ensue within some of the tests below
|
||||
import setuptools
|
||||
|
||||
import pytest
|
||||
|
||||
from wuttjamaican import util
|
||||
|
@ -134,6 +130,13 @@ class TestLoadObject(TestCase):
|
|||
self.assertIs(result, TestCase)
|
||||
|
||||
|
||||
class TestMakeUUID(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
uuid = util.make_uuid()
|
||||
self.assertEqual(len(uuid), 32)
|
||||
|
||||
|
||||
class TestParseBool(TestCase):
|
||||
|
||||
def test_null(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue