def setUp(self):
     print('测试开始')
     rootpath = handle_ini.get_value('rootpath')
     self.url = rootpath + "Data\case_01.xlsx"
     self.register_url =  "/user/register"
     self.login =  "******"
     self.addFamily = "/family/addFamily"
示例#2
0
 def setUp(self):
     print('测试开始')
     rootpath = handle_ini.get_value('uat')
     self.AddReward = rootpath + "/mgmt/reward/save"
     self.openActivity = rootpath + "/mgmt/reward/enable/{}"
     self.enableAutoApprove = rootpath + "/mgmt/reward/enableAutoApprove/{}"
     self.mysql = DoMysql("elephant")
     self.headers_Sunscreen_web = headers_Sunscreen_web_uat
 def setUp(self):
     print('测试开始')
     rootpath = handle_ini.get_value('uat')
     self.SaveUrl = rootpath + "/mgmt/activity/save"
     self.publish = rootpath + "/mgmt/activity/publish/{}"
     self.applyurl = rootpath + "/activity/apply"
     self.agree = rootpath + "/activity/apply/agree"
     self.reject = rootpath + "/activity/apply/reject"
     self.generate = rootpath + "/activity/order/generate"
     self.page = rootpath + "/activity/order/page"
     self.saveVoucher = rootpath + "/activity/order/saveVoucher"
     self.operate = rootpath + "/mgmt/order/operate"
     self.push = rootpath + "/mgmt/order/push/{}"
     self.report = rootpath + "/activity/apply/report/{}"
     self.activity_page = rootpath + "/activity/page"
     self.pageApprove = rootpath + "/activity/apply/pageApprove"
     self.pageApproveItem = rootpath + "/activity/apply/pageApproveItem"
     self.User_info = rootpath + "/activity/apply/{}"
     self.pageApply = rootpath + "/mgmt/activity/pageApply"
     self.Slideshow = rootpath + "/activity/apply/preCheck/{}"
     self.mysql = DoMysql("yjdf_mall_orders")
示例#4
0
# coding=utf-8
import json
import string
import unittest
from Data.Body.body_data import *
from Driver.DoMysql import DoMysql
from Driver.base_request import request
from Driver.GenPass import GenPass
from Driver.handle_init import handle_ini
from Data.Headers.headers_data import *
import logging
rootpath = handle_ini.get_value('rootpath')
file_path = rootpath + "/Log/"
logging.basicConfig(
    level=logging.DEBUG,  # 控制台打印的日志级别
    filename=file_path + '\logs.log',
    filemode='a',  ##模式,有w和a,w就是写模式,每次都会重新写日志,覆盖之前的日志
    # a是追加模式,默认如果不写的话,就是追加模式
    format=
    '%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s'
    # 日志格式
)
logger = logging.getLogger()


class Activity_Reward(unittest.TestCase):
    def setUp(self):
        print('测试开始')
        rootpath = handle_ini.get_value('uat')
        self.AddReward = rootpath + "/mgmt/reward/save"
        self.openActivity = rootpath + "/mgmt/reward/enable/{}"
