def test_get_questions(): src = 'test_data/ssg-fedora-ds-arf.xml' regex = r'_package_\w+_removed' client = get_client(src, regex) out = client.get_questions()[0].choices rule1 = 'xccdf_org.ssgproject.content_rule_package_abrt_removed' rule2 = 'xccdf_org.ssgproject.content_rule_package_sendmail_removed' assert out[0] == rule1 assert out[1] == rule2
def test_get_questions_with_option_show_fail_rules(): src = 'test_data/ssg-fedora-ds-arf.xml' regex = r'_package_\w+_removed' client = get_client_with_option_show_fail_rules(src, regex) out = client.get_questions()[0].choices rule1 = 'xccdf_org.ssgproject.content_rule_package_abrt_removed' assert out[0] == rule1 with pytest.raises(Exception, match="list index out of range"): assert out[2] is None
def test_get_questions(): src = 'test_data/ssg-fedora-ds-arf.xml' regex = r'_package_\w+_removed' client = get_client(src, regex) from PyInquirer import Separator out = client.get_questions(Separator('= The rules ID ='), Separator('= The not selected rules ID =')) rule1 = 'xccdf_org.ssgproject.content_rule_package_abrt_removed' rule2 = 'xccdf_org.ssgproject.content_rule_package_sendmail_removed' assert out[0]['choices'][1]['name'] == rule1 assert out[0]['choices'][2]['name'] == rule2
def test_get_questions_with_option_show_fail_rules(): src = 'test_data/ssg-fedora-ds-arf.xml' regex = r'_package_\w+_removed' client = get_client_with_option_show_fail_rules(src, regex) from PyInquirer import Separator out = client.get_questions(Separator('= The rules ID ='), Separator('= The not selected rules ID =')) rule1 = 'xccdf_org.ssgproject.content_rule_package_abrt_removed' assert out[0]['choices'][1]['name'] == rule1 with pytest.raises(Exception, match="list index out of range"): assert out[0]['choices'][2]['name'] is None
def test_get_questions_not_selected(): src = 'test_data/ssg-fedora-ds-arf.xml' regex = r'_package_\w+_removed' client = get_client_with_option_show_not_selected_rules(src, regex) from PyInquirer import Separator out = client.get_questions(Separator('= The rules ID ='), Separator('= The not selected rules ID =')) rule1 = 'xccdf_org.ssgproject.content_rule_package_setroubleshoot_removed' rule2 = 'xccdf_org.ssgproject.content_rule_package_mcstrans_removed' assert out[0]['choices'][-2]['name'] == rule1 assert out[0]['choices'][-1]['name'] == rule2
def test_get_questions_not_selected(capsys): src = 'test_data/ssg-fedora-ds-arf.xml' regex = r'_package_\w+_removed' client = get_client_with_option_show_not_selected_rules(src, regex) out = client.get_questions()[0].choices outResult = [ 'xccdf_org.ssgproject.content_rule_package_abrt_removed', 'xccdf_org.ssgproject.content_rule_package_sendmail_removed'] assert out == outResult captured = capsys.readouterr() assert captured.out == ( '== The not selected rule IDs ==\n' 'xccdf_org.ssgproject.content_rule_package_nis_removed(Not selected)\n' 'xccdf_org.ssgproject.content_rule_package_ntpdate_removed(Not selected)\n' 'xccdf_org.ssgproject.content_rule_package_telnetd_removed(Not selected)\n' 'xccdf_org.ssgproject.content_rule_package_gdm_removed(Not selected)\n' 'xccdf_org.ssgproject.content_rule_package_setroubleshoot_removed(Not selected)\n' 'xccdf_org.ssgproject.content_rule_package_mcstrans_removed(Not selected)\n')