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
This commit is contained in:
corubba 2022-06-24 14:19:52 +02:00 committed by Ymage
parent e920bf5009
commit 8d849ee2a1
15 changed files with 8 additions and 43 deletions

View File

@ -4,8 +4,7 @@ from collections import namedtuple
from powerdnsadmin.lib.validators import validate_apikey from powerdnsadmin.lib.validators import validate_apikey
from powerdnsadmin.lib.schema import ApiKeySchema from powerdnsadmin.lib.schema import ApiKeySchema
from tests.fixtures import client, initial_data, basic_auth_admin_headers from tests.conftest import user_apikey_data, admin_apikey_data
from tests.fixtures import user_apikey_data, admin_apikey_data, zone_data
class TestIntegrationApiApiKeyAdminUser(object): class TestIntegrationApiApiKeyAdminUser(object):

View File

@ -1,11 +1,8 @@
import pytest
import json import json
from collections import namedtuple from collections import namedtuple
from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.validators import validate_zone
from powerdnsadmin.lib.schema import DomainSchema 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): class TestIntegrationApiZoneUser(object):

View File

@ -1,9 +1,5 @@
import json 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 from . import IntegrationApiManagement

View File

@ -1,10 +1,6 @@
import json 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 from . import IntegrationApiManagement

View File

@ -1,11 +1,8 @@
import pytest
import json import json
from collections import namedtuple from collections import namedtuple
from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.validators import validate_zone
from powerdnsadmin.lib.schema import DomainSchema 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): class TestIntegrationApiZoneAdminUser(object):

View File

@ -3,9 +3,6 @@ from collections import namedtuple
from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.validators import validate_zone
from powerdnsadmin.lib.schema import DomainSchema 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): class TestIntegrationApiZoneAdminApiKey(object):

View File

@ -3,9 +3,6 @@ from collections import namedtuple
from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.validators import validate_zone
from powerdnsadmin.lib.schema import DomainSchema 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): class TestIntegrationApiZoneUserApiKey(object):

View File

@ -3,8 +3,6 @@ from collections import namedtuple
from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.validators import validate_zone
from powerdnsadmin.lib.schema import DomainSchema 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): class TestIntegrationApiZoneUser(object):

View File

@ -2,9 +2,6 @@ import json
import pytest import pytest
from unittest.mock import patch from unittest.mock import patch
from collections import namedtuple from collections import namedtuple
import sys
import os
sys.path.append(os.getcwd())
import powerdnsadmin import powerdnsadmin
from powerdnsadmin.models.setting import Setting 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.api_key import ApiKey
from powerdnsadmin.models.role import Role from powerdnsadmin.models.role import Role
from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.validators import validate_zone
from powerdnsadmin.lib.schema import DomainSchema, ApiKeySchema from powerdnsadmin.lib.schema import DomainSchema
from tests.fixtures import client, initial_data, created_zone_data from tests.conftest import admin_apikey_data, load_data
from tests.fixtures import user_apikey, admin_apikey, zone_data
from tests.fixtures import admin_apikey_data, load_data
class TestUnitApiZoneAdminApiKey(object): class TestUnitApiZoneAdminApiKey(object):

View File

@ -5,12 +5,10 @@ from collections import namedtuple
import powerdnsadmin import powerdnsadmin
from powerdnsadmin.models.user import User from powerdnsadmin.models.user import User
from powerdnsadmin.models.role import Role
from powerdnsadmin.models.domain import Domain from powerdnsadmin.models.domain import Domain
from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.validators import validate_zone
from powerdnsadmin.lib.schema import DomainSchema from powerdnsadmin.lib.schema import DomainSchema
from tests.fixtures import client, basic_auth_admin_headers from tests.conftest import load_data
from tests.fixtures import zone_data, created_zone_data, load_data
class TestUnitApiZoneAdminUser(object): class TestUnitApiZoneAdminUser(object):

View File

@ -5,12 +5,10 @@ from collections import namedtuple
import powerdnsadmin import powerdnsadmin
from powerdnsadmin.models.user import User from powerdnsadmin.models.user import User
from powerdnsadmin.models.role import Role
from powerdnsadmin.models.domain import Domain from powerdnsadmin.models.domain import Domain
from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.validators import validate_zone
from powerdnsadmin.lib.schema import DomainSchema from powerdnsadmin.lib.schema import DomainSchema
from tests.fixtures import client, basic_auth_user_headers from tests.conftest import load_data
from tests.fixtures import zone_data, created_zone_data, load_data
class TestUnitApiZoneUser(object): class TestUnitApiZoneUser(object):

View File

@ -1,7 +1,6 @@
import json import json
import pytest import pytest
from unittest.mock import patch from unittest.mock import patch
from base64 import b64encode
from collections import namedtuple from collections import namedtuple
import powerdnsadmin import powerdnsadmin
@ -10,10 +9,8 @@ from powerdnsadmin.models.domain import Domain
from powerdnsadmin.models.api_key import ApiKey from powerdnsadmin.models.api_key import ApiKey
from powerdnsadmin.models.role import Role from powerdnsadmin.models.role import Role
from powerdnsadmin.lib.validators import validate_zone from powerdnsadmin.lib.validators import validate_zone
from powerdnsadmin.lib.schema import DomainSchema, ApiKeySchema from powerdnsadmin.lib.schema import DomainSchema
from tests.fixtures import client, initial_data, created_zone_data from tests.conftest import user_apikey_data, load_data
from tests.fixtures import user_apikey, zone_data
from tests.fixtures import user_apikey_data, load_data
class TestUnitApiZoneUserApiKey(object): class TestUnitApiZoneUserApiKey(object):