class Test(object):
    '''推荐任务详情'''

    request = RunMethod().run_main
    assertion = Assertion()
    exec_sql = ExecSql().exec_sql
    yaml_data = ReadFile().read_yaml('yaml_path')['lxk']
    sql_yaml_data = ReadFile().read_yaml('sql_yaml_path')['lxk']

    def setup_class(self):
        '''
        数据初始化
        :return:
        '''
        self.task_id = self.exec_sql('lxk', self.sql_yaml_data['获取推荐任务id'][0],
                                     self.sql_yaml_data['获取推荐任务id'][1])[0][0]

    def teardown_class(self):
        '''
        数据清理
        :return:
        '''
        pass

    #@allure.feature('蓝薪卡')
    @allure.story('lxk_推荐任务详情')
    def test_recommend_task_detail(self, get_lxk_c_headers, function, casename,
                                   type, run, url, hearders, param, sql1, sql2,
                                   sql3, asserttype, expect1, expect2,
                                   expect3):
        '''
        推荐任务详情
        :param get_lxk_c_headers:
        :param function:
        :param casename:
        :param type:
        :param run:
        :param url:
        :param hearders:
        :param param:
        :param sql1:
        :param sql2:
        :param sql3:
        :param asserttype:
        :param expect1:
        :param expect2:
        :param expect3:
        :return:
        '''
        response_data = self.request(
            type, self.yaml_data['url'] + url + str(self.task_id),
            get_lxk_c_headers)
        self.assertion.get_sql_data('lxk', eval(sql1)[0], eval(sql1)[1])
        self.assertion.get_response_data(response_data, eval(expect2))
        self.assertion.asser(function, casename, expect1, response_data,
                             asserttype)
示例#2
0
class Test(object):
    '''设置登录密码'''

    request = RunMethod().run_main
    assertion = Assertion()
    exec_sql = ExecSql().exec_sql
    yaml_data = ReadFile().read_yaml('yaml_path')['lxk']
    sql_yaml_data = ReadFile().read_yaml('sql_yaml_path')['lxk']

    def setup_class(self):
        '''
        数据初始化
        :return:
        '''
        self.exec_sql(
            'lxk', self.sql_yaml_data['清除登录密码'][0],
            self.sql_yaml_data['清除登录密码'][1].format(
                self.yaml_data['account']['c_account']))

    def teardown(self):
        '''
        数据清理
        :return:
        '''
        self.exec_sql(
            'lxk', self.sql_yaml_data['清除登录密码'][0],
            self.sql_yaml_data['清除登录密码'][1].format(
                self.yaml_data['account']['c_account']))

    #@allure.feature('蓝薪卡')
    @allure.story('lxk_设置登录密码')
    def test_set_password(self, get_lxk_c_headers, function, casename, type,
                          run, url, hearders, param, sql1, sql2, sql3,
                          asserttype, expect1, expect2, expect3):
        '''
        设置登录密码
        :param get_lxk_c_headers:
        :param function:
        :param casename:
        :param type:
        :param run:
        :param url:
        :param hearders:
        :param param:
        :param sql1:
        :param sql2:
        :param sql3:
        :param asserttype:
        :param expect1:
        :param expect2:
        :param expect3:
        :return:
        '''
        response_data = self.request(type, self.yaml_data['url'] + url,
                                     get_lxk_c_headers, eval(param))
        self.assertion.asser(function, casename, expect1, response_data)
class MakeSqlData(object):

    exec_sql = ExecSql().exec_sql
    sql_yaml_data = ReadFile().read_yaml('sql_yaml_path')

    def __init__(self, project):
        self.project = project

    def make_sql_data(self, b_account, c_account):
        prefix_data = {'user_id': ''}
        print(b_account, c_account, self.project)
        company_user_id = self.exec_sql(
            self.project, self.sql_yaml_data[self.project]['查企业用户id'][0],
            self.sql_yaml_data[self.project]['查企业用户id'][1].format(
                b_account))[0][0]
        team_id = self.exec_sql(
            self.project, self.sql_yaml_data[self.project]['查团队id'][0],
            self.sql_yaml_data[self.project]['查团队id'][1].format(
                b_account))[0][0]
        user_id = self.exec_sql(
            self.project, self.sql_yaml_data[self.project]['查C端用户id'][0],
            self.sql_yaml_data[self.project]['查C端用户id'][1].format(
                c_account))[0][0]
        self.exec_sql(
            self.project, self.sql_yaml_data[self.project]['加入团队'][0],
            self.sql_yaml_data[self.project]['加入团队'][1].format(
                company_user_id, team_id, user_id, c_account))
        prefix_data['user_id'] = user_id
        return prefix_data
