X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=tests%2Ftest_controller.py;h=bbfe9969ccf9a13f74059ff125ef0062dd7f86b1;hb=0e3bc64f93a316e49bbdeb047e7592840207231d;hp=833fc6ef64e60ff74c2aefcf12cc86994b26d165;hpb=ccb4a69e473cab6db7e8d52a04f9b4922528e24f;p=ric-plt%2Fa1.git diff --git a/tests/test_controller.py b/tests/test_controller.py index 833fc6e..bbfe996 100644 --- a/tests/test_controller.py +++ b/tests/test_controller.py @@ -20,8 +20,9 @@ tests for controller import time import json from rmr.rmr_mocks import rmr_mocks +from ricsdl.syncstorage import SyncStorage +from ricsdl.exceptions import RejectedByBackend, NotConnected, BackendError from a1 import a1rmr, data -from .a1test_helpers import MockSDLWrapper RCV_ID = "test_receiver" ADM_CRTL_TID = 6660666 @@ -231,7 +232,7 @@ def _verify_instance_and_status(client, expected_instance, expected_status, expe def setup_module(): """module level setup""" - data.SDL = MockSDLWrapper() # patch SDL + data.SDL.sdl = SyncStorage(fake_db_backend="dict") def noop(): pass @@ -349,6 +350,18 @@ def test_bad_instances(client, monkeypatch, adm_type_good): assert res.status_code == 204 # test 503 handlers + + def monkey_set(key, value): + # set a key override function that throws sdl errors on certain keys + if key == "a1.policy_type.111": + raise RejectedByBackend() + if key == "a1.policy_type.112": + raise NotConnected() + if key == "a1.policy_type.113": + raise BackendError() + + monkeypatch.setattr("a1.data.SDL.set", monkey_set) + res = client.put("/a1-p/policytypes/111", json=adm_type_good) assert res.status_code == 503 res = client.put("/a1-p/policytypes/112", json=adm_type_good)