예제 #1
0
# coding=utf-8
import pymysql
import unittest

from pyrest.yw_api import FanNengAPI
from utils.read_config import ReadCfgFile
from utils.jsonparse import parser

endpoint_yw_app = ReadCfgFile('yw_cfg.ini').get_val('rest_api',
                                                    'endpoint_yw_app')
username = ReadCfgFile('yw_cfg.ini').get_val('rest_api', 'username4')
pwd = ReadCfgFile('yw_cfg.ini').get_val('rest_api', 'passwd')
imei = ReadCfgFile('yw_cfg.ini').get_val('rest_api', 'imei')
login_data = {
    "loginName": username,
    "pwd": pwd,
    "imei": imei,
    "phoneType": "ios"
}

# 预生产地址-苏晔
# base_ip = '10.39.48.241'
# base_name = 'wit-operation'
# base_pwd = 'wit-operation'
# base_ku = 'wit-operation'

# 开发环境
# base_ip = '10.39.30.22'
# base_name = 'wit-operation'
# base_pwd = 'wit-operation'
# base_ku = 'wit-operation'
예제 #2
0
파일: dbUtil.py 프로젝트: yaqingpoem19/watt
 def __init__(self):
     # 获取基础数据连接信息
     self.base_ip = ReadCfgFile().get_val('database', 'base_ip')
     self.base_name = ReadCfgFile().get_val('database', 'base_name')
     self.base_pwd = ReadCfgFile().get_val('database', 'base_pwd')
     self.base_ku = ReadCfgFile().get_val('database', 'base_ku')
예제 #3
0
# coding=utf-8
import pymysql
import unittest
import datetime
import redis
import time
import re

from pyrest.yw_api import FanNengAPI
from utils.read_config import ReadCfgFile
from utils.jsonparse import parser

endpoint_ywWeb_login = ReadCfgFile('yw_cfg.ini').get_val('rest_api', 'endpoint_ywWeb_login')
endpoint_yw_cim = ReadCfgFile('yw_cfg.ini').get_val('rest_api', 'endpoint_yw_cim')
endpoint_yw_web = ReadCfgFile('yw_cfg.ini').get_val('rest_api', 'endpoint_yw_web')
username_web = ReadCfgFile('yw_cfg.ini').get_val('rest_api', 'username1')
pwd_web = ReadCfgFile('yw_cfg.ini').get_val('rest_api', 'web_passwd')
mark = ReadCfgFile('yw_cfg.ini').get_val('rest_api', 'mark')
vcode = ReadCfgFile('yw_cfg.ini').get_val('rest_api', 'vcode')
# login_data_web = {"mark": mark, "pwd": pwd_web, "username": username_web, "vcode": vcode}
# login_data_web = {"username": "******", "pwd": "123456", "vcode": "1234", "mark": "rCnVc9Or"}
access = {"appid": "1", "appsecret": "123456"}


# 测试环境
base_ip = '10.39.30.21'
base_name = 'wit-operation'
base_pwd = 'wit-operation'
base_ku = 'wit-operation'

# 测试环境
예제 #4
0
 def __init__(self,
              sheetIndex=0,
              sheetName='Sheet1'):  #默认获取第一个sheet,默认sheetname为Sheet1
     self.path = ReadCfgFile().get_val('global', 'excel_path')  #初始化Excel路径
     self.sheetIndex = sheetIndex
     self.sheetName = sheetName
예제 #5
0
# coding=utf-8
import unittest
from pyui.pyweb import FanNengWeb
from utils.read_config import ReadCfgFile
from testscripts.ui.fnqa.cim.page.po.web_ui.maintain_web import LoginPage
from time import sleep

cfg = ReadCfgFile('demo_cfg.ini', 'web_ui')
test_login_url = cfg.get_val('ui_web', 'test_env_login')
browser = cfg.get_val('ui_web', 'browser')
user = cfg.get_val('ui_web', 'user')
pass_wd = cfg.get_val('ui_web', 'passwd')
# operation_index = cfg.get_val('ui_web', 'operation_index')


