Added cv_test_manager.py.py as test library

run_test can be used to run cv_test_manager.py

Signed-off-by: SushantBawiskar <sushant.bawiskar@candelatech.com>
This commit is contained in:
SushantBawiskar
2021-04-07 17:29:54 +05:30
parent ea5156ab66
commit 4d998463f6
2 changed files with 158 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
from LANforge import LFRequest
from LANforge import LFUtils
from LANforge.lfcli_base import LFCliBase
import datetime
import time
import json
from chamberview import chamberview as cv
class cv_test(LFCliBase):
def __init__(self,
lfclient_host="localhost",
lfclient_port=8080,
):
super().__init__(_lfjson_host=lfclient_host,
_lfjson_port=lfclient_port)
def create_test_config(self,config_name,text):
req_url = "/cli-json/add_text_blob"
data = {
"type": "Plugin-Settings",
"name": "Wifi-Capacity-"+config_name,
"text": text
}
print(data)
rsp = self.json_post(req_url, data)
time.sleep(1)
def create_test(self, test_name, instance):
cmd = "cv create '{0}' '{1}'".format(test_name, instance)
self.run_cv_cmd(cmd)
def load_test_scenario(self, instance, scenario):
cmd = "cv load '{0}' '{1}'".format(instance, scenario)
print("cmd: ",cmd)
self.run_cv_cmd(cmd)
def load_test_config(self, test_config, instance):
cmd = "cv load '{0}' '{1}'".format(instance, test_config)
print("cmd: ", cmd)
self.run_cv_cmd(cmd)
def start_test(self, instance):
cmd = "cv click '%s' Start" % instance
print("cmd: ",cmd)
self.run_cv_cmd(cmd)
def close_test(self, instance):
cmd = "cv click '%s' 'Close'" % instance
print(cmd)
self.run_cv_cmd(cmd)
def cancel_test(self, instance):
cmd = "cv click '%s' Cancel" % instance
print(cmd)
self.run_cv_cmd(cmd)
def run_cv_cmd(self, command): # Send chamber view commands
print(command)
req_url = "/gui-json/cmd"
data = {
"cmd": command
}
rsp = self.json_post(req_url, data)
print(rsp)
print(data)
def check_ports(self):
response=self.json_get("/ports/")
return response
def show_changes(self,config_name):
req_url = "/cli-json/show_text_blob"
data = {
"type": "Plugin-Settings",
"name": "Wifi-Capacity-"+config_name,
"brief": "brief"
}
rsp = self.json_post(req_url, data)