From 8d849ee2a12280234599787e22eaea982fc84685 Mon Sep 17 00:00:00 2001 From: corubba Date: Fri, 24 Jun 2022 14:19:52 +0200 Subject: [PATCH] Cleanup The `unit/apikey` directory is removed because it does not contain any tests. Same for `unit/test_decorators.py`. The `fixture` module is renamed to the special-name `conftest` [0] so they are available in all tests without the need to import them. With that in place, I removed all now unneeded or previously already unused imports from the tests. Also removed that wierd `sys.path` bit from `unit/zone/test_admin_apikey.py`, no idea what that was originally intended for. [0] https://docs.pytest.org/en/6.2.x/fixture.html#conftest-py-sharing-fixtures-across-multiple-files --- tests/{fixtures.py => conftest.py} | 0 tests/integration/api/apikey/test_admin_user.py | 3 +-- tests/integration/api/apikey/test_user.py | 3 --- tests/integration/api/management/test_admin_user.py | 6 +----- tests/integration/api/management/test_user.py | 4 ---- tests/integration/api/zone/test_admin_user.py | 3 --- tests/integration/api/zone/test_apikey_admin_user.py | 3 --- tests/integration/api/zone/test_apikey_user.py | 3 --- tests/integration/api/zone/test_user.py | 2 -- tests/unit/apikey/__init__.py | 0 tests/unit/test_decorators.py | 0 tests/unit/zone/test_admin_apikey.py | 9 ++------- tests/unit/zone/test_admin_user.py | 4 +--- tests/unit/zone/test_user.py | 4 +--- tests/unit/zone/test_user_apikey.py | 7 ++----- 15 files changed, 8 insertions(+), 43 deletions(-) rename tests/{fixtures.py => conftest.py} (100%) delete mode 100644 tests/unit/apikey/__init__.py delete mode 100644 tests/unit/test_decorators.py diff --git a/tests/fixtures.py b/tests/conftest.py similarity index 100% rename from tests/fixtures.py rename to tests/conftest.py diff --git a/tests/integration/api/apikey/test_admin_user.py b/tests/integration/api/apikey/test_admin_user.py index c367fe1..04e9806 100644 --- a/tests/integration/api/apikey/test_admin_user.py +++ b/tests/integration/api/apikey/test_admin_user.py @@ -4,8 +4,7 @@ from collections import namedtuple from powerdnsadmin.lib.validators import validate_apikey from powerdnsadmin.lib.schema import ApiKeySchema -from tests.fixtures import client, initial_data, basic_auth_admin_headers -from tests.fixtures import user_apikey_data, admin_apikey_data, zone_data +from tests.conftest import user_apikey_data, admin_apikey_data class TestIntegrationApiApiKeyAdminUser(object): diff --git a/tests/integration/api/apikey/test_user.py b/tests/integration/api/apikey/test_user.py index 17fc970..1d0751d 100644 --- a/tests/integration/api/apikey/test_user.py +++ b/tests/integration/api/apikey/test_user.py @@ -1,11 +1,8 @@ -import pytest import json from collections import namedtuple from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.schema import DomainSchema -from tests.fixtures import client, initial_data, basic_auth_user_headers -from tests.fixtures import zone_data class TestIntegrationApiZoneUser(object): diff --git a/tests/integration/api/management/test_admin_user.py b/tests/integration/api/management/test_admin_user.py index eae61f8..b017320 100644 --- a/tests/integration/api/management/test_admin_user.py +++ b/tests/integration/api/management/test_admin_user.py @@ -1,9 +1,5 @@ - import json -from tests.fixtures import ( # noqa: F401 - client, initial_data, basic_auth_admin_headers, - test_admin_user, test_user, account_data, user1_data, -) + from . import IntegrationApiManagement diff --git a/tests/integration/api/management/test_user.py b/tests/integration/api/management/test_user.py index 31bf69f..548702a 100644 --- a/tests/integration/api/management/test_user.py +++ b/tests/integration/api/management/test_user.py @@ -1,10 +1,6 @@ import json -from tests.fixtures import ( # noqa: F401 - client, initial_data, basic_auth_admin_headers, basic_auth_user_headers, - test_admin_user, test_user, account_data, user1_data, -) from . import IntegrationApiManagement diff --git a/tests/integration/api/zone/test_admin_user.py b/tests/integration/api/zone/test_admin_user.py index 2aa9c44..f1c12a7 100644 --- a/tests/integration/api/zone/test_admin_user.py +++ b/tests/integration/api/zone/test_admin_user.py @@ -1,11 +1,8 @@ -import pytest import json from collections import namedtuple from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.schema import DomainSchema -from tests.fixtures import client, initial_data, basic_auth_admin_headers -from tests.fixtures import zone_data class TestIntegrationApiZoneAdminUser(object): diff --git a/tests/integration/api/zone/test_apikey_admin_user.py b/tests/integration/api/zone/test_apikey_admin_user.py index 9090ed6..494366f 100644 --- a/tests/integration/api/zone/test_apikey_admin_user.py +++ b/tests/integration/api/zone/test_apikey_admin_user.py @@ -3,9 +3,6 @@ from collections import namedtuple from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.schema import DomainSchema -from tests.fixtures import client -from tests.fixtures import zone_data, initial_apikey_data -from tests.fixtures import admin_apikey_integration class TestIntegrationApiZoneAdminApiKey(object): diff --git a/tests/integration/api/zone/test_apikey_user.py b/tests/integration/api/zone/test_apikey_user.py index b0c96bc..94ddac1 100644 --- a/tests/integration/api/zone/test_apikey_user.py +++ b/tests/integration/api/zone/test_apikey_user.py @@ -3,9 +3,6 @@ from collections import namedtuple from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.schema import DomainSchema -from tests.fixtures import client -from tests.fixtures import zone_data, initial_apikey_data -from tests.fixtures import user_apikey_integration class TestIntegrationApiZoneUserApiKey(object): diff --git a/tests/integration/api/zone/test_user.py b/tests/integration/api/zone/test_user.py index 7392521..1d0751d 100644 --- a/tests/integration/api/zone/test_user.py +++ b/tests/integration/api/zone/test_user.py @@ -3,8 +3,6 @@ from collections import namedtuple from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.schema import DomainSchema -from tests.fixtures import client, initial_data, basic_auth_user_headers -from tests.fixtures import zone_data class TestIntegrationApiZoneUser(object): diff --git a/tests/unit/apikey/__init__.py b/tests/unit/apikey/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/unit/test_decorators.py b/tests/unit/test_decorators.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/unit/zone/test_admin_apikey.py b/tests/unit/zone/test_admin_apikey.py index fed2561..9d1ca28 100644 --- a/tests/unit/zone/test_admin_apikey.py +++ b/tests/unit/zone/test_admin_apikey.py @@ -2,9 +2,6 @@ import json import pytest from unittest.mock import patch from collections import namedtuple -import sys -import os -sys.path.append(os.getcwd()) import powerdnsadmin from powerdnsadmin.models.setting import Setting @@ -12,10 +9,8 @@ from powerdnsadmin.models.domain import Domain from powerdnsadmin.models.api_key import ApiKey from powerdnsadmin.models.role import Role from powerdnsadmin.lib.validators import validate_zone -from powerdnsadmin.lib.schema import DomainSchema, ApiKeySchema -from tests.fixtures import client, initial_data, created_zone_data -from tests.fixtures import user_apikey, admin_apikey, zone_data -from tests.fixtures import admin_apikey_data, load_data +from powerdnsadmin.lib.schema import DomainSchema +from tests.conftest import admin_apikey_data, load_data class TestUnitApiZoneAdminApiKey(object): diff --git a/tests/unit/zone/test_admin_user.py b/tests/unit/zone/test_admin_user.py index 7212045..922aa64 100644 --- a/tests/unit/zone/test_admin_user.py +++ b/tests/unit/zone/test_admin_user.py @@ -5,12 +5,10 @@ from collections import namedtuple import powerdnsadmin from powerdnsadmin.models.user import User -from powerdnsadmin.models.role import Role from powerdnsadmin.models.domain import Domain from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.schema import DomainSchema -from tests.fixtures import client, basic_auth_admin_headers -from tests.fixtures import zone_data, created_zone_data, load_data +from tests.conftest import load_data class TestUnitApiZoneAdminUser(object): diff --git a/tests/unit/zone/test_user.py b/tests/unit/zone/test_user.py index b15e944..3d37492 100644 --- a/tests/unit/zone/test_user.py +++ b/tests/unit/zone/test_user.py @@ -5,12 +5,10 @@ from collections import namedtuple import powerdnsadmin from powerdnsadmin.models.user import User -from powerdnsadmin.models.role import Role from powerdnsadmin.models.domain import Domain from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.schema import DomainSchema -from tests.fixtures import client, basic_auth_user_headers -from tests.fixtures import zone_data, created_zone_data, load_data +from tests.conftest import load_data class TestUnitApiZoneUser(object): diff --git a/tests/unit/zone/test_user_apikey.py b/tests/unit/zone/test_user_apikey.py index e8bd915..77b1018 100644 --- a/tests/unit/zone/test_user_apikey.py +++ b/tests/unit/zone/test_user_apikey.py @@ -1,7 +1,6 @@ import json import pytest from unittest.mock import patch -from base64 import b64encode from collections import namedtuple import powerdnsadmin @@ -10,10 +9,8 @@ from powerdnsadmin.models.domain import Domain from powerdnsadmin.models.api_key import ApiKey from powerdnsadmin.models.role import Role from powerdnsadmin.lib.validators import validate_zone -from powerdnsadmin.lib.schema import DomainSchema, ApiKeySchema -from tests.fixtures import client, initial_data, created_zone_data -from tests.fixtures import user_apikey, zone_data -from tests.fixtures import user_apikey_data, load_data +from powerdnsadmin.lib.schema import DomainSchema +from tests.conftest import user_apikey_data, load_data class TestUnitApiZoneUserApiKey(object):