def test_get_tenant_ok(requests_mock): uri = 'mo/uni/tn-common.json' requests_mock.post(f'https://{__BASE_URL}/api/aaaLogin.json', json={'imdata': [ {'aaaLogin': {'attributes': {'token': 'tokenxyz'}}} ]}) requests_mock.get(f'https://{__BASE_URL}/api/{uri}', json={'imdata': [{'fvTenant': {'attributes': {'annotation': '', 'childAction': '', 'descr': '', 'dn': 'uni/tn-common', 'extMngdBy': '', 'lcOwn': 'local', 'modTs': '2020-11-23T15:53:52.014+00:00', 'monPolDn': 'uni/tn-common/monepg-default', 'name': 'common', 'nameAlias': '', 'ownerKey': '', 'ownerTag': '', 'status': '', 'uid': '0'}}}] }) aci = ACI(apicIp=__BASE_URL, apicUser='******', apicPasword='unkown') aci.login() resp = aci.getJson(uri) assert 'fvTenant' in resp[0]
def test_get_tenant_not_found(requests_mock): uri = 'mo/uni/tn-commmmmon.json' requests_mock.post(f'https://{__BASE_URL}/api/aaaLogin.json', json={'imdata': [ {'aaaLogin': {'attributes': {'token': 'tokenxyz'}}} ]}) requests_mock.get(f'https://{__BASE_URL}/api/{uri}', json={'error': 'Not found'}, status_code=404) aci = ACI(apicIp=__BASE_URL, apicUser='******', apicPasword='unkown') aci.login() resp = aci.getJson(uri) assert 'error' in resp