commit: 7302780b25f4ad51959b0ba28801701abcf6d3c0
Author: Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Tue Nov 21 03:45:24 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun Dec 3 05:18:39 2023 +0000
URL:
https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=7302780b
pquery tests: convert to FakePkg for richer metadata tests
Additionally rename "test_no_description" to "test_missing_data"
since that's what it does.
Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
tests/scripts/test_pmaint.py | 8 ++++++--
tests/scripts/test_pquery.py | 33 ++++++++++++++++++++++++++++-----
2 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/tests/scripts/test_pmaint.py b/tests/scripts/test_pmaint.py
index 2cdb3009b..b4dc48cee 100644
--- a/tests/scripts/test_pmaint.py
+++ b/tests/scripts/test_pmaint.py
@@ -40,7 +40,9 @@ class FakeRepo(util.SimpleTree):
self.installed = []
self.replaced = []
self.uninstalled = []
- super().__init__(data, pkg_klass=partial(FakePkg.for_tree_usage,
repo=self), repo_id=repo_id)
+ super().__init__(
+ data, pkg_klass=partial(FakePkg.for_tree_usage, repo=self),
repo_id=repo_id
+ )
self.livefs = livefs
self.frozen = frozen
@@ -250,7 +252,9 @@ class TestCopy(ArgParseMixin):
),
)
assert ret == 0, "expected non zero exit code"
- assert [pkg.cpvstr for pkg in config.target_repo.installed] ==
["sys-apps/portage-2.3"]
+ assert [pkg.cpvstr for pkg in config.target_repo.installed] == [
+ "sys-apps/portage-2.3"
+ ]
assert (
config.target_repo.uninstalled == config.target_repo.replaced
), "uninstalled should be the same as replaced; empty"
diff --git a/tests/scripts/test_pquery.py b/tests/scripts/test_pquery.py
index c2e7dc992..c36e9f7c3 100644
--- a/tests/scripts/test_pquery.py
+++ b/tests/scripts/test_pquery.py
@@ -1,8 +1,9 @@
from pkgcore.config import basics
from pkgcore.config.hint import ConfigHint, configurable
-from pkgcore.ebuild import atom
+from pkgcore.ebuild import atom, cpv
from pkgcore.repository import util
from pkgcore.scripts import pquery
+from pkgcore.test.misc import FakePkg
from pkgcore.test.scripts.helpers import ArgParseMixin
@@ -19,7 +20,9 @@ class FakeDomain:
@configurable(typename="repo")
def fake_repo():
- return util.SimpleTree({"spork": {"foon": ("1", "2")}})
+ return util.SimpleTree(
+ {"spork": {"foon": ("1", "2")}}, pkg_klass=FakePkg.for_tree_usage
+ )
@configurable(typename="repo")
@@ -53,10 +56,30 @@ class TestCommandline(ArgParseMixin):
"--all",
)
- def test_no_description(self):
+ def test_missing_metadata(self):
+ simple_repo_config = basics.HardCodedConfigSection(
+ {
+ "class": FakeDomain,
+ "repos": [
+ basics.HardCodedConfigSection(
+ # note we're using a raw CPV; this is to remove all
metadata attributes and force pquery
+ # to display its behaviour for missing.
+ {
+ "class": configurable(typename="repo")(
+ lambda: util.SimpleTree(
+ {"abc": {"def": ["2"]}},
pkg_klass=cpv.VersionedCPV
+ )
+ )
+ }
+ )
+ ],
+ "vdb": [basics.HardCodedConfigSection({"class": fake_vdb})],
+ "default": True,
+ }
+ )
self.assertOut(
[
- " * spork/foon-2",
+ " * abc/def-2",
" repo: MISSING",
" description: MISSING",
" homepage: MISSING",
@@ -66,7 +89,7 @@ class TestCommandline(ArgParseMixin):
"-v",
"--max",
"--all",
- test_domain=domain_config,
+ test_domain=simple_repo_config,
)
def test_atom(self):