mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-09-24 04:59:14 -07:00
dev-python/flask-mongoengine: Run mongodb locally for tests
Closes: https://bugs.gentoo.org/730448 Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user