示例#4
0
 def __init__(self):
     self.yaml_data = ReadFile().read_yaml('yaml_path')['lxk']
     self.header = self.yaml_data['headers']
     self.url = self.yaml_data['url']
     self.lxk_c_url = self.yaml_data['c_login']['url']
     self.lxk_c_method = self.yaml_data['c_login']['method']
     self.lxk_c_param = self.yaml_data['c_login']['param']
示例#5
0
 def _get_sql_conf(self, project):
     """
     获取mysql配置
     :param platform_name:
     :return:
     """
     try:
         return ReadFile().read_yaml('yaml_path')[project]['mysql']
     except:
         self.log.error("找不到对应项目:{0}".format(project))
示例#6
0
def send_mail(latest_report):

    f = open(latest_report, 'rb')
    mail_content = f.read()
    f.close()

    config = ReadFile()
    smtpserver = config.readConfig('Email', 'smtpserver')

    user = config.readConfig('Email', 'user')
    password = config.readConfig('Email', 'password')
    #发件人
    sender = config.readConfig('Email', 'sender')
    #收件人列表(读取ini的文件得到的是str格式,需要用json.loads去掉")
    receives = json.loads(config.readConfig('Email', 'receives'))
    #抄送人列表
    cc = json.loads(config.readConfig('Email', 'cc'))
    subject = config.readConfig('Email', 'subject')
    msg = MIMEMultipart('mixed')
    #邮件内容
    msg.attach(MIMEText(mail_content, 'html', 'utf-8'))

    #添加邮件附件
    att1 = MIMEText(open(latest_report, "rb").read(), "base64", "utf-8")
    att1["Content-Type"] = "application/octet-stream"
    att1["Content-Disposition"] = "attachment;filename=" + 'test_report.html'
    msg.attach(att1)

    #邮件主题
    msg['Subject'] = Header(subject, 'utf-8')
    #邮件发送人
    msg['From'] = Header(sender, 'utf-8')
    #邮件接受人
    msg['To'] = ','.join(receives)
    #邮件抄送人
    msg['Cc'] = ','.join(cc)
    #连接邮箱服务器
    smtp = smtplib.SMTP(smtpserver, 587)
    #创建了安全连接,当SMTP服务必须要加密时使用,端口非25
    smtp.starttls()
    #登录邮箱服务器
    smtp.login(user, password)
    #发送邮件
    smtp.sendmail(sender, receives, msg.as_string())
    smtp.quit()
#!/usr/bin/env python
# _*_coding:utf-8_*_

import pytest
from common.readFile import ReadFile
from common.request import RunMethod
from common.assertion import Assertion
from common.execSql import ExecSql
import allure

data = ReadFile().read_excel('lxk', '推荐任务详情')


@pytest.mark.parametrize(
    'function,casename,type,run,url,hearders,param,sql1,sql2,sql3,asserttype,expect1,expect2,expect3',
    data)
