1 |
commit: 410818d2c733bd5961d51191083b423ef53761b1 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Jan 21 08:04:33 2020 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Jan 21 08:06:41 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=410818d2 |
7 |
|
8 |
Test /etc/portage/modules portdbapi.auxdbmodule settings |
9 |
|
10 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
11 |
|
12 |
lib/portage/tests/dbapi/test_auxdb.py | 50 ++++++++++++++++++++++++ |
13 |
lib/portage/tests/resolver/ResolverPlayground.py | 2 +- |
14 |
2 files changed, 51 insertions(+), 1 deletion(-) |
15 |
|
16 |
diff --git a/lib/portage/tests/dbapi/test_auxdb.py b/lib/portage/tests/dbapi/test_auxdb.py |
17 |
new file mode 100644 |
18 |
index 000000000..73fc2b2c3 |
19 |
--- /dev/null |
20 |
+++ b/lib/portage/tests/dbapi/test_auxdb.py |
21 |
@@ -0,0 +1,50 @@ |
22 |
+# Copyright 2020 Gentoo Authors |
23 |
+# Distributed under the terms of the GNU General Public License v2 |
24 |
+ |
25 |
+from __future__ import unicode_literals |
26 |
+ |
27 |
+from portage.tests import TestCase |
28 |
+from portage.tests.resolver.ResolverPlayground import ResolverPlayground |
29 |
+from portage.util.futures import asyncio |
30 |
+from portage.util.futures.compat_coroutine import coroutine |
31 |
+ |
32 |
+ |
33 |
+class AuxdbTestCase(TestCase): |
34 |
+ |
35 |
+ def test_flat_hash_md5(self): |
36 |
+ self._test_mod('portage.cache.flat_hash.md5_database') |
37 |
+ |
38 |
+ def test_volatile(self): |
39 |
+ self._test_mod('portage.cache.volatile.database') |
40 |
+ |
41 |
+ def test_sqite(self): |
42 |
+ try: |
43 |
+ import sqlite3 |
44 |
+ except ImportError: |
45 |
+ self.skipTest('sqlite3 import failed') |
46 |
+ self._test_mod('portage.cache.sqlite.database') |
47 |
+ |
48 |
+ def _test_mod(self, auxdbmodule): |
49 |
+ ebuilds = { |
50 |
+ "cat/A-1": { |
51 |
+ "EAPI": "7" |
52 |
+ }, |
53 |
+ "cat/B-1": { |
54 |
+ "EAPI": "7" |
55 |
+ }, |
56 |
+ } |
57 |
+ |
58 |
+ playground = ResolverPlayground(ebuilds=ebuilds, |
59 |
+ user_config={'modules': ('portdbapi.auxdbmodule = %s' % auxdbmodule,)}) |
60 |
+ |
61 |
+ portdb = playground.trees[playground.eroot]["porttree"].dbapi |
62 |
+ |
63 |
+ loop = asyncio._wrap_loop() |
64 |
+ loop.run_until_complete(self._test_mod_async(ebuilds, portdb)) |
65 |
+ |
66 |
+ @coroutine |
67 |
+ def _test_mod_async(self, ebuilds, portdb): |
68 |
+ |
69 |
+ for cpv, metadata in ebuilds.items(): |
70 |
+ eapi, = yield portdb.async_aux_get(cpv, ['EAPI']) |
71 |
+ self.assertEqual(eapi, metadata['EAPI']) |
72 |
|
73 |
diff --git a/lib/portage/tests/resolver/ResolverPlayground.py b/lib/portage/tests/resolver/ResolverPlayground.py |
74 |
index cc3056ab4..d7fbe4390 100644 |
75 |
--- a/lib/portage/tests/resolver/ResolverPlayground.py |
76 |
+++ b/lib/portage/tests/resolver/ResolverPlayground.py |
77 |
@@ -44,7 +44,7 @@ class ResolverPlayground(object): |
78 |
its work. |
79 |
""" |
80 |
|
81 |
- config_files = frozenset(("eapi", "layout.conf", "make.conf", "package.accept_keywords", |
82 |
+ config_files = frozenset(("eapi", "layout.conf", "make.conf", "modules", "package.accept_keywords", |
83 |
"package.keywords", "package.license", "package.mask", "package.properties", |
84 |
"package.provided", "packages", |
85 |
"package.unmask", "package.use", "package.use.aliases", "package.use.stable.mask", |