#! /usr/bin/make -f

export PYBUILD_NAME=betamax

# test_fixtures.py needs package already installed, test_add_urllib3_response
# is broken due unbundling in Debian
# (see https://github.com/kennethreitz/requests/issues/2870) and remaining
# tests need Internet connection.
PYTEST_ARGS = --ignore tests/integration/test_fixtures.py \
	--ignore tests/integration/test_hooks.py \
	--ignore tests/integration/test_placeholders.py \
	--ignore tests/integration/test_record_modes.py \
	--ignore tests/integration/test_unicode.py \
	--ignore tests/regression/test_gzip_compression.py \
	-k 'not test_add_urllib3_response'

LAST_CHANGE = $(shell dpkg-parsechangelog -S Date)
BUILD_DATE  = $(shell LC_ALL=C date -u "+%B %d, %Y" -d "$(LAST_CHANGE)")
SPHINXOPTS := -D html_last_updated_fmt="$(BUILD_DATE)"

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

override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=. http_proxy='127.0.0.1:9' sphinx-build $(SPHINXOPTS) -N -bhtml docs docs/build/html

# Tests must be copied manually since Jessie dh-python doesn't copy them.
# Depending on dh-python >= 2.20151103 is an alternative, but it's not in
# Jessie yet.
override_dh_auto_test:
	PYBUILD_SYSTEM=custom \
	PYBUILD_TEST_ARGS="cp -r {dir}/tests {build_dir}/tests; cd {build_dir}; {interpreter} -m pytest $(PYTEST_ARGS)" dh_auto_test