class TestBase(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        # 登录
        print("···········登录············")
        print("···········browser············", browser)
        print("···········url············", test_login_url)
        print()
        self.fn_web = FanNengWeb(browser)
        self.fn_web.max_window()
        self.fn_web.open(test_login_url)
        self.fn_web.type(LoginPage.user_name, user)
        self.fn_web.type(LoginPage.passwd, pass_wd)
        self.fn_web.click(LoginPage.submit_button)
        sleep(2)
예제 #6
0
# __*__coding=utf-8__*__
# autor  张鹏
# date 2018/09/11
# describe  班组时间

from utils.read_config import ReadCfgFile
from pyrest.cim_api import cim_api, user_cim_api, dataService_interface
from datetime import timedelta, datetime
import copy
from dateutil.relativedelta import relativedelta
from utils.db_util import DBHelper
import sys
from utils.format import floatFormat
endpoint_os_ues_web = ReadCfgFile('os_ues_cfg.ini').get_val(
    'rest_os_ues_api', 'endpoint_os_web1')  #测试接口
cim_interface = ReadCfgFile('os_ues_cfg.ini').get_val(
    'rest_support_api', 'cim_web_interface')  #cim接口
data_service = ReadCfgFile('os_ues_cfg.ini').get_val(
    'rest_support_api', 'data_service_web')  #dataservice 接口
user_cim = ReadCfgFile('os_ues_cfg.ini').get_val('rest_support_api',
                                                 'user_cim_interface')
dataDB = eval(ReadCfgFile().get_val('database', '21_dataDB'))
LASTYEAR = ((datetime.now() - relativedelta(years=+1)) +
            timedelta(hours=1)).strftime('%Y-%m-%d %H:%M:%S')
TODAYBEGIN = datetime.now().strftime('%Y-%m-%d 00:00:00')
TODAYEND = datetime.now().strftime('%Y-%m-%d 23:59:59')
LASTMONTH = (datetime.now() -
             relativedelta(months=+1)).strftime('%Y-%m-%d %H:%M:%S')
NOW = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
nowHour = datetime.now().hour
예제 #7
0
 def __init__(self, ):
     self.os_ues = eval(ReadCfgFile().get_val('database', 'os_ues'))
예제 #8
0
# coding=utf-8
import unittest
from pyui.pyweb import FanNengWeb
from utils.read_config import ReadCfgFile
from time import sleep


cfg = ReadCfgFile('ai_test_demo.ini', 'web_ui')
test_login_url = cfg.get_val('ui_web', 'test_env_login')
browser = cfg.get_val('ui_web', 'browser')
dc_password = cfg.get_val('ui_web', 'dc_password')
passwd = cfg.get_val('ui_web', 'passwd')
dc_login = cfg.get_val('ui_web', 'dc_login')


class TestBase(unittest.TestCase):
    fn_web = FanNengWeb(browser)

    @classmethod
    def setUpClass(self):
        self.fn_web.open(test_login_url)
        self.fn_web.type(dc_password, passwd)
        self.fn_web.click(dc_login)
        sleep(2)
        # self.fn_web.open(operation_index)

    @classmethod
    def tearDownClass(self):
        # 关闭窗口并退出driver
        self.fn_web.close()
        self.fn_web.quit()
예제 #9
0
    def fetchMany(self, sql, size):
        self.execute(sql)

        return self.cur.fetchmany(size)


#PG数据库连接
class DBhelper_ps():
    def __init__(self, args):
        self.conn = psycopg2.connect(database=args['database'],
                                     user=args['user'],
                                     password=args['user'],
                                     host=args['host'],
                                     port='5432')
        self.cur = self.conn.cursor()

    def selectAll(self, sql):
        self.cur.execute(sql)
        # 获取表的所有字段名称
        coloumns = [row[0] for row in self.cur.description]
        result = [[str(item) for item in row] for row in self.cur.fetchall()]
        return [dict(zip(coloumns, row)) for row in result]


if __name__ == '__main__':
    base_ku1 = eval(ReadCfgFile().get_val('database', 'base_ku1'))
    da = DBHelper(base_ku1, resultType='')
    sql = "select * from alarm_add_data where add_data_id =110008"

    print(da.fetchOne(sql))
예제 #10
0
# coding=utf-8
import unittest
from pyui.pyweb import FanNengWeb
from utils.read_config import ReadCfgFile
from testscripts.ui.fnqa.yn.page.po.web_ui.energy_web import LoginPage
from time import sleep

cfg = ReadCfgFile('yn_cfg.ini', 'web_ui')
test_login_url = cfg.get_val('ui_web', 'test_env_login')
browser = cfg.get_val('ui_web', 'browser')
user = cfg.get_val('ui_web', 'user')
pass_wd = cfg.get_val('ui_web', 'passwd')
operation_index = cfg.get_val('ui_web', 'operation_index')


class TestBase(unittest.TestCase):
    fn_web = FanNengWeb(browser)

    @classmethod
    def setUpClass(self):
        # 登录
        # self.fn_web = FanNengWeb(browser)
        self.fn_web.open(test_login_url)
        self.fn_web.type(LoginPage.user_name, user)
        self.fn_web.type(LoginPage.passwd, pass_wd)
        self.fn_web.type(LoginPage.check_text, '1234')
        self.fn_web.click(LoginPage.submit_button)
        sleep(2)
        self.fn_web.open(operation_index)

    @classmethod
예제 #11
0
# coding=utf-8
from utils.read_config import ReadCfgFile
from utils.jsonparse import parser
from pyrest.ai_api import AiAPI
from testscripts.api.fnqa.ai.simpletestbase import aibase
import json
url = ReadCfgFile('ai_cfg.ini').get_val('rest_ai_api', 'fhyc_test')
url1 = ReadCfgFile('ai_cfg.ini').get_val('rest_ai_api', 'yxcl_test')
url2 = ReadCfgFile('ai_cfg.ini').get_val('rest_ai_api', 'fhpy_test')


class TestBaseAI(aibase):
    # 负荷预测,返回预测列表
    def ailoadForecasting(self, time, queries, loadType=4):
        # loadType = 预测类型(1 heatWater,2elec,3cool,4steam,默认值4)
        # time = 时间戳,预测time时间后(结果不含time)的12个小时的值,只接收整点
        # staId = 站ID,字符串类型
        # equipID = 设备,字符串类型
        # metric = 采集点,字符串类型
        # equipMK = 设备标识
        list1 = []
        sumtim = 503
        # metric1 = "UES."+metric
        # queries = [{"aggregator": "none", "downsample": "1h-first-zero", "metric": metric1, "tags":
        #    {"equipID": equipID, "staId": staId, "equipMK": equipMK}}]
        # 获取time时间前504小时数据
        json1 = self.opstpdatereduce(time, sumtim, queries)
        payload = {
            "inputData": {
                'CEU_FIQ303_FsIntLP': json1
            },
예제 #12
0
# coding=utf-8

from testscripts.ui.fnqa.ai.testbase import TestBase
from utils.read_config import ReadCfgFile
from time import sleep
cfg = ReadCfgFile('ai_test_demo.ini', 'web_ui')
dc_zhan = cfg.get_val('ui_web', 'dc_zhan')
dc_zhan1 = cfg.get_val('ui_web', 'dc_zhan1')
dc_look2 = cfg.get_val('ui_web', 'dc_look2')
ys = cfg.get_val('ui_web', 'ys')
dc_download = cfg.get_val('ui_web', 'dc_download')
dc_return = cfg.get_val('ui_web', 'dc_return')
dc_x = cfg.get_val('ui_web', 'dc_x')
dc_y = cfg.get_val('ui_web', 'dc_y')
dc_ok = cfg.get_val('ui_web', 'dc_ok')
dc_editok = cfg.get_val('ui_web', 'dc_editok')


# AI能效曲线webu ui test demo
class coverTest(TestBase):

    def test_ai_cover(self):
        # 点击站信息下拉框
        self.fn_web.click(dc_zhan)
        ys1 = self.fn_web.get_element(ys).text
        self.assertEqual(ys1, '阶段能效曲线维护中心')
        sleep(1)
        # 选择龙游站
        self.fn_web.click(dc_zhan1)
        ly = self.fn_web.get_element(dc_zhan1).text
        self.assertEqual(ly, '龙游站')