diff options
author | Michał Górny <mgorny@gentoo.org> | 2021-04-19 23:16:55 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2021-04-19 23:22:53 +0200 |
commit | b1fcc6449b882f16b93fac0c05c9f18e676ae8a0 (patch) | |
tree | fcf355dbab5bb78d922e2aee10291c96ccf9fd53 /dev-python/flask-mongoengine | |
parent | dev-python/argcomplete: Bump to 1.12.3 (diff) | |
download | gentoo-b1fcc6449b882f16b93fac0c05c9f18e676ae8a0.tar.gz gentoo-b1fcc6449b882f16b93fac0c05c9f18e676ae8a0.tar.bz2 gentoo-b1fcc6449b882f16b93fac0c05c9f18e676ae8a0.zip |
dev-python/flask-mongoengine: Run mongodb locally for tests
Closes: https://bugs.gentoo.org/730448
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python/flask-mongoengine')
-rw-r--r-- | dev-python/flask-mongoengine/flask-mongoengine-1.0.0.ebuild | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/dev-python/flask-mongoengine/flask-mongoengine-1.0.0.ebuild b/dev-python/flask-mongoengine/flask-mongoengine-1.0.0.ebuild index 9423465341ba..1afb666dd865 100644 --- a/dev-python/flask-mongoengine/flask-mongoengine-1.0.0.ebuild +++ b/dev-python/flask-mongoengine/flask-mongoengine-1.0.0.ebuild @@ -15,12 +15,14 @@ SRC_URI=" LICENSE="BSD" SLOT="0" KEYWORDS="amd64" -# TODO: make it spawn a local mongodb instance -RESTRICT="test" RDEPEND=">=dev-python/flask-1.1.2[${PYTHON_USEDEP}] >=dev-python/mongoengine-0.20[${PYTHON_USEDEP}] >=dev-python/flask-wtf-0.14.3[${PYTHON_USEDEP}]" +BDEPEND=" + test? ( + dev-db/mongodb + )" distutils_enable_sphinx docs distutils_enable_tests pytest @@ -34,3 +36,38 @@ python_prepare_all() { distutils-r1_python_prepare_all } + +python_test() { + local dbpath=${TMPDIR}/mongo.db + local logpath=${TMPDIR}/mongod.log + + mkdir -p "${dbpath}" || die + ebegin "Trying to start mongod on port ${DB_PORT}" + + LC_ALL=C \ + mongod --dbpath "${dbpath}" --nojournal \ + --bind_ip 127.0.0.1 --port 27017 \ + --unixSocketPrefix "${TMPDIR}" \ + --logpath "${logpath}" --fork || die + sleep 2 + + # Now we need to check if the server actually started... + if [[ -S "${TMPDIR}"/mongodb-27017.sock ]]; then + # yay! + eend 0 + else + eend 1 + eerror "Unable to start mongod for tests. See the server log:" + eerror " ${logpath}" + die "Unable to start mongod for tests." + fi + + local failed + nonfatal epytest || failed=1 + + mongod --dbpath "${dbpath}" --shutdown || die + + [[ ${failed} ]] && die "Tests fail with ${EPYTHON}" + + rm -rf "${dbpath}" || die +} |