# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=py3-webdavclient3
#_pkgreal is used by apkbuild-pypi to find modules at PyPI
_pkgreal=webdav-client-python-3
pkgver=3.14.6
pkgrel=1
pkgdesc="WebDAV client"
url="https://pypi.python.org/project/webdavclient3"
arch="noarch"
license="MIT"
depends="py3-requests py3-lxml py3-dateutil"
checkdepends="
	py3-pytest
	nginx
	nginx-mod-http-dav-ext
	"
makedepends="py3-setuptools py3-gpep517 py3-wheel"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/ezhov-evgeny/webdav-client-python-3/archive/refs/tags/v$pkgver.tar.gz
	nginx-test.conf
	nginx-user.conf
	"
builddir="$srcdir/$_pkgreal-$pkgver"
subpackages="$pkgname-pyc"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	nginx -c "$srcdir"/nginx-test.conf &
	mkdir -p /tmp/www
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer "$builddir"/.dist/*.whl
	# set and get property disabled due to nginx-dav-ext-module not supporting PROPPATCH
	# see https://github.com/arut/nginx-dav-ext-module/pull/64
	# upstream uses apache2 for test server, which can't run as normal user
	.testenv/bin/python3 -m pytest -v  -k 'not test_get_property and not test_set_property' || local FAIL=true
	pkill nginx
	rm -R /tmp/www
	if [ "$FAIL" = "true" ]; then
		return 1
	fi
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
4621dfe3fdde4a60a7580b37aaf2bf778ebae1615946e9ff5aedcf3d2d17b3e60511a4522f8023bd4756139c66027149a2afafbd07bf02d029d811bec172057d  py3-webdavclient3-3.14.6.tar.gz
94fc0ca132eb3f96b613a8bc4788ff8ce4d9f06b7576d13a5bbd4a2994684d6087da791b258aac45ecaca3224a98c34d2853026ead24774901dc9ac8f0763dbb  nginx-test.conf
c0f9b9558abc0809fbf5e7600ba9f868f491debb7405bb5595ecfcc300cb68c602d2efe4340f1c86367f2ba7449b7f725affb9575a8b08bb5f9b65119f297a88  nginx-user.conf
"
