1 ##############################################################################
3 # Copyright (c) 2019 AT&T Intellectual Property.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 ##############################################################################
24 def getRedisClientDecodeResponse():
26 c = config.redis_ip_address
28 p = config.redis_ip_port
30 return redis.Redis(host=c, port=p, db=0, decode_responses=True)
32 def set_general_config_resource_status_false():
34 r = getRedisClientDecodeResponse()
35 r.set("{rsm},CFG:GENERAL:v1.0.0" , "{\"enableResourceStatus\":false,\"partialSuccessAllowed\":true,\"prbPeriodic\":true,\"tnlLoadIndPeriodic\":true,\"wwLoadIndPeriodic\":true,\"absStatusPeriodic\":true,\"rsrpMeasurementPeriodic\":true,\"csiPeriodic\":true,\"periodicityMs\":1,\"periodicityRsrpMeasurementMs\":3,\"periodicityCsiMs\":3}")
37 def verify_rsm_ran_info_start_false():
39 r = getRedisClientDecodeResponse()
41 value = "{\"ranName\":\"test1\",\"enb1MeasurementId\":1,\"enb2MeasurementId\":0,\"action\":\"start\",\"actionStatus\":false}"
43 return r.get("{rsm},RAN:test1") == value
46 def verify_rsm_ran_info_start_true():
48 r = getRedisClientDecodeResponse()
50 rsmInfoStr = r.get("{rsm},RAN:test1")
51 rsmInfoJson = json.loads(rsmInfoStr)
53 response = rsmInfoJson["ranName"] == "test1" and rsmInfoJson["enb1MeasurementId"] == 1 and rsmInfoJson["enb2MeasurementId"] != 1 and rsmInfoJson["action"] == "start" and rsmInfoJson["actionStatus"] == True
58 def verify_rsm_ran_info_stop_false():
60 r = getRedisClientDecodeResponse()
62 rsmInfoStr = r.get("{rsm},RAN:test1")
63 rsmInfoJson = json.loads(rsmInfoStr)
65 response = rsmInfoJson["ranName"] == "test1" and rsmInfoJson["enb1MeasurementId"] == 1 and rsmInfoJson["action"] == "stop" and rsmInfoJson["actionStatus"] == False
70 def verify_rsm_ran_info_stop_true():
72 r = getRedisClientDecodeResponse()
74 rsmInfoStr = r.get("{rsm},RAN:test1")
75 rsmInfoJson = json.loads(rsmInfoStr)
77 response = rsmInfoJson["ranName"] == "test1" and rsmInfoJson["action"] == "stop" and rsmInfoJson["actionStatus"] == True
81 def verify_general_config_enable_resource_status_true():
83 r = getRedisClientDecodeResponse()
85 configStr = r.get("{rsm},CFG:GENERAL:v1.0.0")
86 configJson = json.loads(configStr)
88 return configJson["enableResourceStatus"] == True
90 def verify_general_config_enable_resource_status_false():
92 r = getRedisClientDecodeResponse()
94 configStr = r.get("{rsm},CFG:GENERAL:v1.0.0")
95 configJson = json.loads(configStr)
97 return configJson["enableResourceStatus"] == False