Skip to content

Commit

Permalink
Move tests outside project source folder
Browse files Browse the repository at this point in the history
  • Loading branch information
wannacfuture committed Jan 7, 2021
1 parent 71980cd commit 61fc25e
Show file tree
Hide file tree
Showing 23 changed files with 42 additions and 36 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import django
import sphinx_rtd_theme

environ.setdefault("DJANGO_SETTINGS_MODULE", "axes.tests.settings")
environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings")
django.setup()

# -- Extra custom configuration ------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "axes.tests.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings")

from django.core.management import execute_from_command_line

Expand Down
5 changes: 2 additions & 3 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[pytest]
testpaths = axes/tests
python_files = tests.py test_*.py tests_*.py *_tests.py *_test.py
testpaths = tests
addopts = --cov axes --cov-config .coveragerc --cov-append --cov-report term-missing --cov-report=xml
DJANGO_SETTINGS_MODULE = axes.tests.settings
DJANGO_SETTINGS_MODULE = tests.settings
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
python_requires="~=3.6",
install_requires=["django>=2.2", "django-ipware>=3,<4"],
include_package_data=True,
packages=find_packages(),
packages=find_packages(exclude=["tests"]),
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion axes/tests/settings.py → tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]

ROOT_URLCONF = "axes.tests.urls"
ROOT_URLCONF = "tests.urls"

INSTALLED_APPS = [
"django.contrib.auth",
Expand Down
3 changes: 2 additions & 1 deletion axes/tests/test_admin.py → tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import axes.admin
from axes.models import AccessAttempt, AccessLog
from axes.tests.base import AxesTestCase

from tests.base import AxesTestCase


class AxesEnableAdminFlag(AxesTestCase):
Expand Down
3 changes: 2 additions & 1 deletion axes/tests/test_attempts.py → tests/test_attempts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

from axes.attempts import get_cool_off_threshold
from axes.models import AccessAttempt
from axes.tests.base import AxesTestCase
from axes.utils import reset, reset_request

from tests.base import AxesTestCase


class GetCoolOffThresholdTestCase(AxesTestCase):
@override_settings(AXES_COOLOFF_TIME=42)
Expand Down
3 changes: 2 additions & 1 deletion axes/tests/test_backends.py → tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
AxesBackendRequestParameterRequired,
AxesBackendPermissionDenied,
)
from axes.tests.base import AxesTestCase

from tests.base import AxesTestCase


class BackendTestCase(AxesTestCase):
Expand Down
7 changes: 4 additions & 3 deletions axes/tests/test_checks.py → tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

from axes.backends import AxesBackend
from axes.checks import Messages, Hints, Codes
from axes.tests.base import AxesTestCase

from tests.base import AxesTestCase


class CacheCheckTestCase(AxesTestCase):
Expand Down Expand Up @@ -75,14 +76,14 @@ def test_backend_missing(self):
self.assertEqual(warnings, [warning])

@override_settings(
AUTHENTICATION_BACKENDS=["axes.tests.test_checks.AxesSpecializedBackend"]
AUTHENTICATION_BACKENDS=["tests.test_checks.AxesSpecializedBackend"]
)
def test_specialized_backend(self):
warnings = run_checks()
self.assertEqual(warnings, [])

@override_settings(
AUTHENTICATION_BACKENDS=["axes.tests.test_checks.AxesNotDefinedBackend"]
AUTHENTICATION_BACKENDS=["tests.test_checks.AxesNotDefinedBackend"]
)
def test_import_error(self):
with self.assertRaises(ImportError):
Expand Down
3 changes: 2 additions & 1 deletion axes/tests/test_decorators.py → tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from django.http import HttpResponse

from axes.decorators import axes_dispatch, axes_form_invalid
from axes.tests.base import AxesTestCase

from tests.base import AxesTestCase


class DecoratorTestCase(AxesTestCase):
Expand Down
7 changes: 4 additions & 3 deletions axes/tests/test_handlers.py → tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from axes.handlers.proxy import AxesProxyHandler
from axes.helpers import get_client_str
from axes.models import AccessAttempt, AccessLog
from axes.tests.base import AxesTestCase

from tests.base import AxesTestCase


@override_settings(AXES_HANDLER="axes.handlers.base.AxesHandler")
Expand Down Expand Up @@ -54,7 +55,7 @@ def test_is_admin_site(self):
request.path = url
self.assertEqual(AxesProxyHandler().is_admin_site(request), expected)

@override_settings(ROOT_URLCONF="axes.tests.urls_empty")
@override_settings(ROOT_URLCONF="tests.urls_empty")
@override_settings(AXES_ONLY_ADMIN_SITE=True)
def test_is_admin_site_no_admin_site(self):
request = MagicMock()
Expand Down Expand Up @@ -240,7 +241,7 @@ def test_handler_without_reset(self):
def test_handler_callable_failure_limit(self):
self.check_handler()

@override_settings(AXES_FAILURE_LIMIT="axes.tests.base.custom_failure_limit")
@override_settings(AXES_FAILURE_LIMIT="tests.base.custom_failure_limit")
def test_handler_str_failure_limit(self):
self.check_handler()

