Skip to content

Commit

Permalink
Improve tests to cover all search filters
Browse files Browse the repository at this point in the history
  • Loading branch information
negillett committed Nov 11, 2019
1 parent 107cadf commit 341ccfd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/repository/test_search_content.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pubtools.pulplib import Repository, DetachedException, RpmUnit, ModulemdUnit
from pubtools.pulplib import Repository, DetachedException


def test_detached():
Expand All @@ -26,6 +26,7 @@ def __init__(self, requests_mocker, client):
"_content_type_id": "srpm",
"name": "bash",
"epoch": "0",
"filename": "bash-x86_64.srpm",
"version": "4.0",
"release": "1",
"arch": "x86_64",
Expand All @@ -34,6 +35,7 @@ def __init__(self, requests_mocker, client):
"_content_type_id": "rpm",
"name": "bash",
"epoch": "0",
"filename": "bash-x86_64.rpm",
"version": "4.0",
"release": "1",
"arch": "x86_64",
Expand Down Expand Up @@ -68,14 +70,22 @@ def test_search_content(self):
assert sorted(units)[2].content_type_id == "rpm"
assert sorted(units)[3].content_type_id == "srpm"

def test_search_matched_content(self):
def test_search_modulemd_content(self):
"""search_content gets only matching content from the repository"""
units_f = self.repo.search_content(arch="s390x", stream="s1")
units = [unit for unit in units_f.result().as_iter()]

assert len(units) == 1
assert units[0].content_type_id == "modulemd"

def test_search_rpm_content(self):
"""search_content gets only matching content from the repository"""
units_f = self.repo.search_content(name="bash", filename="bash-x86_64.rpm")
units = [unit for unit in units_f.result().as_iter()]

assert len(units) == 1
assert units[0].content_type_id == "rpm"

def test_search_no_matched_content(self):
"""search_content gets no matching content from the repository"""
units_f = self.repo.search_content(name="hello.txt")
Expand Down

0 comments on commit 341ccfd

Please sign in to comment.