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

pkgname=python-httpretty
pkgver=1.1.4
pkgrel=7
pkgdesc="HTTP client mock for Python"
arch=('any')
url="https://github.com/gabrielfalcao/httpretty"
license=('MIT')
depends=('python-urllib3')
makedepends=('python-setuptools')
checkdepends=('python-nose' 'python-coverage' 'python-eventlet' 'python-freezegun' 'python-httplib2'
              'python-redis' 'python-requests' 'python-sure' 'python-tornado'
              'python-httpx' 'python-boto3')
source=("https://github.com/gabrielfalcao/HTTPretty/archive/$pkgver/$pkgname-$pkgver.tar.gz"
        $pkgname-drop-mock.patch::https://github.com/gabrielfalcao/HTTPretty/pull/452.patch)
sha512sums=('58c733ba4719f97e06e2313bb6b94f1c6609d3facb2e0262ac37be97f1c3430eac661611ba9b3712c9c1809846e177b61f3fc2945f3770d475f70b81bea2aced'
            '5520594ddb2e73d75c6eb8476dc1984464306614d915627c0c9e69815a5671d65e286e90f3ee926daa040f9f24a81835eb5c7993e620a5b67aaaefa06571dcb2')

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

build() {
  cd HTTPretty-$pkgver
  python setup.py build
}

check() {
  cd HTTPretty-$pkgver
  # https://github.com/gabrielfalcao/HTTPretty/issues/457
  nosetests3 -s tests -e test_httpretty_should_handle_paths_starting_with_two_slashes
}

package() {
  cd HTTPretty-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1
  install -Dm644 COPYING -t "$pkgdir"/usr/share/licenses/$pkgname/
}
