# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Jerome Leclanche <jerome@leclan.ch>

pkgname=python-webtest
pkgver=3.0.3
pkgrel=1
pkgdesc="Helper to test WSGI applications"
arch=('any')
url='https://docs.pylonsproject.org/projects/webtest/en/latest/'
license=('MIT')
depends=('python-webob' 'python-beautifulsoup4' 'python-waitress')
optdepends=('python-pyquery: for response.pyquery'
            'python-lxml: for response.lxml')
makedepends=('git' 'python-build' 'python-installer' 'python-setuptools' 'python-wheel')
checkdepends=('python-pytest' 'python-pyquery' 'python-pastedeploy' 'python-wsgiproxy2')
source=("git+https://github.com/Pylons/webtest.git#tag=$pkgver")
sha512sums=('565bb098ec0b130c37d00c0b3a3936cd43f7d0805d8223303c5d67d5e908cd564db8173154a791a9b9edac8366bf9aaddb8a8732dd86d59dae0dac0d73c90fe5')

build() {
  cd webtest
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd webtest
  pytest
}

package() {
  cd webtest
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/WebTest-$pkgver.dist-info/LICENSE.rst \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.rst
}
