-
-
Notifications
You must be signed in to change notification settings - Fork 801
/
Copy pathcommon_testing.py
33 lines (23 loc) · 1.13 KB
/
common_testing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from django.conf import settings
from django.test import TestCase as DjangoTestCase
from django.test import TransactionTestCase as DjangoTransactionTestCase
# The multiple database scenario setup for these tests purposefully defines 'default' as
# an empty database in order to catch any assumptions in this package about database names
# and in particular to ensure there is no assumption that 'default' is a valid database.
#
# When there are multiple databases defined, Django tests will not work unless they are
# told which database(s) to work with.
def retrieve_current_databases():
if len(settings.DATABASES) > 1:
return [name for name in settings.DATABASES if name != "default"]
else:
return ["default"]
class OAuth2ProviderBase:
@classmethod
def setUpClass(cls):
cls.databases = retrieve_current_databases()
super().setUpClass()
class OAuth2ProviderTestCase(OAuth2ProviderBase, DjangoTestCase):
"""Place holder to allow overriding behaviors."""
class OAuth2ProviderTransactionTestCase(OAuth2ProviderBase, DjangoTransactionTestCase):
"""Place holder to allow overriding behaviors."""