def test_multi_line(): assert MULTI_LINE.split('\n') == MockParser(context_wrap(MULTI_LINE)).data
def test_doc_examples(): env = {"rpm_v_packages": RpmVPackages(context_wrap(TEST_RPM))} failed, total = doctest.testmod(rpm_v_packages, globs=env) assert failed == 0
def test_no_such_file_or_directory(): with pytest.raises(ContentException) as e: MockParser(context_wrap(NO_SUCH_FILE)) assert "No such file or directory" in str(e.value)
def test_missing_version(): context = context_wrap(TEST_ETHTOOL_I_MISSING_KEYS) parsed = ethtool.Driver(context) assert parsed.version is None
def test_iface(): context = context_wrap(TEST_ETHTOOL_I_GOOD, path="sbin/ethtool_-i_eth0") parsed = ethtool.Driver(context) assert parsed.ifname == "eth0"
def test_get_ethtool_c_bad_args(): context = context_wrap(TEST_ETHTOOL_C_BAD_ARGS, path='sos_commands/networking/ethtool_-c_eth0') result = ethtool.CoalescingInfo(context) assert result.ifname == 'eth0'
def test_ethtool_g_1(): context = context_wrap(TEST_ETHTOOL_G_1) context.path = TEST_ETHTOOL_G_PATH_1 result = ethtool.Ring(context) assert result.ifname == "bond0.102@bond0"
def test_neutron_l3_agent_ini(): nla_ini = NeutronL3AgentIni(context_wrap(L3_AGENT_INI)) assert nla_ini.has_option("AGENT", "log_agent_heartbeats") assert nla_ini.get("DEFAULT", "agent_mode") == "dvr" assert nla_ini.getint("DEFAULT", "metadata_port") == 9697
def test_grub2_default_index_1(): res = GrubbyDefaultIndex(context_wrap(DEFAULT_INDEX_1)) assert res.default_index == 0 res = GrubbyDefaultIndex(context_wrap(DEFAULT_INDEX_2)) assert res.default_index == 1
def test_sysconfig_doc(): env = { 'chronyd_syscfg': ChronydSysconfig(context_wrap(CHRONYDSYSCONFIG)), 'ntpd_syscfg': NtpdSysconfig(context_wrap(NTPDSYSCONFIG)), 'docker_syscfg': DockerSysconfig(context_wrap(DOCKERSYSCONFIG)), 'httpd_syscfg': HttpdSysconfig(context_wrap(HTTPDSYSCONFIG)), 'irqb_syscfg': IrqbalanceSysconfig(context_wrap(IRQBALANCESYSCONFIG)), 'vwho_syscfg': VirtWhoSysconfig(context_wrap(VIRTWHOSYSCONFIG)), 'mongod_syscfg': MongodSysconfig(context_wrap(MONGODSYSCONFIG)), 'memcached_syscfg': MemcachedSysconfig(context_wrap(MEMCACHEDSYSCONFIG)), 'libvirt_guests_syscfg': LibvirtGuestsSysconfig(context_wrap(LIBVIRTGUESTSSYSCONFIG)), 'prelink_syscfg': PrelinkSysconfig(context_wrap(PRELINKSYSCONFIG)), 'u2d_syscfg': Up2DateSysconfig(context_wrap(UP2DATESYSCONFIG)), 'netcs_syscfg': NetconsoleSysconfig(context_wrap(NETCONSOLESYSCONFIG)), 'pps_syscfg': PuppetserverSysconfig(context_wrap(PUPPETSERVERCONFIG)), 'ft_syscfg': ForemanTasksSysconfig(context_wrap(FOREMANTASKSYSCONFG)), 'dss_syscfg': DockerStorageSetupSysconfig(context_wrap(DOCKERSTORAGESETUPSYSCONFG)), 'dirsrv_syscfg': DirsrvSysconfig(context_wrap(DIRSRVSYSCONFG)), 'cs_syscfg': CorosyncSysconfig(context_wrap(COROSYNCSYSCONFIG)), } failed, total = doctest.testmod(sysconfig, globs=env) assert failed == 0
def test_doc(): env = {"l3_agent_ini": NeutronL3AgentIni(context_wrap(L3_AGENT_INI, path="/etc/neutron/l3_agent.ini"))} failed, total = doctest.testmod(neutron_l3_agent_conf, globs=env) assert failed == 0
def test_ipcs_mp(): shm = IpcsMP(context_wrap(IPCS_M_P)) assert '1' in shm assert '1074' not in shm assert shm.get('1').get('cpid') == '1105'
def test_ipcs_m(): shm = IpcsM(context_wrap(IPCS_M)) assert '1' in shm assert '0' in shm assert '11074' not in shm assert shm.get('0').get('bytes') == '37879808'
def test_ipcs_si(): sem = IpcsSI(context_wrap(IPCS_S_I)) assert sem.semid == '65536' assert sem.pid_list == ['0', '2265', '4390', '6151', '6152']
def test_ethtool_a_blank_line(): context = context_wrap(SUCCESS_ETHTOOL_A_BLANK_LINE, path=SUCCESS_ETHTOOL_A_PATH) result = ethtool.Pause(context) assert result.ifname == "enp0s25"
def test_getsebool(): result = getsebool.Getsebool(context_wrap(GETSEBOOL)) assert result["varnishd_connect_any"] == 'off' assert result["virt_use_nfs"] == 'on' assert "virt_use_xserver" in result assert "not_exist_key" not in result
def test_get_ethtool_c_cannot_get(): context = context_wrap(TEST_ETHTOOL_C_CANNOT_GET) context.path = 'sos_commands/networking/ethtool_-c_usb0' result = ethtool.CoalescingInfo(context) assert result.ifname == 'usb0'
def test_getsebool_disabled(): with pytest.raises(SkipException) as excinfo: getsebool.Getsebool(context_wrap(SELINUX_DISABLED)) assert 'SELinux is disabled' in str(excinfo.value)
def test_get_ethtool_c_short(): context = context_wrap(TEST_ETHTOOL_C_SHORT, path=TEST_ETHTOOL_C_PATH) with pytest.raises(ParseException) as exc: ethtool.CoalescingInfo(context) assert 'Command output missing value data' in str(exc)
def test_checkin_conf(): resault = CheckinConf(context_wrap(CONFIG)) assert resault.sections() == ['logging', 'spacewalk', 'katello'] assert resault.get('spacewalk', 'host') == ''
def test_ethtool_g_2(): context = context_wrap(TEST_ETHTOOL_G_2, path=TEST_ETHTOOL_G_PATH_2) result = ethtool.Ring(context) assert result.ifname == "eth2"
def test_vsftpd_conf(): vsftpd_conf = VsftpdConf(context_wrap(VSFTPD_CONF)) assert vsftpd_conf.get('anonymous_enable') == 'NO' assert vsftpd_conf.get('local_enable') == 'YES' assert vsftpd_conf.get('write_enable') == 'YES' assert 'Commented_option' not in vsftpd_conf
def test_missing_value(): context = context_wrap(TEST_ETHTOOL_I_GOOD) parsed = ethtool.Driver(context) assert parsed.firmware_version is None
def test_command_not_found(): with pytest.raises(ContentException) as e: MockParser(context_wrap(CMF)) assert "Command not found" in str(e.value)
def test_no_iface(): context = context_wrap(TEST_ETHTOOL_I_GOOD, path="foo/bar/baz/oopsie") parsed = ethtool.Driver(context) assert parsed.ifname is None
def test_rpm_empty(): rpm_pkgs = RpmVPackages(context_wrap([])) assert rpm_pkgs.packages_list == []