1 |
commit: b1fcc6449b882f16b93fac0c05c9f18e676ae8a0 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Apr 19 21:16:55 2021 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Apr 19 21:22:53 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b1fcc644 |
7 |
|
8 |
dev-python/flask-mongoengine: Run mongodb locally for tests |
9 |
|
10 |
Closes: https://bugs.gentoo.org/730448 |
11 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
12 |
|
13 |
.../flask-mongoengine-1.0.0.ebuild | 41 ++++++++++++++++++++-- |
14 |
1 file changed, 39 insertions(+), 2 deletions(-) |
15 |
|
16 |
diff --git a/dev-python/flask-mongoengine/flask-mongoengine-1.0.0.ebuild b/dev-python/flask-mongoengine/flask-mongoengine-1.0.0.ebuild |
17 |
index 9423465341b..1afb666dd86 100644 |
18 |
--- a/dev-python/flask-mongoengine/flask-mongoengine-1.0.0.ebuild |
19 |
+++ b/dev-python/flask-mongoengine/flask-mongoengine-1.0.0.ebuild |
20 |
@@ -15,12 +15,14 @@ SRC_URI=" |
21 |
LICENSE="BSD" |
22 |
SLOT="0" |
23 |
KEYWORDS="amd64" |
24 |
-# TODO: make it spawn a local mongodb instance |
25 |
-RESTRICT="test" |
26 |
|
27 |
RDEPEND=">=dev-python/flask-1.1.2[${PYTHON_USEDEP}] |
28 |
>=dev-python/mongoengine-0.20[${PYTHON_USEDEP}] |
29 |
>=dev-python/flask-wtf-0.14.3[${PYTHON_USEDEP}]" |
30 |
+BDEPEND=" |
31 |
+ test? ( |
32 |
+ dev-db/mongodb |
33 |
+ )" |
34 |
|
35 |
distutils_enable_sphinx docs |
36 |
distutils_enable_tests pytest |
37 |
@@ -34,3 +36,38 @@ python_prepare_all() { |
38 |
|
39 |
distutils-r1_python_prepare_all |
40 |
} |
41 |
+ |
42 |
+python_test() { |
43 |
+ local dbpath=${TMPDIR}/mongo.db |
44 |
+ local logpath=${TMPDIR}/mongod.log |
45 |
+ |
46 |
+ mkdir -p "${dbpath}" || die |
47 |
+ ebegin "Trying to start mongod on port ${DB_PORT}" |
48 |
+ |
49 |
+ LC_ALL=C \ |
50 |
+ mongod --dbpath "${dbpath}" --nojournal \ |
51 |
+ --bind_ip 127.0.0.1 --port 27017 \ |
52 |
+ --unixSocketPrefix "${TMPDIR}" \ |
53 |
+ --logpath "${logpath}" --fork || die |
54 |
+ sleep 2 |
55 |
+ |
56 |
+ # Now we need to check if the server actually started... |
57 |
+ if [[ -S "${TMPDIR}"/mongodb-27017.sock ]]; then |
58 |
+ # yay! |
59 |
+ eend 0 |
60 |
+ else |
61 |
+ eend 1 |
62 |
+ eerror "Unable to start mongod for tests. See the server log:" |
63 |
+ eerror " ${logpath}" |
64 |
+ die "Unable to start mongod for tests." |
65 |
+ fi |
66 |
+ |
67 |
+ local failed |
68 |
+ nonfatal epytest || failed=1 |
69 |
+ |
70 |
+ mongod --dbpath "${dbpath}" --shutdown || die |
71 |
+ |
72 |
+ [[ ${failed} ]] && die "Tests fail with ${EPYTHON}" |
73 |
+ |
74 |
+ rm -rf "${dbpath}" || die |
75 |
+} |