def test_saphostcrtl_hana_2(): lssap = Lssap(context_wrap(Lssap_all_TEST)) inst = SAPHostCtrlInstances(context_wrap(SAPHOSTCTRL_HOSTINSTANCES_GOOD)) hn = Hostname(HnF(context_wrap(HOSTNAME1)), None, None, None, None) sap = Sap(hn, inst, lssap) assert 'D50' not in sap assert 'HDB00' in sap assert sorted(sap.local_instances) == sorted( ['HDB88', 'HDB90', 'SMDA91', 'HDB62', 'HDB00']) assert sorted(sap.all_instances) == sorted([ 'ASCS07', 'ASCS52', 'D54', 'DVEBMGS09', 'ERS08', 'HDB00', 'HDB62', 'HDB88', 'HDB90', 'SCS10', 'SMDA91' ]) assert sorted(sap.business_instances) == sorted([ 'ASCS07', 'ASCS52', 'D54', 'DVEBMGS09', 'ERS08', 'HDB00', 'HDB62', 'HDB88', 'HDB90', 'SCS10' ]) assert sorted(sap.function_instances) == sorted(['SMDA91']) assert sap['HDB88'].number == '88' assert sap['HDB90'].hostname == 'li-ld-1810' assert sap['DVEBMGS09'].version == '749, patch 301, changelist 1779613' assert sap.version('HDB90') == '749, patch 211, changelist 1754007' assert sap.hostname('HDB62') == 'd62dbsrv' assert sap.type('SCS10') == 'SCS' assert sap.is_netweaver is True assert sap.is_hana is True assert sap.is_ascs is True
def test_doc_examples(): env = { 'saps': Sap(Hostname(HnF(context_wrap(HOSTNAME)), None, None, None, None), None, Lssap(context_wrap(Lssap_doc_TEST))) } failed, total = doctest.testmod(sap, globs=env) assert failed == 0
def test_lssap_hana(): lssap = Lssap(context_wrap(Lssap_hana_TEST)) hn = Hostname(HnF(context_wrap(HOSTNAME)), None, None, None, None) sap = Sap(hn, None, lssap) assert 'D50' not in sap assert sap.is_netweaver is False assert sap.is_hana is True assert sap.is_ascs is False
def test_lssap_ascs(): lssap = Lssap(context_wrap(Lssap_ascs_TEST)) hn = Hostname(HnF(context_wrap(HOSTNAME)), None, None, None, None) sap = Sap(hn, None, lssap) assert sap['ASCS16'].sid == 'HA2' assert sap.is_netweaver is False assert sap.is_hana is False assert sap.is_ascs is True
def test_all(): lssap = Lssap(context_wrap(Lssap_all_TEST)) hn = Hostname(HnF(context_wrap(HOSTNAME)), None, None, None, None) sap = Sap(hn, None, lssap) assert sap['D16'].version == '749, patch 10, changelist 1698137' assert sap['ASCS16'].hostname == 'lu0417' assert sap.is_netweaver is True assert sap.is_hana is True assert sap.is_ascs is True
def test_get_all_hostname(): hnf = HnF(context_wrap(HOSTNAME_FULL)) hns = HnS(context_wrap(HOSTNAME_SHORT)) hnd = HnD(context_wrap(HOSTNAME_DEF)) sid = SystemID(context_wrap(SYSTEMID_PROFILE_NAME)) expected = (HOSTNAME_FULL, HOSTNAME_SHORT, 'example.com') result = Hostname(hnf, hnd, hns, sid) assert result.fqdn == expected[0] assert result.hostname == expected[1] assert result.domain == expected[2]
def test_r_case(): saphostctrl = SAPHostCtrlInstances( context_wrap(SAPHOSTCTRL_HOSTINSTANCES_R_CASE)) hn = Hostname(HnF(context_wrap(HOSTNAME2)), None, None, None, None) sap = Sap(hn, saphostctrl, None) assert sorted(sap.local_instances) == sorted(['W20', 'SMDA98', 'SMDA97']) assert sap['DVEBMGS12'].version == '753, patch 501, changelist 1967207' assert sap['ASCS10'].hostname == 'r4d01' assert sap.is_netweaver is True assert sap.is_hana is False assert sap.is_ascs is True
def test_lssap_netweaver(): lssap = Lssap(context_wrap(Lssap_nw_TEST)) hn = Hostname(HnF(context_wrap(HOSTNAME)), None, None, None, None) sap = Sap(hn, None, lssap) assert sap['D50'].number == '50' assert 'D16' in sap.local_instances assert 'D51' in sap.all_instances assert 'D51' not in sap.local_instances assert sap.is_netweaver is True assert sap.is_hana is False assert sap.is_ascs is False
def test_hostname_function(): # can be removed once the function being removed hnf = HnF(context_wrap(HOSTNAME_FULL)) hns = HnS(context_wrap(HOSTNAME_SHORT)) hnd = HnD(context_wrap(HOSTNAME_DEF)) sid = SystemID(context_wrap(SYSTEMID_PROFILE_NAME)) expected = (HOSTNAME_FULL, HOSTNAME_SHORT, 'example.com') result = hn_func(hnf, hnd, hns, sid) assert result.fqdn == expected[0] assert result.hostname == expected[1] assert result.domain == expected[2]
def test_hostname_doc(): hnf = HnF(context_wrap(HOSTNAME_FULL)) hns = HnS(context_wrap(HOSTNAME_SHORT)) hnd = HnD(context_wrap(HOSTNAME_DEF)) sid = SystemID(context_wrap(SYSTEMID_PROFILE_NAME)) env = { 'hostname': Hostname(hnf, hnd, hns, sid), 'hn': hn_func(hnf, hnd, hns, sid) } failed, total = doctest.testmod(hostname, globs=env) assert failed == 0
def test_saphostcrtl_hana(): lssap = Lssap(context_wrap(Lssap_nw_TEST)) inst = SAPHostCtrlInstances(context_wrap(SAPHOSTCTRL_HOSTINSTANCES)) hn = Hostname(HnF(context_wrap(HOSTNAME)), None, None, None, None) sap = Sap(hn, inst, lssap) assert 'D50' not in sap assert sap.local_instances == ['HDB88'] assert 'HDB90' in sap.all_instances assert sap['HDB88'].number == '88' assert sap['HDB90'].hostname == 'lu0418' assert sap['HDB90'].version == '749, patch 211, changelist 1754007' assert sap.number('HDB90') == '90' assert sap.sid('HDB88') == 'D89' assert sap.is_netweaver is False assert sap.is_hana is True assert sap.is_ascs is False
def test_get_hostname(): hnf = HnF(context_wrap(HOSTNAME_FULL)) expected = (HOSTNAME_FULL, HOSTNAME_SHORT, 'example.com') result = Hostname(hnf, None, None, None) assert result.fqdn == expected[0] assert result.hostname == expected[1] assert result.domain == expected[2] hns = HnS(context_wrap(HOSTNAME_SHORT)) expected = (HOSTNAME_SHORT, HOSTNAME_SHORT, '') result = Hostname(None, None, hns, None) assert result.fqdn == expected[0] assert result.hostname == expected[1] assert result.domain == expected[2] hnd = HnD(context_wrap(HOSTNAME_DEF)) expected = (HOSTNAME_DEF, HOSTNAME_DEF, '') result = Hostname(None, hnd, None, None) assert result.fqdn == expected[0] assert result.hostname == expected[1] assert result.domain == expected[2]
def test_ab(): hn = Hostname(HnF(context_wrap(HOSTNAME)), None, None, None, None) with pytest.raises(SkipComponent) as se: Sap(hn, None, None) assert 'No SAP instance.' in str(se)