MigrationAutodetector is a class within the django.db.migrations.autodetector module of the Django project.
django-axes (project documentation and PyPI package information is a code library for Django projects to track failed login attempts against a web application. The goal of the project is to make it easier for you to stop people and scripts from hacking your Django-powered website.
The code for django-axes is open source under the MIT license and maintained by the group of developers known as Jazzband.
django-axes / axes / tests / test_models.py
# test_models.py
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
from axes.models import AccessAttempt, AccessLog
from axes.tests.base import AxesTestCase
class ModelsTestCase(AxesTestCase):
def setUp(self):
self.failures_since_start = 42
self.access_attempt = AccessAttempt(
failures_since_start=self.failures_since_start
)
self.access_log = AccessLog()
def test_access_attempt_str(self):
self.assertIn("Access", str(self.access_attempt))
def test_access_log_str(self):
self.assertIn("Access", str(self.access_log))
class MigrationsTestCase(AxesTestCase):
def test_missing_migrations(self):
executor = MigrationExecutor(connection)
autodetector = MigrationAutodetector(
executor.loader.project_state(), ProjectState.from_apps(apps)
)
changes = autodetector.changes(graph=executor.loader.graph)
self.assertEqual({}, changes)
## ... source file continues with no further MigrationAutodetector examples...