示例#5
0
class UpDownStuff():
    base_url = handle_ini.get_value('updownstuff_host')
    List_url = base_url + '/list'
    selectCamera_url = base_url + '/selectCamera'
    closeStream_url = base_url + '/closeStream'
    setIpConfig_url = base_url + '/setIpConfig'
    startToGrab_url = base_url + '/startToGrab'
    detail_url = base_url + '/detail'

    def getCameraList(self):
        res = request.run_main('get', self.List_url)
        res = res['data'][0]['uuid']
        print('uuid:' + res)
        return res

    def closeStream(self, uuid):
        json = {"uuid": uuid}
        res = request.run_main('post', self.closeStream_url, json=json)
        print(res)

    def SelectCamera(self, uuid):
        json = {"uuid": uuid, "control-mode": "exclusive"}
        res = request.run_main('post', self.selectCamera_url, json=json)
        print(res)
        status = res['status']
        if status == False:
            time.sleep(2)
            self.closeStream(uuid)
            res1 = request.run_main('post', self.selectCamera_url, json=json)
            if res1['status'] == True:
                print('selectCamera操作成功1')
            else:
                print(res1)
        else:
            print('selectCamera操作成功2')

    # def setIpConfig(self,uuid):
    #     json = {
    #         "uuid": uuid,
    #         "config": "static"
    #     }
    #     res = request.run_main('post', self.setIpConfig_url, json=json)
    #     print('setIpConfig: ',str(res))
    def startToGrab(self, uuid):
        json = {"uuid": uuid, "rgb": False}
        res = request.run_main('post', self.startToGrab_url, json=json)
        if res['status'] == True:
            print('startToGrab操作成功')
        else:
            print(res)

    def detail(self, uuid):
        json1 = {"uuid": uuid}
        res = request.run_main('post', self.detail_url, json=json1)
        if res['status'] == True:
            print('detail操作成功')
        else:
            print(res)
        print(json.dumps(res, indent=2, ensure_ascii=False))

    def Go(self):
        uuid = self.getCameraList()
        self.SelectCamera(uuid)
        # self.setIpConfig(uuid)
        self.startToGrab(uuid)
        self.detail(uuid)
示例#6
0
class Demo:
    url = "https://www.biduo.cc/biquge/53_53723/"
    file_path = handle_ini.get_value('file_path')
    cur = 0

    def fiction(self):
        ''' 建立Session:'''
        session = HTMLSession()

        # 打开Url检查返回码
        r = session.get(Demo.url)
        if r.status_code == 404:
            print("url open failed: {}".format(r.url))
        return r

    def analysis(self, htmls):
        anchors = []
        news = htmls.html.find('div#list dd a')
        #查找内容并检查返回内容
        if news == None:
            print("article empty")
        for value in news:
            '''获取Element内容中的信息(文本/链接)'''
            anchor = {'text': value.text, 'links': value.absolute_links}
            anchors.append(anchor)
        return anchors

    def __refine(self, anchors):
        '''数据精炼'''
        l = lambda anchor: {
            'title': anchor['text'].strip(),  #strip()去掉字符串多余空格
            'links': anchor['links']
        }
        return map(l, anchors)

    def __sort(self, anchors):
        '''数据排序'''
        anchors = sorted(anchors, key=self.__sort_seed, reverse=True)
        return anchors

    def __sort_seed(self, anchor):
        for rank in range(0, len(anchor)):
            str(rank + 1)
        return str(rank + 1)

    def __show(self, anchors):
        '''数据显示'''
        for rank in range(0, len(anchors)):
            print('rank' + str(rank + 1) + ":  " + anchors[rank]['title'] +
                  '      ' + str(anchors[rank]['links']))
        set = anchors[rank]['links']
        lists = list(set)[0]
        session = HTMLSession()
        r = session.get(lists)
        newss = r.html.find("div.bookname h1")
        news = r.html.find("div#content")
        for texts in news:
            for self.title in newss:
                print('\n')
                print('-------------------' + self.title.text +
                      '-------------------------')
            print(texts.text)
        return texts.text

    def __open(self, texts):
        wwwa = Demo.file_path + "/{0}.txt".format(self.title.text)
        if wwwa == None:
            print("标题为空")
        with open(wwwa, 'w') as f:
            f.write('-------------------------' + self.title.text +
                    '-------------------------' + '\n' + texts)
            f.close()

    def go(self):
        htmls = self.fiction()
        anchors = self.analysis(htmls)
        anchors = list(self.__refine(anchors))
        anchors = self.__sort(anchors)
        anchors = self.__show(anchors)
        self.__open(anchors)
        print(
            str(datetime.datetime.now()) +
            "-----------------------------------------------------------------"
        )
示例#7
0
 def setUp(self):
     print('测试开始')
     rootpath = handle_ini.get_value('uat')
     self.url = rootpath + "/user/warrant"