Add more super user registry status tests
This commit is contained in:
parent
9533dc2981
commit
da7413a92e
1 changed files with 31 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
import unittest
|
||||
import mock
|
||||
|
||||
from data.database import User
|
||||
from data import model
|
||||
|
@ -28,11 +29,40 @@ class FreshConfigProvider(object):
|
|||
|
||||
|
||||
class TestSuperUserRegistryStatus(ApiTestCase):
|
||||
def test_registry_status(self):
|
||||
def test_registry_status_no_config(self):
|
||||
with FreshConfigProvider():
|
||||
json = self.getJsonResponse(SuperUserRegistryStatus)
|
||||
self.assertEquals('config-db', json['status'])
|
||||
|
||||
@mock.patch("config_app.config_endpoints.api.suconfig.database_is_valid", mock.Mock(return_value=False))
|
||||
def test_registry_status_no_database(self):
|
||||
with FreshConfigProvider():
|
||||
config_provider.save_config({'key': 'value'})
|
||||
json = self.getJsonResponse(SuperUserRegistryStatus)
|
||||
self.assertEquals('setup-db', json['status'])
|
||||
|
||||
@mock.patch("config_app.config_endpoints.api.suconfig.database_is_valid", mock.Mock(return_value=True))
|
||||
def test_registry_status_db_has_superuser(self):
|
||||
with FreshConfigProvider():
|
||||
config_provider.save_config({'key': 'value'})
|
||||
json = self.getJsonResponse(SuperUserRegistryStatus)
|
||||
self.assertEquals('config', json['status'])
|
||||
|
||||
@mock.patch("config_app.config_endpoints.api.suconfig.database_is_valid", mock.Mock(return_value=True))
|
||||
@mock.patch("config_app.config_endpoints.api.suconfig.database_has_users", mock.Mock(return_value=False))
|
||||
def test_registry_status_db_no_superuser(self):
|
||||
with FreshConfigProvider():
|
||||
config_provider.save_config({'key': 'value'})
|
||||
json = self.getJsonResponse(SuperUserRegistryStatus)
|
||||
self.assertEquals('create-superuser', json['status'])
|
||||
|
||||
@mock.patch("config_app.config_endpoints.api.suconfig.database_is_valid", mock.Mock(return_value=True))
|
||||
@mock.patch("config_app.config_endpoints.api.suconfig.database_has_users", mock.Mock(return_value=True))
|
||||
def test_registry_status_setup_complete(self):
|
||||
with FreshConfigProvider():
|
||||
config_provider.save_config({'key': 'value', 'SETUP_COMPLETE': True})
|
||||
json = self.getJsonResponse(SuperUserRegistryStatus)
|
||||
self.assertEquals('config', json['status'])
|
||||
|
||||
class TestSuperUserConfigFile(ApiTestCase):
|
||||
def test_get_superuser_invalid_filename(self):
|
||||
|
|
Reference in a new issue