コード例 #1
0
def test_pcp_enabled():
    unitfiles = UnitFiles(context_wrap(LIST_UNIT_FILES))
    services = Services(None, unitfiles)
    broker = dr.Broker()
    broker[Services] = services

    result = pcp_enabled(broker)
    assert result is True

    unitfiles = UnitFiles(context_wrap(LIST_UNIT_FILES_no_pmproxy))
    services = Services(None, unitfiles)
    broker = dr.Broker()
    broker[Services] = services

    with pytest.raises(SkipComponent):
        pcp_enabled(broker)
コード例 #2
0
def test_unitfiles_doc_examples():
    env = {
        'conf': UnitFiles(context_wrap(UNITFILES_DOCTEST)),
        'units': ListUnits(context_wrap(LISTUNITS_DOCTEST)),
    }
    failed, total = doctest.testmod(unitfiles, globs=env)
    assert failed == 0
コード例 #3
0
def test_unitfiles():
    context = context_wrap(KDUMP_DISABLED_RHEL7)
    unitfiles = UnitFiles(context)
    assert not unitfiles.is_on('kdump.service')
    assert len(unitfiles.services) == 1
    assert len(unitfiles.parsed_lines) == 1

    context = context_wrap(KDUMP_ENABLED_RHEL7)
    unitfiles = UnitFiles(context)
    assert unitfiles.is_on('kdump.service')
    assert len(unitfiles.services) == 1
    assert len(unitfiles.parsed_lines) == 1

    context = context_wrap(KDUMP_ENABLED_RHEL7)
    unitfiles = UnitFiles(context)
    assert unitfiles.is_on('kdump.service')
    assert len(unitfiles.services) == 1
    assert len(unitfiles.parsed_lines) == 1

    context = context_wrap(KDUMP_BIG_TEST)
    unitfiles = UnitFiles(context)
    assert unitfiles.is_on('kdump.service')
    assert not unitfiles.is_on('other.service')
    assert unitfiles.is_on('test.service')
    assert len(unitfiles.services) == 3
    assert len(unitfiles.parsed_lines) == 3

    context = context_wrap(UNIT_INVALID_VS_VALID)
    unitfiles = UnitFiles(context)
    assert unitfiles.is_on('svca.service')
    assert 'svca.service' in unitfiles.services
    assert 'svca.service' in unitfiles.service_list
    assert 'svcb.service' in unitfiles.services
    assert 'svcb.service' in unitfiles.service_list
    assert 'svcc.service' not in unitfiles.services
    assert 'svcc.service' not in unitfiles.service_list
    assert True is unitfiles.is_on('svca.service')
    assert False is unitfiles.is_on('svcb.service')
    assert None is unitfiles.is_on('svcc.service')
    assert unitfiles.exists('svca.service')
    assert unitfiles.exists('svcb.service')
    assert not unitfiles.exists('svcc.service')
コード例 #4
0
def test_unitfile_NG():
    with pytest.raises(SkipException):
        UnitFiles(context_wrap(UNITFILES_NG))

    with pytest.raises(SkipException):
        ListUnits(context_wrap(LISTUNITS_NG))