diff options
author | Frederick Muriuki Muriithi | 2023-01-03 05:49:53 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-01-03 06:16:28 +0300 |
commit | da33d719105d67afb1ee6b040380211cfa8be23d (patch) | |
tree | 825d77283b578c60058afba12fc786df4704d20e /tests/unit/auth/fixtures | |
parent | 27647b38fe1b183010d4c49bce5aa22ea2bb3f48 (diff) | |
download | genenetwork3-da33d719105d67afb1ee6b040380211cfa8be23d.tar.gz |
auth: rename fixtures: test_* -> fxtr_*
Since test functions are defined starting with "test_", rename the fixture to
more clearly indicate it is a fixture (fxtr_*), an not a test in itself.
Diffstat (limited to 'tests/unit/auth/fixtures')
-rw-r--r-- | tests/unit/auth/fixtures/group_fixtures.py | 16 | ||||
-rw-r--r-- | tests/unit/auth/fixtures/migration_fixtures.py | 8 | ||||
-rw-r--r-- | tests/unit/auth/fixtures/oauth2_client_fixtures.py | 6 | ||||
-rw-r--r-- | tests/unit/auth/fixtures/resource_fixtures.py | 4 | ||||
-rw-r--r-- | tests/unit/auth/fixtures/role_fixtures.py | 2 | ||||
-rw-r--r-- | tests/unit/auth/fixtures/user_fixtures.py | 6 |
6 files changed, 21 insertions, 21 deletions
diff --git a/tests/unit/auth/fixtures/group_fixtures.py b/tests/unit/auth/fixtures/group_fixtures.py index d17d5cb..72b96d1 100644 --- a/tests/unit/auth/fixtures/group_fixtures.py +++ b/tests/unit/auth/fixtures/group_fixtures.py @@ -46,7 +46,7 @@ TEST_RESOURCES = TEST_RESOURCES_GROUP_01 + TEST_RESOURCES_GROUP_02 TEST_RESOURCES_PUBLIC = (TEST_RESOURCES_GROUP_01[0], TEST_RESOURCES_GROUP_02[1]) @pytest.fixture(scope="function") -def test_group(conn_after_auth_migrations):# pylint: disable=[redefined-outer-name] +def fxtr_group(conn_after_auth_migrations):# pylint: disable=[redefined-outer-name] """Fixture: setup a test group.""" query = "INSERT INTO groups(group_id, group_name) VALUES (?, ?)" with db.cursor(conn_after_auth_migrations) as cursor: @@ -58,9 +58,9 @@ def test_group(conn_after_auth_migrations):# pylint: disable=[redefined-outer-na yield (conn_after_auth_migrations, TEST_GROUPS[0]) @pytest.fixture(scope="function") -def test_users_in_group(test_group, test_users):# pylint: disable=[redefined-outer-name, unused-argument] +def fxtr_users_in_group(fxtr_group, fxtr_users):# pylint: disable=[redefined-outer-name, unused-argument] """Link the users to the groups.""" - conn, all_users = test_users + conn, all_users = fxtr_users users = tuple( user for user in all_users if user.email not in ("unaff@iliated.user",)) query_params = tuple( @@ -78,7 +78,7 @@ def test_users_in_group(test_group, test_users):# pylint: disable=[redefined-out query_params) @pytest.fixture(scope="function") -def fixture_group_roles(test_group):# pylint: disable=[redefined-outer-name] +def fxtr_group_roles(fxtr_group):# pylint: disable=[redefined-outer-name] """Link roles to group""" from .role_fixtures import RESOURCE_EDITOR_ROLE, RESOURCE_READER_ROLE# pylint: disable=[import-outside-toplevel] group_roles = ( @@ -86,7 +86,7 @@ def fixture_group_roles(test_group):# pylint: disable=[redefined-outer-name] TEST_GROUP_01, RESOURCE_EDITOR_ROLE), GroupRole(uuid.UUID("82aed039-fe2f-408c-ab1e-81cd1ba96630"), TEST_GROUP_02, RESOURCE_READER_ROLE)) - conn, groups = test_group + conn, groups = fxtr_group with db.cursor(conn) as cursor: cursor.executemany( "INSERT INTO group_roles VALUES (?, ?, ?)", @@ -97,11 +97,11 @@ def fixture_group_roles(test_group):# pylint: disable=[redefined-outer-name] yield conn, groups, group_roles @pytest.fixture(scope="function") -def fixture_group_user_roles(test_users_in_group, fixture_group_roles, fixture_resources):#pylint: disable=[redefined-outer-name,unused-argument] +def fxtr_group_user_roles(fxtr_users_in_group, fxtr_group_roles, fxtr_resources):#pylint: disable=[redefined-outer-name,unused-argument] """Assign roles to users.""" from .role_fixtures import RESOURCE_EDITOR_ROLE # pylint: disable=[import-outside-toplevel] - conn, _groups, _group_roles = fixture_group_roles - _conn, _group, group_users = test_users_in_group + conn, _groups, _group_roles = fxtr_group_roles + _conn, _group, group_users = fxtr_users_in_group users = tuple(user for user in group_users if user.email not in ("unaff@iliated.user", "group@lead.er")) users_roles_resources = ( diff --git a/tests/unit/auth/fixtures/migration_fixtures.py b/tests/unit/auth/fixtures/migration_fixtures.py index 3e511b1..eb42c2b 100644 --- a/tests/unit/auth/fixtures/migration_fixtures.py +++ b/tests/unit/auth/fixtures/migration_fixtures.py @@ -8,14 +8,14 @@ from gn3.auth import db from gn3.migrations import apply_migrations, rollback_migrations @pytest.fixture(scope="session") -def auth_testdb_path(test_app_config): # pylint: disable=redefined-outer-name +def auth_testdb_path(fxtr_app_config): # pylint: disable=redefined-outer-name """Get the test application's auth database file""" - return test_app_config["AUTH_DB"] + return fxtr_app_config["AUTH_DB"] @pytest.fixture(scope="session") -def auth_migrations_dir(test_app_config): # pylint: disable=redefined-outer-name +def auth_migrations_dir(fxtr_app_config): # pylint: disable=redefined-outer-name """Get the test application's auth database file""" - return test_app_config["AUTH_MIGRATIONS"] + return fxtr_app_config["AUTH_MIGRATIONS"] def apply_single_migration(backend: DatabaseBackend, migration: Migration):# pylint: disable=[redefined-outer-name] """Utility to apply a single migration""" diff --git a/tests/unit/auth/fixtures/oauth2_client_fixtures.py b/tests/unit/auth/fixtures/oauth2_client_fixtures.py index 03a53d7..5f11e92 100644 --- a/tests/unit/auth/fixtures/oauth2_client_fixtures.py +++ b/tests/unit/auth/fixtures/oauth2_client_fixtures.py @@ -9,13 +9,13 @@ from gn3.auth import db from gn3.auth.authentication.oauth2.models.oauth2client import OAuth2Client @pytest.fixture(autouse=True) -def fixture_patch_envvars(monkeypatch): +def fxtr_patch_envvars(monkeypatch): monkeypatch.setenv("AUTHLIB_INSECURE_TRANSPORT", "true") @pytest.fixture -def fixture_oauth2_clients(fixture_users_with_passwords): +def fxtr_oauth2_clients(fxtr_users_with_passwords): """Fixture: Create the OAuth2 clients for use with tests.""" - conn, users = fixture_users_with_passwords + conn, users = fxtr_users_with_passwords now = datetime.datetime.now() clients = tuple( diff --git a/tests/unit/auth/fixtures/resource_fixtures.py b/tests/unit/auth/fixtures/resource_fixtures.py index 9287936..12d8bce 100644 --- a/tests/unit/auth/fixtures/resource_fixtures.py +++ b/tests/unit/auth/fixtures/resource_fixtures.py @@ -6,9 +6,9 @@ from gn3.auth import db from .group_fixtures import TEST_RESOURCES @pytest.fixture(scope="function") -def fixture_resources(test_group):# pylint: disable=[redefined-outer-name] +def fxtr_resources(fxtr_group):# pylint: disable=[redefined-outer-name] """fixture: setup test resources in the database""" - conn, _group = test_group + conn, _group = fxtr_group with db.cursor(conn) as cursor: cursor.executemany( "INSERT INTO resources VALUES (?,?,?,?,?)", diff --git a/tests/unit/auth/fixtures/role_fixtures.py b/tests/unit/auth/fixtures/role_fixtures.py index befa6b0..e1e1680 100644 --- a/tests/unit/auth/fixtures/role_fixtures.py +++ b/tests/unit/auth/fixtures/role_fixtures.py @@ -22,7 +22,7 @@ RESOURCE_EDITOR_ROLE = Role( TEST_ROLES = (RESOURCE_READER_ROLE, RESOURCE_EDITOR_ROLE) @pytest.fixture(scope="function") -def fixture_roles(conn_after_auth_migrations): +def fxtr_roles(conn_after_auth_migrations): """Setup some example roles.""" with db.cursor(conn_after_auth_migrations) as cursor: cursor.executemany( diff --git a/tests/unit/auth/fixtures/user_fixtures.py b/tests/unit/auth/fixtures/user_fixtures.py index 843d575..89b7e62 100644 --- a/tests/unit/auth/fixtures/user_fixtures.py +++ b/tests/unit/auth/fixtures/user_fixtures.py @@ -18,7 +18,7 @@ TEST_USERS = ( "unaff@iliated.user", "Unaffiliated User")) @pytest.fixture(scope="function") -def test_users(conn_after_auth_migrations):# pylint: disable=[redefined-outer-name] +def fxtr_users(conn_after_auth_migrations):# pylint: disable=[redefined-outer-name] """Fixture: setup test users.""" query = "INSERT INTO users(user_id, email, name) VALUES (?, ?, ?)" query_user_roles = "INSERT INTO user_roles(user_id, role_id) VALUES (?, ?)" @@ -44,9 +44,9 @@ def test_users(conn_after_auth_migrations):# pylint: disable=[redefined-outer-na ("9a0c7ce5-2f40-4e78-979e-bf3527a59579",))) @pytest.fixture(scope="function") -def fixture_users_with_passwords(test_users): # pylint: disable=[redefined-outer-name] +def fxtr_users_with_passwords(fxtr_users): # pylint: disable=[redefined-outer-name] """Fixture: add passwords to the users""" - conn, users = test_users + conn, users = fxtr_users user_passwords_params = tuple( (str(user.user_id), bcrypt.hashpw( f"password_for_user_{idx:03}".encode("utf8"), |