1
# Copyright 2008-2015 Canonical
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU Affero General Public License as
5
# published by the Free Software Foundation, either version 3 of the
6
# License, or (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU Affero General Public License for more details.
13
# You should have received a copy of the GNU Affero General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
# For further info, check http://launchpad.net/filesync-server
18
"""TestCases for testing with backends."""
20
from django.test import TestCase, utils
21
from django.test.client import RequestFactory
22
from testresources import ResourcedTestCase
24
from backends.testing.resources import get_all_db_resources
27
class BaseTestCase(TestCase):
28
"""Base TestCase: provides a Factory, RequestFactory and a mock SSO."""
30
request_factory = RequestFactory()
33
super(BaseTestCase, self).setUp()
35
# django's pre_setup, currently not being called because trial test
36
# runner will not __call__ every test case -- assign client manually
37
self.client = self.client_class()
39
# the following is usually called from the DjangoTestSuiteRunner
40
# (django/test/simple.py) -- since we use trial, need to call by hand
41
utils.setup_test_environment()
42
self.addCleanup(utils.teardown_test_environment)
45
class DatabaseResourceTestCase(BaseTestCase, ResourcedTestCase):
46
"""Base TestCase for Tests that use the database."""
48
resources = get_all_db_resources()