TireSwingSoftware/openassign-server — Issue #103: Tests fail when using "load_fixtures" decorator
Author: mhrivnak
Created: 2012-02-21 04:36:33+00:00
State: open

The decorator pr_services.testlib.helpers.load_fixtures does not seem to work properly when using a postgres backend. It does however work with sqlite.

It turns out that the "loaddata" management command uses its own transaction by default, which was conflicting with the test transaction. It has a non-advertised argument named "commit", which when False causes it to not do any transaction management. We should use that and set it to False.

Here is output from the four tests that use this decorator (using postgres):

```
======================================================================
ERROR: test_session_view (pr_services.pr_tests.TestAssignmentManagerViews)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/mhrivnak/git/openassign-server/pr_services/testlib/helpers.py", line 57, in wrapper
return func(*args, **kwargs)
File "/home/mhrivnak/git/openassign-server/pr_services/pr_tests.py", line 681, in test_session_view
session = Session.objects.get(id=1)
File "/home/mhrivnak/pythons/openassign/lib/python2.6/site-packages/django/db/models/manager.py", line 132, in get
return self.get_query_set().get(*args, **kwargs)
File "/home/mhrivnak/pythons/openassign/lib/python2.6/site-packages/django/db/models/query.py", line 349, in get
% self.model._meta.object_name)
DoesNotExist: Session matching query does not exist.

======================================================================
ERROR: test_create_from_task_bundle (pr_services.pr_tests.TestCurriculumManagement)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/mhrivnak/git/openassign-server/pr_services/testlib/helpers.py", line 57, in wrapper
return func(*args, **kwargs)
File "/home/mhrivnak/git/openassign-server/pr_services/pr_tests.py", line 3793, in test_create_from_task_bundle
curriculum = Curriculum.objects.get(id=1)
File "/home/mhrivnak/pythons/openassign/lib/python2.6/site-packages/django/db/models/manager.py", line 132, in get
return self.get_query_set().get(*args, **kwargs)
File "/home/mhrivnak/pythons/openassign/lib/python2.6/site-packages/django/db/models/query.py", line 349, in get
% self.model._meta.object_name)
DoesNotExist: Curriculum matching query does not exist.

======================================================================
ERROR: test_enroll_users (pr_services.pr_tests.TestCurriculumManagement)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/mhrivnak/git/openassign-server/pr_services/testlib/helpers.py", line 57, in wrapper
return func(*args, **kwargs)
File "/home/mhrivnak/git/openassign-server/pr_services/pr_tests.py", line 3816, in test_enroll_users
self.curriculum_task_association_manager.create(curriculum.id, exams[0].id)
File "/home/mhrivnak/pythons/openassign/lib/python2.6/site-packages/django/db/models/query.py", line 190, in __getitem__
return list(qs)[0]
IndexError: list index out of range

======================================================================
ERROR: test_from_instructor (pr_services.pr_tests.TestEmailTaskAssignees)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/mhrivnak/git/openassign-server/pr_services/testlib/helpers.py", line 57, in wrapper
return func(*args, **kwargs)
File "/home/mhrivnak/git/openassign-server/pr_services/pr_tests.py", line 543, in test_from_instructor
session = Session.objects.get(id=1)
File "/home/mhrivnak/pythons/openassign/lib/python2.6/site-packages/django/db/models/manager.py", line 132, in get
return self.get_query_set().get(*args, **kwargs)
File "/home/mhrivnak/pythons/openassign/lib/python2.6/site-packages/django/db/models/query.py", line 349, in get
% self.model._meta.object_name)
DoesNotExist: Session matching query does not exist.
```