Skip to content

Commit

Permalink
Add test to filter facts using a regex
Browse files Browse the repository at this point in the history
Closes #37
  • Loading branch information
elyezer committed Oct 3, 2017
1 parent abdbcaf commit 527c205
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions camayoc/tests/rho/test_fact.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,33 @@ def test_fact_list_filter():
assert rho_fact_list.exitstatus == 0


def test_fact_list_regex_filter():
"""Use a regex to filter the list of available facts.
:id: c4843f39-5c16-4154-9221-5e222fb6e4d5
:description: Filter the list of available facts by providing the
``--filter`` option with a regular expression as a value.
:steps: Run ``rho fact list --filter <regex_filter>``
:expectedresults: Only the facts that match the regex filter are printed.
"""
expected_facts = (
'subman.virt.host_type',
'virt-what.type',
'virt.type',
)
rho_fact_list = pexpect.spawn(
'rho fact list --filter {}'.format(r'"[\w.-]+type"'))
rho_fact_list.logfile = BytesIO()
rho_fact_list.expect(pexpect.EOF)
output = rho_fact_list.logfile.getvalue().decode('utf-8')
rho_fact_list.logfile.close()
rho_fact_list.close()
assert rho_fact_list.exitstatus == 0

facts = [line.split(' - ')[0].strip() for line in output.splitlines()]
assert sorted(facts) == sorted(expected_facts)


def test_fact_hash(isolated_filesystem):
"""Hash some facts from a generated report.
Expand Down

0 comments on commit 527c205

Please sign in to comment.