예제 #1
0
    def __before(self):

        """测试函数开始前事物"""
        try:
            self.driver.delete_all_cookies()
        except:
            try:
                self.__chose()
            except:
                InitTest.start()
                self.driver = Ioput.output("driver")
            else:
                InitTest.start()
                self.driver = Ioput.output("driver")
예제 #2
0
class CaseSample首页(FunctionSample):
    for f in Get.out(Ioput.output("file"), "other"):
        exec("""
def test_{0}(self):
   Ioput.function_name(self.__class__.__name__)
   self.首页_table({1})
               """.format(f.get("buttontext"), f))
예제 #3
0
class CaseSample详情(FunctionSample):
    for f in Get.out(
            Ioput.output("file"),
            "Detail",
    ):

        if Suite.table_data:
            exec("""
def test_{0}__表格数据(self):
    Ioput.function_name(self.__class__.__name__)
    self.详情_table({1})
            """.format(f.get("buttontext0"), f))

        if Suite.xlsx_data:
            if f.get("buttontext0", None) != "时段收视":
                exec("""
def test_{0}_导出数据(self):
    Ioput.function_name(self.__class__.__name__)
    self.详情_xlsx({1})
            """.format(f.get("buttontext0"), f))

        if Suite.keyword and f.get("buttontext0") == "节目收视":
            exec("""
def test_{0}_关键字搜索(self):
    Ioput.function_name(self.__class__.__name__)
    self.d_keyword({1})
            """.format(f.get("buttontext0"), f))
예제 #4
0
class CaseSample详情(FunctionSample):
    for f in Get.out(Ioput.output("file"), "detail"):
        exec("""
def test_{0}__表格数据(self):
    Ioput.function_name(self.__class__.__name__)
    self.详情_table({1})
            """.format(f.get("buttontext"), f))
예제 #5
0
class CaseSample首页(FunctionSample):
    for f in Get.out(
            Ioput.output("file"),
            "time",
    ):
        if Suite.table_data:
            exec("""
def test_{0}__表格数据(self):
   Ioput.function_name(self.__class__.__name__)
   self.首页_table({1})
               """.format(
                f.get("casename"),
                f,
            ))
        if Suite.xlsx_data:
            exec("""
def test_{0}_导出数据(self):
   Ioput.function_name(self.__class__.__name__)
   self.首页_xlsx({1})
               """.format(
                f.get("casename"),
                f,
            ))
        if Suite.keyword:
            exec("""
def test_{0}_搜索关键字(self):
   Ioput.function_name(self.__class__.__name__)
   self.h_keyword({1})
               """.format(
                f.get("casename"),
                f,
            ))
예제 #6
0
 def _before(self,**kwargs):
     """测试函数前环境不通过,重新准备一次环境"""
     if Ioput.output("pathstatus") == "exit":
         text = "setupClass 不通过,当前用例判为失败: {0}".format(Ioput.output("patherror"))
         log().critical(text)
         assert False, text
     log().debug("前置环境校验通过,next")
     try:
        self.checktext(1, element=getattr(self, "text", ""))
     except Exception as e:
         log().error(" %s 准备清空浏览器缓存,重置环境一次 :%s" % (self.text, e))
         try:
             self._last()
         except:
             self._first()
         else:
             self._first()
         if "详情" in self.__class__.__name__ and getattr(self,"buttontext", None) != "子级栏目":
             self.pararms2(**kwargs)
             self.get_data_datil()
예제 #7
0
class CaseSample首页(FunctionSample):
    for f in Get.out(Ioput.output("file"), "Column"):
        if Suite.table_data:
            exec("""
def test_{0}__表格数据(self):
   Ioput.function_name(self.__class__.__name__)
   self.首页_table({1})
               """.format(f.get("list_page"), f))
            if Suite.xlsx_data:
                exec("""
def test_{0}_导出数据(self):
   Ioput.function_name(self.__class__.__name__)
   self.首页_xlsx({1})
               """.format(f.get("list_page"), f))
예제 #8
0
class CaseSample详情(FunctionSample):
    for f in Get.out(Ioput.output("file"), "detail"):
        if Suite.table_data:
            exec("""
def test_{0}__表格数据(self):
    Ioput.function_name(self.__class__.__name__)
    self.详情_table({1})
            """.format(f.get("casename"), f))
        if Suite.xlsx_data:
            exec("""
def test_{0}_导出数据(self):
    Ioput.function_name(self.__class__.__name__)
    self.详情_xlsx({1})
            """.format(f.get("casename"), f))
예제 #9
0
def socket_client(host, send_dict, key="index", send=None):
    """
    :param host: host:目标地址
    :param send_dict: send_dict消息内容,类型为dict
    :param key: 返回内容存放的键值,send!=None 时必须带上key
    :param send: 一个实例 Ioput(),或"web"
    :return: 
    """
    HOST = host
    cfg = Ioput.output("cfg")
    PORT = cfg["node"]["localport"]
    PORT = int(PORT)

    s_ds = str(send_dict)
    b_ds = bytes(s_ds, encoding='utf-8')
    log().info(("send data", type(b_ds), b_ds))
    log().info(("object 'send' is ", send))

    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
        s.connect((HOST, PORT))
        s.sendall(b_ds)
        log().info(("send dict success ", send_dict))
        data = s.recv(1024)
    k1 = (eval(data))
    log().info(("get result dict sucess ", k1))

    if send == None:
        pass

    elif send == "web":
        """
        接受注入的返回消息,存入类属性中
        """
        Ioput.input(keys=key, value=k1)
        log().info(("write  {", key, ":", k1, "}  to  'Webdata,  success"))

    elif send != None and send != "web":
        """
        send 是一个实例,用于远程机器返回的数据写入实例中
        """
        send.write_dict(key, value=k1)
        log().info(("write  {", key, ":", k1, "}  to  send.put_dict success"))

    return k1
