X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=tests%2Ftest_sdl.py;fp=tests%2Ftest_sdl.py;h=92edcb0526541733c683b609bc3b302e52ae77a9;hb=21f659c694968e95ad4e1a568538a586c5291b62;hp=0000000000000000000000000000000000000000;hpb=aa10152885b58792ffde0c78f42df4a8c0078d42;p=ric-plt%2Fxapp-frame-py.git diff --git a/tests/test_sdl.py b/tests/test_sdl.py new file mode 100644 index 0000000..92edcb0 --- /dev/null +++ b/tests/test_sdl.py @@ -0,0 +1,52 @@ +""" +tests data functions +""" +# ================================================================================== +# Copyright (c) 2019-2020 Nokia +# Copyright (c) 2018-2020 AT&T Intellectual Property. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ================================================================================== +from ricxappframe.xapp_sdl import SDLWrapper + + +NS = "testns" + + +def test_sdl(): + """ + test raw sdl functions + """ + sdl = SDLWrapper(use_fake_sdl=True) + sdl.set(NS, "as.df1", "data") + sdl.set(NS, "as.df2", "data2") + assert sdl.get(NS, "as.df1") == "data" + assert sdl.get(NS, "as.df2") == "data2" + assert sdl.find_and_get(NS, "as.df1") == {"as.df1": "data"} + assert sdl.find_and_get(NS, "as.df2") == {"as.df2": "data2"} + assert sdl.find_and_get(NS, "as.df") == {"as.df1": "data", "as.df2": "data2"} + assert sdl.find_and_get(NS, "as.d") == {"as.df1": "data", "as.df2": "data2"} + assert sdl.find_and_get(NS, "as.") == {"as.df1": "data", "as.df2": "data2"} + assert sdl.find_and_get(NS, "asd") == {} + + # delete 1 + sdl.delete(NS, "as.df1") + assert sdl.get(NS, "as.df1") is None + assert sdl.get(NS, "as.df2") == "data2" + + # delete 2 + sdl.delete(NS, "as.df2") + assert sdl.get(NS, "as.df2") is None + + assert sdl.find_and_get(NS, "as.df") == {} + assert sdl.find_and_get(NS, "") == {}