Expand Down
13 changes: 5 additions & 8 deletions axes/tests/test_helpers.py → tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from django.test import override_settings

from axes.helpers import get_cool_off, get_lockout_response, is_user_attempt_whitelisted
from axes.tests.base import AxesTestCase

from tests.base import AxesTestCase


def mock_get_cool_off_str():
Expand All @@ -25,9 +26,7 @@ def test_get_cool_off_int(self):
def test_get_cool_off_callable(self):
self.assertEqual(get_cool_off(), timedelta(seconds=30))

@override_settings(
AXES_COOLOFF_TIME="axes.tests.test_helpers.mock_get_cool_off_str"
)
@override_settings(AXES_COOLOFF_TIME="tests.test_helpers.mock_get_cool_off_str")
def test_get_cool_off_path(self):
self.assertEqual(get_cool_off(), timedelta(seconds=30))

Expand All @@ -50,9 +49,7 @@ def test_is_whitelisted(self):
def test_is_whitelisted_override_callable(self):
self.assertTrue(is_user_attempt_whitelisted(self.request, self.credentials))

@override_settings(
AXES_WHITELIST_CALLABLE="axes.tests.test_helpers.mock_is_whitelisted"
)
@override_settings(AXES_WHITELIST_CALLABLE="tests.test_helpers.mock_is_whitelisted")
def test_is_whitelisted_override_path(self):
self.assertTrue(is_user_attempt_whitelisted(self.request, self.credentials))

Expand Down Expand Up @@ -81,7 +78,7 @@ def test_get_lockout_response_override_callable(self):
self.assertEqual(400, response.status_code)

@override_settings(
AXES_LOCKOUT_CALLABLE="axes.tests.test_helpers.mock_get_lockout_response"
AXES_LOCKOUT_CALLABLE="tests.test_helpers.mock_get_lockout_response"
)
def test_get_lockout_response_override_path(self):
response = get_lockout_response(self.request, self.credentials)
Expand Down
3 changes: 2 additions & 1 deletion axes/tests/test_logging.py → tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

from axes.apps import AppConfig
from axes.models import AccessAttempt, AccessLog
from axes.tests.base import AxesTestCase

from tests.base import AxesTestCase


@patch("axes.apps.AppConfig.initialized", False)
Expand Down
3 changes: 2 additions & 1 deletion axes/tests/test_login.py → tests/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
from axes.conf import settings
from axes.models import AccessAttempt
from axes.helpers import get_cache, make_cache_key_list
from axes.tests.base import AxesTestCase

from tests.base import AxesTestCase


class DjangoLoginTestCase(TestCase):
Expand Down
3 changes: 2 additions & 1 deletion axes/tests/test_management.py → tests/test_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from django.utils import timezone

from axes.models import AccessAttempt, AccessLog
from axes.tests.base import AxesTestCase

from tests.base import AxesTestCase


class ResetAccessLogsManagementCommandTestCase(AxesTestCase):
Expand Down
6 changes: 2 additions & 4 deletions axes/tests/test_middleware.py → tests/test_middleware.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from unittest import mock

from django.http import HttpResponse, HttpRequest
from django.conf import settings
from django.test import override_settings

from axes.middleware import AxesMiddleware
from axes.tests.base import AxesTestCase

from tests.base import AxesTestCase


class MiddlewareTestCase(AxesTestCase):
Expand Down
3 changes: 2 additions & 1 deletion axes/tests/test_models.py → tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from django.db.migrations.state import ProjectState

from axes.models import AccessAttempt, AccessLog
from axes.tests.base import AxesTestCase

from tests.base import AxesTestCase


class ModelsTestCase(AxesTestCase):
Expand Down
3 changes: 2 additions & 1 deletion axes/tests/test_signals.py → tests/test_signals.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from unittest.mock import MagicMock

from axes.tests.base import AxesTestCase
from axes.signals import user_locked_out

from tests.base import AxesTestCase


class SignalTestCase(AxesTestCase):
def test_send_lockout_signal(self):
Expand Down
5 changes: 3 additions & 2 deletions axes/tests/test_utils.py → tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from axes.apps import AppConfig
from axes.models import AccessAttempt
from axes.tests.base import AxesTestCase
from axes.helpers import (
get_cache_timeout,
get_client_str,
Expand All @@ -24,6 +23,8 @@
toggleable,
)

from tests.base import AxesTestCase


@override_settings(AXES_ENABLED=False)
class AxesDisabledTestCase(AxesTestCase):
Expand Down Expand Up @@ -488,7 +489,7 @@ def test_get_client_username_not_callable(self):
with self.assertRaises(TypeError):
get_client_username(HttpRequest(), {})

@override_settings(AXES_USERNAME_CALLABLE="axes.tests.test_utils.get_username")
@override_settings(AXES_USERNAME_CALLABLE="tests.test_utils.get_username")
def test_get_client_username_str(self):
self.assertEqual(get_client_username(HttpRequest(), {}), "username")

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 61fc25e

Please sign in to comment.