class Test(object):
    '''推荐任务详情'''

    request = RunMethod().run_main
    assertion = Assertion()
    exec_sql = ExecSql().exec_sql
    yaml_data = ReadFile().read_yaml('yaml_path')['lxk']
    sql_yaml_data = ReadFile().read_yaml('sql_yaml_path')['lxk']

    def setup_class(self):
        '''
        数据初始化
        :return:
        '''
        self.task_id = self.exec_sql('lxk', self.sql_yaml_data['获取推荐任务id'][0],
#!/usr/bin/env python
# _*_coding:utf-8_*_

import pytest
from common.readFile import ReadFile
from common.request import RunMethod
from common.assertion import Assertion
from common.execSql import ExecSql
from common.prefixSqlData import MakeSqlData
import allure

data = ReadFile().read_excel('lxk', '实名绑卡')


@pytest.mark.parametrize(
    'function,casename,type,run,url,hearders,param,sql1,sql2,sql3,asserttype,expect1,expect2,expect3',
    data)
class Test(object):
    '''实名绑卡'''

    request = RunMethod().run_main
    assertion = Assertion()
    exec_sql = ExecSql().exec_sql
    yaml_data = ReadFile().read_yaml('yaml_path')['lxk']
    sql_yaml_data = ReadFile().read_yaml('sql_yaml_path')['lxk']
    prefix_sql_data = MakeSqlData('lxk').make_sql_data

    def setup_class(self):
        '''
        数据初始化
        :return:
示例#9
0
#!/usr/bin/env python
# _*_coding:utf-8_*_
import pytest, os, yaml, requests
from common.readFile import ReadFile
from common.login import Login

yaml_data = ReadFile().read_yaml('yaml_path')


@pytest.fixture(scope='session')
def get_lxk_c_headers():
    """
    登录获取token更新headers
    :return:
    """
    headers = yaml_data['lxk']['headers']
    token = Login().lxk_c_login(
        'lxk_c', yaml_data['lxk']['account']['c_account'])['data']['token']
    headers['Authorization'] = token
    return headers
#!/usr/bin/env python
# _*_coding:utf-8_*_

import pytest
from common.readFile import ReadFile
from common.request import RunMethod
from common.assertion import Assertion
from common.execSql import ExecSql
from common.prefixSqlData import MakeSqlData
import allure

data = ReadFile().read_excel('lxk', '设置交易密码')


@pytest.mark.parametrize(
    'function,casename,type,run,url,hearders,param,sql1,sql2,sql3,asserttype,expect1,expect2,expect3',
    data)
class Test(object):
    '''设置交易密码'''

    request = RunMethod().run_main
    assertion = Assertion()
    exec_sql = ExecSql().exec_sql
    yaml_data = ReadFile().read_yaml('yaml_path')['lxk']
    sql_yaml_data = ReadFile().read_yaml('sql_yaml_path')['lxk']
    prefix_sql_data = MakeSqlData('lxk').make_sql_data

    def setup_class(self):
        '''
        数据初始化
        :return:
示例#11
0
#!/usr/bin/env python
# _*_coding:utf-8_*_

import pytest
from common.readFile import ReadFile
from common.request import RunMethod
from common.assertion import Assertion
from common.execSql import ExecSql
from common.prefixSqlData import MakeSqlData
import allure

data = ReadFile().read_excel('lxk', '我的报名')
print(data)

# @pytest.mark.parametrize('function,casename,type,run,url,hearders,param,sql1,sql2,sql3,asserttype,expect1,expect2,expect3',data)
# class Test(object):
#     '''我的报名'''
#
#     request = RunMethod().run_main
#     assertion = Assertion()
#     exec_sql = ExecSql().exec_sql
#     yaml_data = ReadFile().read_yaml('yaml_path')['lxk']
#     sql_yaml_data = ReadFile().read_yaml('sql_yaml_path')['lxk']
#     prefix_sql_data = MakeSqlData('lxk').make_sql_data
#
#
#     def setup_class(self):
#         '''
#         数据初始化
#         :return:
#         '''
示例#12
0
from  pageObject.basePage import *
from selenium import webdriver
from common.readFile import ReadFile
from config import setting

login_el = ReadFile().readYaml(setting.TEST_Element_YAML + '/' + 'login.yaml')
data = ReadFile().readYaml(setting.TEST_DATA_YAML + '/' + 'login_data.yaml')

class CndsPage(BasePage):
    '''登录页面'''

    url = '/login'

    # 定位器,通过元素属性定位元素对象
    #选择账号密码登录
    chanlelogin_loc = login_el['testcase'][0]
    # 账号输入框
    username_loc = login_el['testcase'][1]
    # 密码输入框
    pwd_loc = login_el['testcase'][2]
    # 单击登录
    login_accout_loc = login_el['testcase'][3]

    def accout_login(self,accout,passwd):
        self.open_url(self.url)
        self.click(self.chanlelogin_loc)
        self.input(self.username_loc,accout)
        self.input(self.pwd_loc,passwd)
        self.click(self.login_accout_loc)

    # 定位器,通过元素属性定位检查项元素对象
示例#13
0
 def __init__(self, driver):
     self.driver = driver
     config = ReadFile()
     self.baseurl = config.readConfig("BaseUrl", "url")
示例#14
0
 def __init__(self):
     config = ReadFile()
     self.browser = config.readConfig("Browser", "browser")
     self.host = config.readConfig("host", "host")
     logger.info("You had select {} host {} browser.".format(
         self.host, self.browser))