island: Add FULL_USER_CREDENTIALS to test_environment.py

This commit is contained in:
Mike Salvatore 2021-05-05 07:21:46 -04:00
parent 9024a512b0
commit 7772ea6e4e
1 changed files with 6 additions and 5 deletions

View File

@ -20,7 +20,8 @@ PARTIAL_CREDENTIALS = None
STANDARD_WITH_CREDENTIALS = None STANDARD_WITH_CREDENTIALS = None
STANDARD_ENV = None STANDARD_ENV = None
EMPTY_CREDS = UserCreds("", "") EMPTY_USER_CREDENTIALS = UserCreds("", "")
FULL_USER_CREDENTIALS = UserCreds(username="test", password_hash="1231234")
# This fixture is a dirty hack that can be removed once these tests are converted from # This fixture is a dirty hack that can be removed once these tests are converted from
@ -69,7 +70,7 @@ def get_server_config_file_path_test_version():
class TestEnvironment(TestCase): class TestEnvironment(TestCase):
class EnvironmentCredentialsNotRequired(Environment): class EnvironmentCredentialsNotRequired(Environment):
def __init__(self): def __init__(self):
config = StubEnvironmentConfig("test", "test", EMPTY_CREDS) config = StubEnvironmentConfig("test", "test", EMPTY_USER_CREDENTIALS)
super().__init__(config) super().__init__(config)
_credentials_required = False _credentials_required = False
@ -79,7 +80,7 @@ class TestEnvironment(TestCase):
class EnvironmentCredentialsRequired(Environment): class EnvironmentCredentialsRequired(Environment):
def __init__(self): def __init__(self):
config = StubEnvironmentConfig("test", "test", EMPTY_CREDS) config = StubEnvironmentConfig("test", "test", EMPTY_USER_CREDENTIALS)
super().__init__(config) super().__init__(config)
_credentials_required = True _credentials_required = True
@ -100,7 +101,7 @@ class TestEnvironment(TestCase):
@patch.object(target=EnvironmentConfig, attribute="save_to_file", new=MagicMock()) @patch.object(target=EnvironmentConfig, attribute="save_to_file", new=MagicMock())
def test_try_add_user(self): def test_try_add_user(self):
env = TestEnvironment.EnvironmentCredentialsRequired() env = TestEnvironment.EnvironmentCredentialsRequired()
credentials = UserCreds(username="test", password_hash="1231234") credentials = FULL_USER_CREDENTIALS
env.try_add_user(credentials) env.try_add_user(credentials)
credentials = UserCreds(username="test", password_hash="") credentials = UserCreds(username="test", password_hash="")
@ -108,7 +109,7 @@ class TestEnvironment(TestCase):
env.try_add_user(credentials) env.try_add_user(credentials)
env = TestEnvironment.EnvironmentCredentialsNotRequired() env = TestEnvironment.EnvironmentCredentialsNotRequired()
credentials = UserCreds(username="test", password_hash="1231234") credentials = FULL_USER_CREDENTIALS
with self.assertRaises(RegistrationNotNeededError): with self.assertRaises(RegistrationNotNeededError):
env.try_add_user(credentials) env.try_add_user(credentials)