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

pkgname=python-mongomock
pkgver=4.3.0
pkgrel=1
pkgdesc="Fake pymongo stub for testing simple MongoDB-dependent code"
url="https://github.com/mongomock/mongomock"
license=('ISC')
arch=('any')
depends=('python-sentinels' 'python-packaging' 'python-pytz')
makedepends=('git' 'python-build' 'python-hatch-vcs' 'python-hatchling' 'python-installer')
checkdepends=('python-pymongo' 'python-pytest')
source=("git+https://github.com/mongomock/mongomock.git#tag=$pkgver")
sha512sums=('0e7685b22f6f6a0a5c98870825415cb9e794e705116720a65d806bcf3b542c32149e05b802ab2400e2e38a358d64ba5c5f01dbb062c785500633863f7c9c58d4')

build() {
  cd mongomock
  python -m build --wheel --no-isolation
}

check() {
  cd mongomock

  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  NO_LOCAL_MONGO=1 test-env/bin/python -m pytest -v tests \
    -k 'not (test__codec_options_with_pymongo or test__codec_options or test_insert_bson_invalid_encode_type or test_insert_bson_validation or test__bulk_write_ or test__get_collection_different_codec_options or test__with_options_pymongo or test__with_options_type_registry)'
}

package() {
  cd mongomock
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
