# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-flexmock
pkgver=0.12.1
pkgrel=1
pkgdesc="Mock/Stub/Spy library for Python"
arch=(any)
url="https://flexmock.readthedocs.io"
license=('BSD-2-Clause')
depends=('python')
makedepends=('git' 'python-build' 'python-installer' 'python-poetry-core')
checkdepends=('python-pytest' 'python-teamcity-messages' 'python-testtools' 'python-twisted')
source=("git+https://github.com/flexmock/flexmock.git#tag=$pkgver")
sha512sums=('841726bc48c5cf7e1007715252e41c84902a6d3f91271306ca0e6b519976c9066bc8bbe7e2f9e44e39209fc4057c42e80f4422a2f0b96e72dcca4063886d320d')

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

check() {
  cd flexmock
  PYTHONPATH="$PWD/src" pytest -p flexmock._pytest_plugin
}

package() {
  cd flexmock
  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"/flexmock-$pkgver.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
