#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export PYBUILD_NAME=django-otp

%:
	dh $@ --with python3,sphinxdoc --buildsystem=pybuild

override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=.:docs/ext sphinx-build -b html -d docs/.build/.doctrees -N docs/source docs/.build/html

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	django-admin startproject test_project
	cp debian/settings.py test_project/test_project/settings.py
	dh_auto_test -- --system=custom --test-args="PYTHONPATH='.:test_project' {interpreter} /usr/bin/django-admin test --settings=test_project.settings django_otp"
	set -e; \
	for plugin in otp_email otp_static otp_hotp otp_totp; do \
		dh_auto_test -- --system=custom --test-args="PYTHONPATH='.:test_project' {interpreter} /usr/bin/django-admin test --settings=test_project.settings django_otp.plugins.$$plugin"; \
	done
	rm -rf test_project
endif

override_dh_clean:
	rm -rf docs/.build
	dh_clean
