diff --git a/.gitignore b/.gitignore index 800c70e..68a2f5f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ /example/database.sqlite3 /example/GeoLiteCity.dat /django_user_sessions.egg-info/ -/tests/test_city.mmdb -/tests/test_country.mmdb /htmlcov/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ec76055..d037fce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,3 +18,11 @@ repos: hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] + - repo: local + hooks: + - id: generate-mmdb-fixtures + name: Regenerate MaxMind database files + language: system + entry: make tests/test_city.mmdb tests/test_country.mmdb + always_run: true + pass_filenames: false diff --git a/Makefile b/Makefile index 5a87979..a4291dd 100644 --- a/Makefile +++ b/Makefile @@ -13,11 +13,15 @@ check: DJANGO_SETTINGS_MODULE=example.settings PYTHONPATH=. \ python -Wd example/manage.py check -generate-mmdb-fixtures: +tests/test_city.mmdb: tests/Dockerfile tests/generate_mmdb.pl docker --context=default buildx build -f tests/Dockerfile --tag test-mmdb-maker tests docker run --rm --volume $$(pwd)/tests:/data test-mmdb-maker -test: generate-mmdb-fixtures +tests/test_country.mmdb: tests/Dockerfile tests/generate_mmdb.pl + docker --context=default buildx build -f tests/Dockerfile --tag test-mmdb-maker tests + docker run --rm --volume $$(pwd)/tests:/data test-mmdb-maker + +test: tests/test_city.mmdb tests/test_country.mmdb DJANGO_SETTINGS_MODULE=tests.settings PYTHONPATH=. \ django-admin.py test ${TARGET} diff --git a/tests/test_city.mmdb b/tests/test_city.mmdb new file mode 100644 index 0000000..9533ba8 Binary files /dev/null and b/tests/test_city.mmdb differ diff --git a/tests/test_country.mmdb b/tests/test_country.mmdb new file mode 100644 index 0000000..f44a8c0 Binary files /dev/null and b/tests/test_country.mmdb differ diff --git a/tox.ini b/tox.ini index 191e76f..893502b 100644 --- a/tox.ini +++ b/tox.ini @@ -27,7 +27,6 @@ DJANGO = [testenv] commands = - make generate-mmdb-fixtures coverage run {envbindir}/django-admin test -v 2 --pythonpath=./ --settings=tests.settings coverage report coverage xml @@ -41,4 +40,3 @@ deps = geoip2 ignore_outcome = djmain: True -allowlist_externals = make