work in progress: autommatic tests for SQL-based storage implementation
This commit is contained in:
parent
781521ca88
commit
506e539c2d
6 changed files with 84 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
from cco.storage.common import registerContainerClass
|
||||
from cco.storage.tracking import record
|
||||
from loops.organize.tracking.storage import compat
|
||||
|
||||
|
||||
class Favorite(record.Track):
|
||||
|
@ -12,7 +13,7 @@ class Favorite(record.Track):
|
|||
|
||||
|
||||
@registerContainerClass
|
||||
class Favorites(record.Container):
|
||||
class Favorites(compat.Container):
|
||||
|
||||
itemFactory = Favorite
|
||||
tableName = 'favorites'
|
||||
|
|
14
organize/tracking/storage/compat.py
Normal file
14
organize/tracking/storage/compat.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
# loops.organize.tracking.storage.compat
|
||||
|
||||
"""loops compatibility layer on cco.storage.tracking.
|
||||
|
||||
Provides a Container subclass that defines methods from cybertools...TrackingStorage
|
||||
used by code based on loops.organize.tracking.
|
||||
"""
|
||||
|
||||
from cco.storage.tracking import record
|
||||
|
||||
|
||||
class Container(record.Container):
|
||||
|
||||
pass
|
4
storage/__init__.py
Normal file
4
storage/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
# loops.storage
|
||||
|
||||
"""Common stuff for new SQL-based storage implementation.
|
||||
"""
|
4
storage/tests/__init__.py
Normal file
4
storage/tests/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
# loops.storage.tests
|
||||
|
||||
"""Testing stuff for new SQL-based storage implementation.
|
||||
"""
|
33
storage/tests/common.py
Normal file
33
storage/tests/common.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
# loops.storage.test.common
|
||||
|
||||
"""Common definitions for testing the SQL-based storage implementation.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from zope import component, interface
|
||||
from zope.app.testing.setup import placefulSetUp, placefulTearDown
|
||||
|
||||
from loops.expert.testsetup import TestSite
|
||||
from loops.organize.setup import SetupManager
|
||||
from loops.organize.tests import setupUtilitiesAndAdapters
|
||||
from loops import util
|
||||
|
||||
|
||||
|
||||
class TestCase(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def prepare(cls):
|
||||
cls.site = site = placefulSetUp(True)
|
||||
component.provideAdapter(SetupManager, name='organize')
|
||||
t = TestSite(site)
|
||||
cls.concepts, cls.resources, cls.views = t.setup()
|
||||
cls.loopsRoot = loopsRoot = site['loops']
|
||||
loopsId = util.getUidForObject(loopsRoot)
|
||||
setupData = setupUtilitiesAndAdapters(loopsRoot)
|
||||
|
||||
@classmethod
|
||||
def cleanup(cls):
|
||||
placefulTearDown()
|
||||
|
||||
|
27
storage/tests/test_storage.py
Normal file
27
storage/tests/test_storage.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
# loops.storage.tests.test_storage
|
||||
|
||||
"""Comprehensive functional testing for SQL-based storage implementation.
|
||||
"""
|
||||
|
||||
from loops.storage.tests import common
|
||||
|
||||
|
||||
class TestStorage(common.TestCase):
|
||||
|
||||
def test_000_setUp(self):
|
||||
self.prepare()
|
||||
self.assertEqual(self.loopsRoot.__name__, 'loops')
|
||||
|
||||
def test_migration(self):
|
||||
self.assertEqual('a'.upper(), 'A')
|
||||
|
||||
def test_query(self):
|
||||
self.assertEqual('a'.upper(), 'A')
|
||||
|
||||
def test_zzz_tearDown(self):
|
||||
self.cleanup()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Add table
Reference in a new issue