In an attempt to package horus, I stumbled upon the test suite failing on many tests, which boils down to a missing database initialization:
================================================= test session starts ==================================================
platform linux2 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1
rootdir: /home/hp/src/obs/home:frispete:python/python-horus/horus-0.9.15, inifile: pytest.ini
plugins: cov-2.2.0
collected 73 items
horus/tests/test_init.py FF.
horus/tests/test_integration.py ...F..F
horus/tests/test_interfaces.py ..
horus/tests/test_models.py ...FFFFFFFFFFFFFFFFFF.
horus/tests/test_resources.py F
horus/tests/test_schemas.py ..
horus/tests/test_views.py ..FF...F.FFFF..FF.F...F..FFFFFFFFFFF
======================================================= FAILURES =======================================================
____________________________________________ TestInitCase.test_group_finder ____________________________________________
self = <horus.tests.test_init.TestInitCase testMethod=test_group_finder>
def test_group_finder(self):
from horus import groupfinder
from horus.tests.models import User
from horus.tests.models import Group
group = Group(name='foo', description='bar')
user1 = User(username='sontek', email='[email protected]')
user1.password = 'foo'
group.users.append(user1)
self.session.add(group)
self.session.add(user1)
> self.session.flush()
horus/tests/test_init.py:65:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py:2004: in flush
self._flush(objects)
/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py:2122: in _flush
transaction.rollback(_capture_exception=True)
/usr/lib64/python2.7/site-packages/sqlalchemy/util/langhelpers.py:60: in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py:2086: in _flush
flush_context.execute()
/usr/lib64/python2.7/site-packages/sqlalchemy/orm/unitofwork.py:373: in execute
rec.execute(self)
/usr/lib64/python2.7/site-packages/sqlalchemy/orm/unitofwork.py:532: in execute
uow
/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py:174: in save_obj
mapper, table, insert)
/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py:781: in _emit_insert_statements
execute(statement, params)
/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py:914: in execute
return meth(self, multiparams, params)
/usr/lib64/python2.7/site-packages/sqlalchemy/sql/elements.py:323: in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py:1010: in _execute_clauseelement
compiled_sql, distilled_params
/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py:1146: in _execute_context
context)
/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py:1341: in _handle_dbapi_exception
exc_info
/usr/lib64/python2.7/site-packages/sqlalchemy/util/compat.py:199: in raise_from_cause
reraise(type(exception), exception, tb=exc_tb)
/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py:1139: in _execute_context
context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x7f354db2fd10>
cursor = <sqlite3.Cursor object at 0x7f354db08d50>, statement = 'INSERT INTO "group" (description, name) VALUES (?, ?)'
parameters = ('bar', 'foo'), context = <sqlalchemy.dialects.sqlite.base.SQLiteExecutionContext object at 0x7f354dc90150>
def do_execute(self, cursor, statement, parameters, context=None):
> cursor.execute(statement, parameters)
E OperationalError: (sqlite3.OperationalError) no such table: group [SQL: u'INSERT INTO "group" (description, name) VALUES (?, ?)'] [parameters: (u'bar', u'foo')]
/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py:450: OperationalError
and so on. Applying the patch below fixes this for me.
--- horus-0.9.15/horus/tests/__init__.py~ 2014-01-19 03:48:10.000000000 +0100
+++ horus-0.9.15/horus/tests/__init__.py 2016-01-07 16:33:59.505228572 +0100
@@ -35,6 +35,7 @@ class BaseTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.engine = engine_from_config(settings, prefix='sqlalchemy.')
+ Base.metadata.create_all(cls.engine)
cls.Session = sessionmaker()
def setUp(self):