def test_renew_cookie_exception(requests_mock): requests_mock.post(f'https://{__BASE_URL}/api/aaaLogin.json', json={'imdata': [ {'aaaLogin': {'attributes': {'token': 'tokenxyz'}}} ]}) requests_mock.post(f'https://{__BASE_URL}/api/aaaRefresh.json', json={'status_code': 401, 'text': 'Not Allowed'}, status_code=401) aci = ACI(apicIp=__BASE_URL, apicUser='******', apicPasword='unkown') aci.login() with pytest.raises(RequestException): aci.renewCookie()
def test_renew_cookie_ok(requests_mock): requests_mock.post(f'https://{__BASE_URL}/api/aaaLogin.json', json={'imdata': [ {'aaaLogin': {'attributes': {'token': 'tokenxyz'}}} ]}) requests_mock.post(f'https://{__BASE_URL}/api/aaaRefresh.json', json={'imdata': [ {'aaaLogin': {'attributes': {'token': 'tokenxyz'}}} ]}, status_code=200) aci = ACI(apicIp=__BASE_URL, apicUser='******', apicPasword='unkown') aci.login() assert aci.renewCookie()