92edcb0526541733c683b609bc3b302e52ae77a9
[ric-plt/xapp-frame-py.git] / tests / test_sdl.py
1 """
2 tests data functions
3 """
4 # ==================================================================================
5 #       Copyright (c) 2019-2020 Nokia
6 #       Copyright (c) 2018-2020 AT&T Intellectual Property.
7 #
8 #   Licensed under the Apache License, Version 2.0 (the "License");
9 #   you may not use this file except in compliance with the License.
10 #   You may obtain a copy of the License at
11 #
12 #          http://www.apache.org/licenses/LICENSE-2.0
13 #
14 #   Unless required by applicable law or agreed to in writing, software
15 #   distributed under the License is distributed on an "AS IS" BASIS,
16 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 #   See the License for the specific language governing permissions and
18 #   limitations under the License.
19 # ==================================================================================
20 from ricxappframe.xapp_sdl import SDLWrapper
21
22
23 NS = "testns"
24
25
26 def test_sdl():
27     """
28     test raw sdl functions
29     """
30     sdl = SDLWrapper(use_fake_sdl=True)
31     sdl.set(NS, "as.df1", "data")
32     sdl.set(NS, "as.df2", "data2")
33     assert sdl.get(NS, "as.df1") == "data"
34     assert sdl.get(NS, "as.df2") == "data2"
35     assert sdl.find_and_get(NS, "as.df1") == {"as.df1": "data"}
36     assert sdl.find_and_get(NS, "as.df2") == {"as.df2": "data2"}
37     assert sdl.find_and_get(NS, "as.df") == {"as.df1": "data", "as.df2": "data2"}
38     assert sdl.find_and_get(NS, "as.d") == {"as.df1": "data", "as.df2": "data2"}
39     assert sdl.find_and_get(NS, "as.") == {"as.df1": "data", "as.df2": "data2"}
40     assert sdl.find_and_get(NS, "asd") == {}
41
42     # delete 1
43     sdl.delete(NS, "as.df1")
44     assert sdl.get(NS, "as.df1") is None
45     assert sdl.get(NS, "as.df2") == "data2"
46
47     # delete 2
48     sdl.delete(NS, "as.df2")
49     assert sdl.get(NS, "as.df2") is None
50
51     assert sdl.find_and_get(NS, "as.df") == {}
52     assert sdl.find_and_get(NS, "") == {}