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

pkgname=python-requests-mock
pkgver=1.12.1
pkgrel=3
pkgdesc='A mock of useful classes & functions to be used with python-requests'
arch=(any)
url='https://github.com/jamielennox/requests-mock'
license=(Apache-2.0)
depends=(
  python
  python-requests
)
makedepends=(
  git
  python-build
  python-installer
  python-setuptools
  python-setuptools-scm
  python-wheel
)
checkdepends=(
  python-purl
  python-pytest
  python-requests-futures
  python-testtools
  python-fixtures
  python-pbr
)
source=(
  "$pkgname::git+$url#tag=$pkgver"
  fix-test.patch
)
sha512sums=('2e539ac04e950f08a6de44355a2d6e878980b7c86a8ddcbaf2ce526de6f4342f61fe51874e5b64809723a1295e2f00f8ee451f643d407327e1284df1602f5537'
            '0b880e5e8902903ff598d0420e2d00c518a906f835c86bde3dbb1ffb6cc972f1655f530408e67c614ed817e7896aaf8975c986cfe85883cd2d6015d88c014b62')
b2sums=('c4207736c642adbc30d1313332ae2b37f20e623b61a3767d6a9dc62ee2c75ca9534adafd00d2f61864ab131f78c7816666103c7c604aa6fca5fc2be76766c16a'
        '8cf6d5aad8c7e1fd626ebfc5fbdad2b586c867dd97997b02d4f7298adfb00c0d3cff2cc27650f694d7e6fdde0861a749d25c108a958c408f3061fd377c9bf016')

prepare() {
  cd "$pkgname"

  patch -p1 -i "$srcdir/fix-test.patch"
}

build() {
  cd "$pkgname"

  SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver python -m build --wheel --no-isolation
}

check() {
  cd "$pkgname"

  python -m pytest tests/pytest
  python -m testtools.run discover
}

package() {
  cd "$pkgname"

  python -m installer --destdir="$pkgdir" dist/*.whl
}