예제 #10
0
class CaseSample首页(FunctionSample):
    for f in Get.out(Ioput.output("file"), ("time", "other")):
        if Suite.table_data:
            exec("""
def test_{0}_{2}__表数据(self):
   Ioput.function_name(self.__class__.__name__)
   self.首页_table({1})
               """.format(f.get("casename"), f, f.get("buttontext")))
        if Suite.xlsx_data and f.get("buttontext", None) == "详情数据":
            exec("""
def test_{0}_{2}_导出数据(self):
   Ioput.function_name(self.__class__.__name__)
   self.首页_xlsx({1})
               """.format(f.get("casename"), f, f.get("buttontext")))

        if Suite.keyword and f.get("buttontext", None) == "详情数据":
            exec("""
def test_{0}_{2}_关键字搜索(self):
    Ioput.function_name(self.__class__.__name__)
    self.h_keyword({1})
               """.format(f.get("casename"), f, f.get("buttontext")))
예제 #11
0
from config.conf import Suite

__autor__ = "鲁旭"

from lib.funcslib import Ioput
Ioput.input("file", "HDreal")
from lib.testsam import *
from flow.biportal.epgbase import Epg高清实时数据
file = Ioput.output("file")


class CaseSample首页(FunctionSample):
    for f in Get.out(Ioput.output("file"), "Column"):
        if Suite.table_data:
            exec("""
def test_{0}__表格数据(self):
   Ioput.function_name(self.__class__.__name__)
   self.首页_table({1})
               """.format(f.get("list_page"), f))
            if Suite.xlsx_data:
                exec("""
def test_{0}_导出数据(self):
   Ioput.function_name(self.__class__.__name__)
   self.首页_xlsx({1})
               """.format(f.get("list_page"), f))


Test1 = type("Test高清实时数据_首页", (CaseSample首页, ), {"obj": Epg高清实时数据})

if __name__ == "__main__":
    print(dir())
예제 #12
0
파일: _local_main.py 프로젝트: demi52/mandy
    def _recv_and_send(self, dict2):
        """
        :param dict: type(bytes,str ,dict)
                      {"action":"clean_disk"}
        :return:
        """
        try:
            action = dict2['action']
        except:
            print("ERROR :param type error or notfound key 'action' ")
            return {"status": "fail", "text": "param type error or notfound key 'action'"}
        #初始化磁盘环境
        if action == 'clean_disk':
            ret = Exos().clean_disk()
        #初始化数据库环境
        elif action == 'clean_db':
            ret = Exos().clean_db()
        #初始化数据库与磁盘环境
        elif action == 'clean':
            ret1= Exos().clean_disk()
            ret2=Exos().clean_db()
            if ret1["status"] == "success" and ret2["status"] == "success":
                ret={"status": "success", "action": "clean_db_disk"}
            else:
                ret={"status": "fail", "action": "clean_db_disk"}
        #业务进程启动、停止
        elif action == 'exe_streamer':
            try:
                streamer_act = dict2['streamer_act']
            except:
                return {"status": "fail", "text": "not found key streamer_act", "action":"exe_streamer"}
            ret=Exos().exe_streamer(streamer_act)
        #业务内容查询与判断
        elif action == 'select_content':
            try:
                contentID=dict2['contentID']
                type=dict2['type']
            except:
                return {"status": "fail", "text": "not found key 'contentID' or 'type'","action":"select_content"}
            ret = Exos().select_content(contentID, type)
        #配置文件读写
        elif action == "scelect_config":
            try:
                sec=dict2["sec"]
                key=dict2["key"]
                value=dict2["value"]
            except:
                return {"status": "fail", "text": "notfound key 'sec' or 'key' or 'value'", "action":"scelect_config"}
            ret = Exos().select_config(sec, key, value)

        if Exos.localhost == "127.0.0.1":
            from lib.funcslib import Ioput
            from lib.funcslib import log
            try:
                key = dict2["key"]
                if action == "input":
                    value =dict2["value"]
                    Ioput.input(keys=key,value=value)
                    log().info(("write sucess",key,value))
                    ret={"status": "sucess","action": "input", "key": key,"value":value}
                elif action == "output":
                    result=Ioput.output(key=key,timeout=60)
                    log().info(("read sucess", key, result))
                    ret={"status": "sucess","action": "output", "key": key,"value":result}
            except:
                ret={"status": "fail","text":"please need correct 'key';'status',value "}
        return ret
예제 #13
0
 def _first(self, **kwargs):
     __class__.pararms(self, **kwargs)
     if BI_protal.portal != "debug":
         self.driver = Ioput.output("driver")
     else:
         self.open()
예제 #14
0
파일: driver.py 프로젝트: demi52/mandy
 def end(cls):
     driver = Ioput.output("driver")
     driver.quit()
     log().info("\t测试结束关闭浏览器\t".center(80, "-"))