aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrian Harring <ferringb@gmail.com>2023-11-20 19:45:24 -0800
committerArthur Zamarin <arthurzam@gentoo.org>2023-12-03 07:18:39 +0200
commit7302780b25f4ad51959b0ba28801701abcf6d3c0 (patch)
treec05644f49562e53fe1446ad10f40fee84385cad5 /tests
parentcleanup: Replace fake_pkg with common mock (diff)
downloadpkgcore-7302780b25f4ad51959b0ba28801701abcf6d3c0.tar.gz
pkgcore-7302780b25f4ad51959b0ba28801701abcf6d3c0.tar.bz2
pkgcore-7302780b25f4ad51959b0ba28801701abcf6d3c0.zip
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@gmail.com> Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/scripts/test_pmaint.py8
-rw-r--r--tests/scripts/test_pquery.py33
2 files changed, 34 insertions, 7 deletions
diff --git a/tests/scripts/test_pmaint.py b/tests/scripts/test_pmaint.py
index 2cdb3009..b4dc48ce 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 c2e7dc99..c36e9f7c 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):