test: move ConfigForTesting
This commit is contained in:
parent
1d59095460
commit
dd033e4feb
2 changed files with 12 additions and 12 deletions
|
@ -117,6 +117,16 @@ FAKE_APPLICATION_CLIENT_ID = 'deadbeef'
|
||||||
CSRF_TOKEN_KEY = '_csrf_token'
|
CSRF_TOKEN_KEY = '_csrf_token'
|
||||||
CSRF_TOKEN = '123csrfforme'
|
CSRF_TOKEN = '123csrfforme'
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigForTesting(object):
|
||||||
|
def __enter__(self):
|
||||||
|
config_provider.reset_for_test()
|
||||||
|
return config_provider
|
||||||
|
|
||||||
|
def __exit__(self, type, value, traceback):
|
||||||
|
config_provider.reset_for_test()
|
||||||
|
|
||||||
|
|
||||||
class ApiTestCase(unittest.TestCase):
|
class ApiTestCase(unittest.TestCase):
|
||||||
maxDiff = None
|
maxDiff = None
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from test.test_api_usage import ApiTestCase, READ_ACCESS_USER, ADMIN_ACCESS_USER
|
from test.test_api_usage import ApiTestCase, READ_ACCESS_USER, ADMIN_ACCESS_USER, ConfigForTesting
|
||||||
from endpoints.api.suconfig import (SuperUserRegistryStatus, SuperUserConfig, SuperUserConfigFile,
|
from endpoints.api.suconfig import (SuperUserRegistryStatus, SuperUserConfig, SuperUserConfigFile,
|
||||||
SuperUserCreateInitialSuperUser, SuperUserConfigValidate)
|
SuperUserCreateInitialSuperUser, SuperUserConfigValidate)
|
||||||
from app import config_provider, all_queues
|
from app import config_provider, all_queues
|
||||||
|
@ -8,16 +8,6 @@ from data import model
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
class ConfigForTesting(object):
|
|
||||||
|
|
||||||
def __enter__(self):
|
|
||||||
config_provider.reset_for_test()
|
|
||||||
return config_provider
|
|
||||||
|
|
||||||
def __exit__(self, type, value, traceback):
|
|
||||||
config_provider.reset_for_test()
|
|
||||||
|
|
||||||
|
|
||||||
class TestSuperUserRegistryStatus(ApiTestCase):
|
class TestSuperUserRegistryStatus(ApiTestCase):
|
||||||
def test_registry_status(self):
|
def test_registry_status(self):
|
||||||
with ConfigForTesting():
|
with ConfigForTesting():
|
||||||
|
|
Reference in a new issue