# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-pytest-httpbin
pkgver=2.1.0
pkgrel=1
pkgdesc='A py.test fixture for httpbining code'
arch=('any')
license=('MIT')
url='https://github.com/kevin1024/pytest-httpbin'
depends=('python-pytest' 'httpbin')
makedepends=('python-build' 'python-installer' 'python-setuptools' 'python-wheel')
checkdepends=('python-requests')
source=("https://github.com/kevin1024/pytest-httpbin/archive/v$pkgver/$pkgname-$pkgver.tar.gz"
        $pkgname-LICENSE::https://raw.githubusercontent.com/kevin1024/pytest-httpbin/0bd7637a5c59b1a8376b9a4f051b02a97abb8c1b/LICENSE)
sha512sums=('849985f170318ea3ad1d2af8811f3e3fef0e62bd6bdc611f061a8cd7d84a2d85d0ba9caf8c97298e1c99b979b08f1a28476927fa7abc1fa57334732ecfbdf2db'
            '64e7f080f69371711a2181dc7c072e1e4770914b577daae141deab447d781bddd1eae8a79eda367549ed7830de3d80c1a29d7139478f547e40bed62f2d75a3ca')

build() {
  cd pytest-httpbin-$pkgver
  python -m build -nw
}

check() {
  # Hack entry points by installing it
  # https://github.com/kevin1024/pytest-httpbin/issues/64

  cd pytest-httpbin-$pkgver
  python -m installer -d tmp_install dist/*.whl
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  PYTHONPATH="$PWD/tmp_install/$site_packages" pytest --deselect tests/test_server.py::test_redirect_location_is_https_for_secure_server
}

package() {
  cd pytest-httpbin-$pkgver
  python -m installer -d "$pkgdir" dist/*.whl
  install -Dm644 ../$pkgname-LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
