diff --git a/tests/fake/test_fake_search_all_content.py b/tests/fake/test_fake_search_all_content.py index 4861e770..652ddab8 100644 --- a/tests/fake/test_fake_search_all_content.py +++ b/tests/fake/test_fake_search_all_content.py @@ -1,13 +1,13 @@ import pytest from pubtools.pulplib import ( - FakeController, Criteria, - RpmUnit, - ModulemdUnit, + FakeController, ModulemdDefaultsUnit, - YumRepository, + ModulemdUnit, PulpException, + RpmUnit, + YumRepository, ) @@ -41,6 +41,9 @@ def populated_units(controller): arch="x86_64", repository_memberships=["repo1"], ), + RpmUnit( + name="jq", version="4.0", release="1", arch="x86_64", files=["/some/file"] + ), ModulemdUnit( name="module1", stream="s1", @@ -101,12 +104,12 @@ def test_search_content_all(populated_units, controller): ).result() ] units3 = [u for u in controller.client.search_content().result()] - assert len(units1) == 3 - assert len([u for u in units1 if u.content_type_id == "rpm"]) == 3 + assert len(units1) == 4 + assert len([u for u in units1 if u.content_type_id == "rpm"]) == 4 assert len(units2) == 2 assert len([u for u in units2 if u.content_type_id == "srpm"]) == 2 # + two modulemd, one modulemd_defaults - assert len(units3) == 8 + assert len(units3) == 9 assert set(sum([u.repository_memberships for u in units1], [])) == set( ["repo1", "repo2"] @@ -150,12 +153,12 @@ def test_search_content_all_pagination(populated_units, controller): ).result() ] units3 = [u for u in controller.client.search_content().result()] - assert len(units1) == 3 - assert len([u for u in units1 if u.content_type_id == "rpm"]) == 3 + assert len(units1) == 4 + assert len([u for u in units1 if u.content_type_id == "rpm"]) == 4 assert len(units2) == 2 assert len([u for u in units2 if u.content_type_id == "srpm"]) == 2 # + two modulemd, one modulemd_defaults - assert len(units3) == 8 + assert len(units3) == 9 assert set(sum([u.repository_memberships for u in units1], [])) == set( ["repo1", "repo2"] diff --git a/tests/fake/test_fake_search_content.py b/tests/fake/test_fake_search_content.py index d28b844d..a97efa94 100644 --- a/tests/fake/test_fake_search_content.py +++ b/tests/fake/test_fake_search_content.py @@ -1,14 +1,14 @@ import pytest from pubtools.pulplib import ( - FakeController, Criteria, - Matcher, - RpmUnit, ErratumUnit, + FakeController, + Matcher, ModulemdUnit, - YumRepository, RpmDependency, + RpmUnit, + YumRepository, ) @@ -32,6 +32,13 @@ def populated_repo(controller): sourcerpm="glibc-5.0-1.el5_11.1.src.rpm", provides=[RpmDependency(name="gcc")], ), + RpmUnit( + name="jq", + version="4.0", + release="1", + arch="x86_64", + files=["/some/file", "/another/file", "/yet/another/file", "/script"], + ), ModulemdUnit( name="module1", stream="s1", version=1234, context="a1b2", arch="x86_64" ), @@ -91,7 +98,7 @@ def test_search_content_default_crit(populated_repo): """search_content with default criteria on populated repo finds all units""" units = list(populated_repo.search_content()) - assert len(units) == 6 + assert len(units) == 7 def test_search_content_by_type(populated_repo): @@ -118,6 +125,15 @@ def test_search_content_by_type(populated_repo): repository_memberships=["repo1"], provides=[RpmDependency(name="gcc")], ), + RpmUnit( + name="jq", + version="4.0", + release="1", + arch="x86_64", + repository_memberships=["repo1"], + unit_id="23a7711a-8133-2876-37eb-dcd9e87a1613", + files=["/some/file", "/another/file", "/yet/another/file", "/script"], + ), ] @@ -156,6 +172,14 @@ def test_search_content_with_fields(populated_repo): arch="x86_64", repository_memberships=["repo1"], ), + RpmUnit( + name="jq", + version="4.0", + release="1", + arch="x86_64", + repository_memberships=["repo1"], + unit_id="23a7711a-8133-2876-37eb-dcd9e87a1613", + ), ] @@ -166,7 +190,7 @@ def test_search_erratum_by_type(populated_repo): units = list(populated_repo.search_content(crit)) assert units == [ ErratumUnit( - unit_id="85776e9a-dd84-f39e-7154-5a137a1d5006", + unit_id="d71037d1-b83e-90ec-17e0-aa3c03983ca8", id="RHBA-1234:56", summary="The best advisory", repository_memberships=["repo1"], @@ -207,7 +231,7 @@ def test_search_content_by_unit_type(populated_repo): units = list(populated_repo.search_content(crit)) assert sorted(units) == [ ModulemdUnit( - unit_id="23a7711a-8133-2876-37eb-dcd9e87a1613", + unit_id="e6f4590b-9a16-4106-cf6a-659eb4862b21", name="module1", stream="s1", version=1234, @@ -216,7 +240,7 @@ def test_search_content_by_unit_type(populated_repo): repository_memberships=["repo1"], ), ModulemdUnit( - unit_id="e6f4590b-9a16-4106-cf6a-659eb4862b21", + unit_id="85776e9a-dd84-f39e-7154-5a137a1d5006", name="module2", stream="s2", version=1234, @@ -239,7 +263,7 @@ def test_search_content_mixed_fields(populated_repo): # Note: sorting different types not natively supported, hence sorting by repr assert sorted(units, key=repr) == [ ModulemdUnit( - unit_id="23a7711a-8133-2876-37eb-dcd9e87a1613", + unit_id="e6f4590b-9a16-4106-cf6a-659eb4862b21", name="module1", stream="s1", version=1234, @@ -266,7 +290,7 @@ def test_search_content_subfields(populated_repo): crit = Criteria.and_( Criteria.with_unit_type(RpmUnit), Criteria.with_field("provides.name", "gcc") ) - units = list(populated_repo.search_content(crit)) + units = list(populated_repo.search_content(crit).result()) assert units == [ RpmUnit( @@ -280,3 +304,26 @@ def test_search_content_subfields(populated_repo): repository_memberships=["repo1"], ) ] + + +def test_search_content_files(populated_repo): + """ + search_content using files subfield in attributes that are lists of strings. + """ + crit = Criteria.and_( + Criteria.with_unit_type(RpmUnit), + Criteria.with_field("files", "/some/file"), + ) + units = list(populated_repo.search_content(crit).result()) + + assert units == [ + RpmUnit( + name="jq", + version="4.0", + release="1", + arch="x86_64", + repository_memberships=["repo1"], + unit_id="23a7711a-8133-2876-37eb-dcd9e87a1613", + files=["/some/file", "/another/file", "/yet/another/file", "/script"], + ) + ]