okfn/ckan — pull request #1112 by seanh (2013-07-16 11:00:52+00:00)
Title: Start adding example new logic tests

`ckan.model.repo.rebuild_db()` is freezing for me when I run these tests.

The command I'm running is:

nosetests --ckan --with-pylons=test-custom.ini --nologcapture --nocapture ckan/new_tests

(I have a `test-custom.ini` file that wraps `test-core.ini`, all it does is set the solr url).

The first time I run the command I get the exception below. After that, running the tests will get as far as printing `Rebuilding db` but never print `db rebuilt`

If I drop and recreate the test db, then I can run the tests and get the exception again:

sudo -u postgres dropdb ckan_test; sudo -u postgres createdb -O ckan_default ckan_test -E utf-8;

Exception:

```
Traceback (most recent call last):
File "/home/seanh/.virtualenvs/ckan/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/seanh/Projects/ckan/ckan/ckan/new_tests/logic/action/test_update.py", line 33, in test_user_update
user = logic.call_action('user_create', **test_data.FRED)
File "/home/seanh/Projects/ckan/ckan/ckan/new_tests/logic/__init__.py", line 27, in call_action
return logic.get_action(action_name)(context=context, data_dict=kwargs)
File "/home/seanh/Projects/ckan/ckan/ckan/logic/__init__.py", line 329, in wrapped
return _action(context, data_dict, **kw)
File "/home/seanh/Projects/ckan/ckan/ckan/logic/action/create.py", line 785, in user_create
data, errors = _validate(data_dict, schema, context)
File "/home/seanh/Projects/ckan/ckan/ckan/lib/navl/dictization_functions.py", line 229, in validate
converted_data, errors = _validate(flattened, schema, context)
File "/home/seanh/Projects/ckan/ckan/ckan/lib/navl/dictization_functions.py", line 290, in _validate
convert(converter, key, converted_data, errors, context)
File "/home/seanh/Projects/ckan/ckan/ckan/lib/navl/dictization_functions.py", line 187, in convert
converter(key, converted_data, errors, context)
File "/home/seanh/Projects/ckan/ckan/ckan/logic/validators.py", line 488, in user_name_validator
result = query.first()
File "/home/seanh/.virtualenvs/ckan/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2156, in first
ret = list(self[0:1])
File "/home/seanh/.virtualenvs/ckan/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2023, in __getitem__
return list(res)
File "/home/seanh/.virtualenvs/ckan/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2227, in __iter__
return self._execute_and_instances(context)
File "/home/seanh/.virtualenvs/ckan/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2242, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "/home/seanh/.virtualenvs/ckan/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1449, in execute
params)
File "/home/seanh/.virtualenvs/ckan/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1584, in _execute_clauseelement
compiled_sql, distilled_params
File "/home/seanh/.virtualenvs/ckan/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1698, in _execute_context
context)
File "/home/seanh/.virtualenvs/ckan/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1691, in _execute_context
context)
File "/home/seanh/.virtualenvs/ckan/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 331, in do_execute
cursor.execute(statement, parameters)
InternalError: (InternalError) current transaction is aborted, commands ignored until end of transaction block
'SELECT "user".name AS user_name \nFROM "user" \nWHERE "user".name = %(name_1)s \n LIMIT %(param_1)s' {'name_1': 'fred', 'param_1': 1}
```