예제 #1
0
def test_fail():
    with pytest.raises(ParseException) as excinfo:
        lssap.Lssap(context_wrap(Lssap_BAD_1))
    assert "Lssap: Unable to parse 1 line(s) of content: (['/usr/sap/hostctrl/lssap: command or file not found'])" in str(
        excinfo)

    with pytest.raises(ParseException) as excinfo:
        lssap.Lssap(context_wrap(Lssap_BAD_2))
    assert "Lssap: Unable to parse 1 line(s) of content: (['HA2 | N16|  D16'])" in str(
        excinfo)

    with pytest.raises(ParseException) as excinfo:
        lssap.Lssap(context_wrap(Lssap_BAD_3))
    assert "Lssap: Unable to parse 2 line(s) of content: (['HA2 | N16 | D16', 'HB2 | foo | bar'])" in str(
        excinfo)

    with pytest.raises(ParseException) as excinfo:
        lssap.Lssap(context_wrap(Lssap_BAD1))
    assert "Lssap: Unable to parse 1 line(s) of content: (['HA2|  16|       D16|         lu0417'])" in str(
        excinfo)

    with pytest.raises(SkipException) as excinfo:
        lssap.Lssap(context_wrap(Lssap_BAD2))

    with pytest.raises(ParseException) as excinfo:
        lssap.Lssap(context_wrap('test'))
    assert "Lssap: Unable to parse 1 line(s) of content: (['test'])" in str(
        excinfo)
예제 #2
0
def test_lssap_hana():
    sap = lssap.Lssap(context_wrap(Lssap_hana_TEST))
    data = sap.data
    assert data[0] == {
        "SID": "HA2",
        "Nr": "16",
        "Instance": "HDB16",
        "SAPLOCALHOST": "lu0417",
        "Version": "749, patch 10, changelist 1698137",
        "DIR_EXECUTABLE": "/usr/sap/HA2/HDB16/exe"
    }
    assert data[0]["SAPLOCALHOST"] == "lu0417"
    assert sap.is_hana() is True
    assert sap.is_netweaver() is False
    assert sap.is_ascs() is False
예제 #3
0
def test_all():
    sap = lssap.Lssap(context_wrap(Lssap_runAll_Test))
    assert sap.sid == ['DA1', 'DAA', 'HA2', 'MEP', 'MHP']
    assert sap.instances == [
        'D16', 'D22', 'HDB16', 'ASCS16', 'SMDA97', 'SMDA98', 'HDB00', 'ASCS02',
        'DVEBMGS01'
    ]
    assert sap.data[1] == {
        "SID": "HA2",
        "Nr": "22",
        "Instance": "D22",
        "SAPLOCALHOST": "lu0417",
        "Version": "749, patch 10, changelist 1698137",
        "DIR_EXECUTABLE": "/usr/sap/HA2/D22/exe"
    }
    assert sap.is_netweaver() is True
    assert sap.is_hana() is True
    assert sap.is_ascs() is True
    assert 'SMDA' in sap.instance_types
    assert 'DVEBMGS01' in sap.instances
    assert sap.version("D16") == "749, patch 10, changelist 1698137"
    assert sap.version("D06") is None
예제 #4
0
def test_doc_examples():
    env = {'lssap': lssap.Lssap(context_wrap(Lssap_nw_TEST))}
    failed, total = doctest.testmod(lssap, globs=env)
    assert failed == 0
예제 #5
0
def test_lssap_ascs():
    sap = lssap.Lssap(context_wrap(Lssap_ascs_TEST))
    assert sap.is_hana() is False
    assert sap.is_netweaver() is False
    assert sap.is_ascs() is True
예제 #6
0
def test_valid_extra_lines():
    sap = lssap.Lssap(context_wrap(Lssap_extra_lines))
    assert sap is not None