Although the tests pass when run as part of the full openstack_dashboard test suite, the quota tests behave differently when run as a subset and fail.
$ ./run_tests.sh openstack_dashboard.test.tests.quotas
...
======================================================================
ERROR: test_tenant_quota_usages_no_instances_running (openstack_dashboard.test.tests.quotas.QuotaTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jpichon/devel/horizon/openstack_dashboard/test/helpers.py", line 77, in instance_stub_out
return fn(self)
File "/home/jpichon/devel/horizon/openstack_dashboard/test/tests/quotas.py", line 136, in test_tenant_quota_usages_no_instances_running
quota_usages = quotas.tenant_quota_usages(self.request)
File "/home/jpichon/devel/horizon/horizon/utils/memoized.py", line 33, in __call__
value = self.func(*args)
File "/home/jpichon/devel/horizon/openstack_dashboard/usage/quotas.py", line 120, in tenant_quota_usages
disabled_quotas=disabled_quotas):
File "/home/jpichon/devel/horizon/openstack_dashboard/usage/quotas.py", line 103, in get_tenant_quota_data
tenant_id=tenant_id)
File "/home/jpichon/devel/horizon/openstack_dashboard/usage/quotas.py", line 79, in _get_quota_data
tenant_id = request.user.tenant_id
File "/home/jpichon/devel/horizon/.venv/lib/python2.7/site-packages/django/utils/functional.py", line 203, in inner
return func(self._wrapped, *args)
AttributeError: 'AnonymousUser' object has no attribute 'tenant_id'
...
It happens for other api_tests as well (e.g. swift_tests, lbaas_tests), different errors relating to the AnonymousUser being returned.
It looks like when running this subset of the tests, openstack_auth.urls doesn't get loaded, therefore the middleware get_user monkey patching doesn't happen and we call directly to django. contrib. auth.middleware later on.
While waiting for bug 1207840 to be resolved, we could force the monkey patching to happen in the helpers.TestCase's setUp() method.