def test_systemctl_show_doc_examples():
    env = {
        'systemctl_show_all':
        SystemctlShowServiceAll(context_wrap(SYSTEMCTL_SHOW_ALL_EXAMPLES)),
        'systemctl_show_target':
        SystemctlShowTarget(context_wrap(SYSTEMCTL_SHOW_TARGET)),
        # TODO: Remove the following test when removing the deprecated parsers.
        'systemctl_show_cinder_volume':
        SystemctlShowCinderVolume(context_wrap(SYSTEMCTL_SHOW_EXAMPLES)),
        'systemctl_show_mariadb':
        SystemctlShowMariaDB(context_wrap(SYSTEMCTL_SHOW_EXAMPLES)),
        'systemctl_show_pulp_workers':
        SystemctlShowPulpWorkers(context_wrap(SYSTEMCTL_SHOW_EXAMPLES)),
        'systemctl_show_pulp_resource_manager':
        SystemctlShowPulpResourceManager(
            context_wrap(SYSTEMCTL_SHOW_EXAMPLES)),
        'systemctl_show_pulp_celerybeat':
        SystemctlShowPulpCelerybeat(context_wrap(SYSTEMCTL_SHOW_EXAMPLES)),
        'systemctl_show_httpd':
        SystemctlShowHttpd(context_wrap(SYSTEMCTL_SHOW_EXAMPLES)),
        'systemctl_show_qpidd':
        SystemctlShowQpidd(context_wrap(SYSTEMCTL_SHOW_EXAMPLES)),
        'systemctl_show_qdrouterd':
        SystemctlShowQdrouterd(context_wrap(SYSTEMCTL_SHOW_EXAMPLES)),
        'systemctl_show_smartpdc':
        SystemctlShowSmartpdc(context_wrap(SYSTEMCTL_SHOW_EXAMPLES)),
        'systemctl_show_nginx':
        SystemctlShowNginx(context_wrap(SYSTEMCTL_SHOW_EXAMPLES))
    }
    failed, total = doctest.testmod(systemctl_show, globs=env)
    assert failed == 0
def test_systemctl_show_service_all():
    svc_all = SystemctlShowServiceAll(
        context_wrap(SYSTEMCTL_SHOW_ALL_EXAMPLES))
    assert len(svc_all) == 3

    assert 'postfix.service' in svc_all
    assert 'LimitMEMLOCK' not in svc_all['postfix.service']
    assert svc_all['postfix.service']["LimitNOFILE"] == "65536"
    assert svc_all['postfix.service']["KillSignal"] == "15"
    assert svc_all['postfix.service']["LimitLOCKS"] == "18446744073709551615"
    assert len(svc_all['postfix.service']) == 10

    assert 'postgresql.service' in svc_all
    assert svc_all['postgresql.service']["User"] == "postgres"
    assert svc_all['postgresql.service'][
        "ControlGroup"] == "/system.slice/postgresql.service"
    assert len(svc_all['postgresql.service']) == 28

    assert 'tuned.service' in svc_all
    assert svc_all['tuned.service']["Id"] == "tuned.service"
    assert svc_all['tuned.service']["Transient"] == "no"
    assert "ABC" not in svc_all['tuned.service']
    assert len(svc_all['tuned.service']) == 44
def test_systemctl_show_service_all_ab():
    with pytest.raises(SkipException):
        SystemctlShowServiceAll(context_wrap(''))

    with pytest.raises(ParseException):
        SystemctlShowServiceAll(context_wrap(SYSTEMCTL_SHOW_ALL_EXP))