2019-02-01 16:19:15 +00:00
|
|
|
from django.apps.registry import apps
|
|
|
|
|
from django.db import connection
|
|
|
|
|
from django.db.migrations.autodetector import MigrationAutodetector
|
|
|
|
|
from django.db.migrations.executor import MigrationExecutor
|
|
|
|
|
from django.db.migrations.state import ProjectState
|
2018-10-24 23:48:59 +00:00
|
|
|
|
2019-02-12 21:22:52 +00:00
|
|
|
from axes.models import AccessAttempt, AccessLog
|
2021-01-06 21:42:25 +00:00
|
|
|
|
|
|
|
|
from tests.base import AxesTestCase
|
2018-10-24 23:48:59 +00:00
|
|
|
|
2019-02-12 21:22:52 +00:00
|
|
|
|
2019-02-22 23:22:11 +00:00
|
|
|
class ModelsTestCase(AxesTestCase):
|
2018-10-24 23:48:59 +00:00
|
|
|
def setUp(self):
|
2019-02-12 21:22:52 +00:00
|
|
|
self.failures_since_start = 42
|
|
|
|
|
|
|
|
|
|
self.access_attempt = AccessAttempt(
|
2019-09-28 16:27:50 +00:00
|
|
|
failures_since_start=self.failures_since_start
|
2019-02-12 21:22:52 +00:00
|
|
|
)
|
|
|
|
|
self.access_log = AccessLog()
|
|
|
|
|
|
|
|
|
|
def test_access_attempt_str(self):
|
2019-09-28 16:27:50 +00:00
|
|
|
self.assertIn("Access", str(self.access_attempt))
|
2019-02-12 21:22:52 +00:00
|
|
|
|
|
|
|
|
def test_access_log_str(self):
|
2019-09-28 16:27:50 +00:00
|
|
|
self.assertIn("Access", str(self.access_log))
|
2018-10-24 23:48:59 +00:00
|
|
|
|
|
|
|
|
|
2019-02-22 23:22:11 +00:00
|
|
|
class MigrationsTestCase(AxesTestCase):
|
2018-10-24 23:48:59 +00:00
|
|
|
def test_missing_migrations(self):
|
|
|
|
|
executor = MigrationExecutor(connection)
|
|
|
|
|
autodetector = MigrationAutodetector(
|
2019-09-28 16:27:50 +00:00
|
|
|
executor.loader.project_state(), ProjectState.from_apps(apps)
|
2018-10-24 23:48:59 +00:00
|
|
|
)
|
2019-02-01 16:19:15 +00:00
|
|
|
|
2018-10-24 23:48:59 +00:00
|
|
|
changes = autodetector.changes(graph=executor.loader.graph)
|
2019-02-01 16:19:15 +00:00
|
|
|
|
2018-10-24 23:48:59 +00:00
|
|
|
self.assertEqual({}, changes)
|