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

pkgname=python-httpretty
pkgver=1.1.4
pkgrel=8
pkgdesc="HTTP client mock for Python"
arch=('any')
url="https://github.com/gabrielfalcao/httpretty"
license=('MIT')
depends=('python-urllib3')
makedepends=('python-build'
             'python-installer'
             'python-wheel'
             'python-setuptools')
checkdepends=('openssl'
              'python-boto3'
              'python-cryptography'
              'python-eventlet'
              'python-freezegun'
              'python-httplib2'
              'python-httpx'
              'python-ipdb'
              'python-mccabe'
              'python-ndg-httpsclient'
              'python-pyopenssl'
              'python-pytest'
              'python-redis'
              'python-requests'
              'python-requests-toolbelt'
              'python-sure'
              'python-tornado')
source=("$url/archive/$pkgver/$pkgname-$pkgver.tar.gz"
        $pkgname-drop-mock.patch::$url/pull/452.patch)
sha512sums=('58c733ba4719f97e06e2313bb6b94f1c6609d3facb2e0262ac37be97f1c3430eac661611ba9b3712c9c1809846e177b61f3fc2945f3770d475f70b81bea2aced'
            '5520594ddb2e73d75c6eb8476dc1984464306614d915627c0c9e69815a5671d65e286e90f3ee926daa040f9f24a81835eb5c7993e620a5b67aaaefa06571dcb2')

prepare() {
  cd HTTPretty-$pkgver
  patch -p1 -i ../$pkgname-drop-mock.patch
  sed -i -e '/rednose/d' -e '/cover/d' setup.cfg
}

build() {
  cd HTTPretty-$pkgver
  python -m build -wn
}

check() {
  cd HTTPretty-$pkgver
  export PYTHONPATH=.
  local deseclected=(
    # https://github.com/gabrielfalcao/HTTPretty/issues/457
    tests/functional/test_requests.py
    # meant to be used with nose not pytest
    tests/functional/test_bypass.py
    tests/functional/test_debug.py
    tests/functional/test_requests.py
    tests/functional/test_passthrough.py
  )
  pytest ${deseclected[@]/#/--deselect }
}

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