Пример #1
0
class mockDataGenerator():
    def __init__(self, language):
        self.fake = Factory().create(language)

    def random_phone_number(self):
        return self.fake.phone_number()

    def random_name(self):
        return self.fake.name()

    def random_address(self):
        return self.fake.addres()

    def random_email(self):
        return self.fake.email()

    def random_ipv4(self):
        return self.fake.ipv4()

    def random_str(self, min_chars=0, max_chars=8):
        return self.fake.pystr(min_chars=min_chars, max_chars=max_chars)

    def random_text(self):
        return self.fake.text()

    def random_timestamp(self):
        return self.fake.unix_time(end_datetime=None)

    def random_int(self):
        return self.fake.pyint()

    def random_bool(self):
        return self.fake.pybool()

    def random_description(self):
        return self.fake.paragraph(nb_sentences=3,
                                   variable_nb_sentences=True,
                                   ext_word_list=None)

    def random_title(self):
        return self.fake.sentence(nb_words=6,
                                  variable_nb_words=True,
                                  ext_word_list=None)

    def random_type(self):
        i = random.randint(0, 10)
        if i == 0:
            type_ = '前端'
        else:
            type_ = '后端'

        return type_
Пример #2
0
class Generator:
    def __init__(self):
        self.fake = Factory().create('zh_CN')

    def random_phone_number(self):
        """随机手机号"""
        return self.fake.phone_number()

    def random_name(self):
        """随机姓名"""
        return self.fake.name()

    def random_address(self):
        """随机地址"""
        return self.fake.address()

    def random_email(self):
        """随机email"""
        return self.fake.email()

    def random_ipv4(self):
        """随机IPV4地址"""
        return self.fake.ipv4()

    def random_str(self, min_chars=0, max_chars=8):
        """长度在最大值与最小值之间的随机字符串"""
        return self.fake.pystr(min_chars=min_chars, max_chars=max_chars)

    def factory_generate_ids(self, starting_id=1, increment=1):
        """ 返回一个生成器函数,调用这个函数产生生成器,从starting_id开始,步长为increment。 """
        def generate_started_ids():
            val = starting_id
            local_increment = increment
            while True:
                yield val
                val += local_increment

        return generate_started_ids

    def factory_choice_generator(self, values):
        """ 返回一个生成器函数,调用这个函数产生生成器,从给定的list中随机取一项。 """
        def choice_generator():
            my_list = list(values)
            # rand = random.Random()
            while True:
                yield random.choice(my_list)

        return choice_generator
Пример #3
0
from faker import Factory

from common.myCommon import Assertion
from common.myCommon.TestBaseCase import TestBaseCase
from common.myFile import MockData as MD
from ymjry.query import xqkj_query as xq
from ymjry.testAction import WebAction
from ymjry.testAction import loginAction
from ymjry.query import xqkj_query

global_dict = loginAction.global_dict
fake = Factory().create('zh_CN')
# 系统用户基本信息
name = loginAction.sign + fake.name_male()
idcard = fake.ssn(min_age=18, max_age=20)
email = loginAction.sign + fake.email()


class test_024_web_urge(TestBaseCase):
    def test_001_api_78dk_platform_urge_collectionPersonnelList_null(self):
        """
        Time       :2019-09-27
        author     : 闫红
        desc       :催收人员管理列表-搜索-v1.5.2,搜索分案状态为空的所有人员
        """
        res = json.loads(
            WebAction.test_api_78dk_platform_urge_user_collectionPersonnelList(
                divisionstate='',
                email='',
                mobile='',
                name='',
Пример #4
0
from faker import Factory

from common.myCommon import Assertion
from common.myCommon.TestBaseCase import TestBaseCase
from xqkj.query import PlatformSystem_query as pq
from xqkj.testAction import PmsAction
from xqkj.testAction import specialAction
from xqkj.testAction import loginAction
from common.myFile import MockData as MD
import time


fake = Factory().create('zh_CN')
user_name = '用户' + loginAction.sign
email = fake.email()


class test_020_pms_user(TestBaseCase):
    def test_001_backstage_user_list(self):
        """
        Time       :2019-07-17
        author     : 闫红
        desc       : 用户列表查询,查询所有
        """
        rs = PmsAction.test_backstage_user_list(name='', currentpage=1, pagesize=10)
        Assertion.verity(json.loads(rs)['code'], 10000)
        Assertion.verity(json.loads(rs)['msg'], "SUCCESS")

    def test_002_backstage_user_list_one(self):
        """
Пример #5
0
from common.myCommon import Assertion
from common.myCommon.TestBaseCase import TestBaseCase
from common.mydb import MysqlClent
from reborn.test import case_stream
from reborn.testAction import PlatformAction as JtlbasicAction, loginAction

fake = Factory().create('zh_CN')
# 商户名称
merchantname = fake.company() + '门店'
# 拒绝商户名称
merchantnamefail = fake.company() + '拒绝'
# s删除机构 法人 结算的商户
merchantnamedele = fake.company() + '删除测试'

# 新增机构 email
email = fake.email()
# 删除机构email
emaildele = fake.email()

# 新增法人信息
name = fake.name_male()
# 删除法人信息
namedele = fake.name_male()

# 计算账户信息
account_name = fake.name_male()
# 删除结算账户信息
account_namedele = fake.name_male()

# 门店信息
st_name = fake.name_male()
Пример #6
0
# 导入faker模块
from faker import Factory

fake = Factory().create(locale="zh_CN")
# print(dir(fake))
for i in range(1, 11):
    print("第{0}次随机产生的数据:".format(i))
    print("用户姓名:{0}".format(fake.name()))
    print("用户名:{0}".format(fake.user_name()))
    print("密码:{0}".format(fake.password()))
    print("电子信箱:{0}".format(fake.email()))
    print("电话号码:{0}".format(fake.phone_number()))
    print("住址:{0}".format(fake.address()))
    print("所在城市:{0}".format(fake.city()))
    print("段落:{0}".format(fake.paragraph()))
    print("文本:{0}".format(fake.text()))
    print("IPv4:{0}".format(fake.ipv4()))
    print("网址:{0}".format(fake.url()))
    print("指定长度的字符串:{0}".format(fake.pystr(min_chars=6, max_chars=12)))
Пример #7
0
from common.myCommon import Assertion
from common.myCommon.TestBaseCase import TestBaseCase
from common.mydb import MysqlClent
from xqkj.test import case_stream
from xqkj.testAction import PlatformAction
from xqkj.testAction import loginAction

fake = Factory().create('zh_CN')
name = fake.name_male()

channelname = fake.company() + '渠道' + loginAction.sign
channelname3 = channelname + '下级' + loginAction.sign
channelname1 = fake.company() + '渠道拒绝' + loginAction.sign
channelname2 = fake.company() + '删除机构测试' + loginAction.sign
email = fake.email()

# 法人名称
# 新增
# name=fake.name_male()
# 测试删除法定代表人
name2 = fake.name_male() + loginAction.sign

# 结算账户名称人
namecount = fake.name_male() + loginAction.sign
# 测试删除账户信息
namecount2 = fake.name_male() + loginAction.sign
# 删除结算账户测试
email2 = fake.email()

# 流程测试渠道
Пример #8
0
# -*- coding: utf-8 -*-
import os
import random
from faker import Factory

from run_path import test_report_path

fake = Factory().create('zh_CN')
print(fake.phone_number())
print(fake.name())
print(fake.address())
print(fake.email())
report = os.path.join(test_report_path(), '59017-12工资单.xls')
os.remove(report)
@desc       : 系统管理接口测试用例   (暂停用)
"""

import json
import unittest

from faker import Factory

from common.myCommon import Assertion as ass
from common.myCommon.TestBaseCase import TestBaseCase
from easyloan.query import easyloan_query as eq
from easyloan.testAction import Easyloan_webAction as ew, loginAction as la

f = Factory().create('zh_CN')
role_name = 'role' + la.sign
addAdmin_email = la.sign + f.email()
addAdmin_password = '******'
addAdmin_phone = f.phone_number()
addAdmin_name = la.sign + f.name()
org_name = la.sign + f.company()
org_address = la.sign + f.street_name()


class testEasyloan_web_003_role(TestBaseCase):
    def test_001_api_78dk_web_role_queryRoleList(self):
        """
          Time       :2019-04-28
          author     : 罗林
          desc       : 分页查询
        """
        rs = ew.test_api_78dk_web_role_queryRoleList(currentpage=1,
Пример #10
0
import json

from faker import Factory

from common.myCommon import Assertion
from common.myCommon.TestBaseCase import TestBaseCase
from common.mydb import MysqlClent
from reborn.testAction import PlatformAction as JtlbasicAction, loginAction

fake = Factory().create('zh_CN')
name = fake.name_male()
name = name + 'test'
idcard = fake.ssn(min_age=18, max_age=20)
phone = fake.ean8()
email = fake.email()
phone = '135' + phone

# 删除用户
name1 = fake.name_male()
name1 = name1 + 'dele'
phone1 = fake.ean8()
email1 = fake.email()
phone1 = '135' + phone1

# 清除用户权限
name2 = fake.name_male()
name2 = name2 + 'clear'
phone2 = fake.ean8()
email2 = fake.email()
phone2 = '135' + phone2
Пример #11
0
import json

from faker import Factory

from common.myCommon import Assertion
from common.myCommon.TestBaseCase import TestBaseCase
from common.mydb import MysqlClent
from xqkj.testAction import PlatformAction
from xqkj.testAction import loginAction
from xqkj.testAction import specialAction

fake = Factory().create('zh_CN')
name = fake.name_male()
name = loginAction.sign + name
idcard = fake.ssn(min_age=18, max_age=20)
email = fake.email()
phone = fake.phone_number()


# 修改用户信息
name3 = fake.name_male()
name3 = loginAction.sign + 'modify' + name3
phone3 = fake.phone_number()
email3 = fake.email()

# 新增用户测试--非email
name4 = fake.name_male()
name4 = loginAction.sign + 'mail' + name4
phone4 = fake.phone_number()
email4 = fake.email()
class TestdataGenerator(object):
    """一些生成器方法,生成随机数,手机号,以及连续数字等"""
    def __init__(self):
        self.fake = Factory().create('zh_CN')

    def random_phone_number(self):
        """随机手机号"""
        return self.fake.phone_number()

    def random_name(self):
        """随机姓名"""
        return self.fake.name()

    def random_address(self):
        """随机地址"""
        return self.fake.address()

    def random_email(self):
        """随机email"""
        return self.fake.email()

    def random_ipv4(self):
        """随机IPV4地址"""
        return self.fake.ipv4()

    def random_str(self, min_chars=0, max_chars=8):
        """长度在最大值与最小值之间的随机字符串,只包含a-zA-Z字母"""
        return self.fake.pystr(min_chars=min_chars, max_chars=max_chars)

    def random_int(self, min_value=0, max_value=9999, exclude=None):
        """返回[min_value, max_value]范围内的一随机数,可排除范围内任意数"""
        if exclude is not None:
            if not isinstance(exclude, list):
                return "exclude must a list"
        else:
            exclude = list()
        while True:
            value = self.fake.pyint(min_value=min_value, max_value=max_value)
            if value not in exclude:
                return value

    def random_letter_digit_str(self, min_chars=0, max_chars=8):
        """长度在最大值与最小值之间的随机字符串,只包含a-zA-Z字母和0-9数字"""
        if min_chars is None:
            return "".join(self.random_letters_digits(length=max_chars))
        else:
            assert (
                max_chars >= min_chars
            ), "Maximum length must be greater than or equal to minium length"
            return "".join(
                self.random_letters_digits(length=random.randint(
                    min_chars, max_chars), ), )

    def random_letters_digits(self, length=16):
        """返回一随机字母、数字字符串(a-z 、A-Z 、0-9)."""
        return self.fake.random_choices(
            getattr(string, 'letters', string.ascii_letters + string.digits),
            length=length,
        )

    def random_punctuation_str(self, min_chars=0, max_chars=8):
        """返回长度在最大值与最小值之间的随机字符串,只包含英文标点符号"""
        if min_chars is None:
            return "".join(self.random_punctuation(length=max_chars))
        else:
            assert (
                max_chars >= min_chars
            ), "Maximum length must be greater than or equal to minium length"
            return "".join(
                self.random_punctuation(length=random.randint(
                    min_chars, max_chars), ), )

    def random_punctuation(self, length=16):
        """返回一随机英文标点符号"""
        return self.fake.random_choices(
            getattr(string, 'letters', string.punctuation),
            length=length,
        )

    @classmethod
    def factory_generate_ids(cls, starting_id=1, increment=1):
        """ 返回一个生成器函数,调用这个函数产生生成器,从starting_id开始,步长为increment。 """
        def generate_started_ids():
            val = starting_id
            local_increment = increment
            while True:
                yield val
                val += local_increment

        return generate_started_ids

    @classmethod
    def factory_choice_generator(cls, values):
        """ 返回一个生成器函数,调用这个函数产生生成器,从给定的list中随机取一项。 """
        def choice_generator():
            my_list = list(values)
            while True:
                yield random.choice(my_list)

        return choice_generator
Пример #13
0
class DataGenerator(object):
    """随机数据生成器"""
    def __init__(self):
        self.fake = Factory().create('zh_CN')

    def random_phone_number(self):
        """
		随机手机号码
		:return:
		"""
        return self.fake.phone_number()

    def random_name(self):
        """
		随机姓名
		:return:
		"""
        return self.fake.name()

    def random_address(self):
        """
		随机地址
		:return:
		"""
        return self.fake.address()

    def random_email(self):
        """
		随机email
		:return:
		"""
        return self.fake.email()

    def random_ipv4(self):
        """
		随机ip地址
		:return:
		"""
        return self.fake.ipv4()

    def random_str(self, min_char=0, max_char=8):
        """
		随机字符,默认8个
		:return:
		"""
        return self.fake.pystr(min_chars=min_char, max_chars=max_char)

    @staticmethod
    def random_chinese_characters(i=1):
        """随机中文汉字"""
        s = ""
        if i < 11:
            s = xeger.xeger(u"[\\u4e00-\\u9fa5]{}".format("{" + str(i) + "}"))
        else:
            j = i // 10
            k = i % 10

            while j > 0:
                a = xeger.xeger(u"[\\u4e00-\\u9fa5]{10}")
                s = s + a
                j -= 1
                if j == 0:
                    a = xeger.xeger(
                        u"[\\u4e00-\\u9fa5]{}".format("{" + str(k) + "}"))
                    s = s + a
        return s
Пример #14
0
import json
from faker import Factory
from common.myCommon import Assertion
from common.myCommon.TestBaseCase import TestBaseCase
from ymjry.query import xqkj_query
from ymjry.testAction import WebAction
from ymjry.testAction import loginAction
from ymjry.testAction import specialAction

global_dict = loginAction.global_dict
fake = Factory().create('zh_CN')
# 系统用户基本信息
name = loginAction.sign + fake.name_male()
idcard = fake.ssn(min_age=18, max_age=20)
email = loginAction.sign + fake.email()
phone = '131' + fake.ean8()

# 修改用户信息
name3 = loginAction.sign + 'modify' + fake.name_male()
phone3 = '131' + fake.ean8()
email3 = loginAction.sign + fake.email()

# 新增用户测试--非email
name4 = loginAction.sign + 'mail' + fake.name_male()
phone4 = '131' + fake.ean8()
email4 = loginAction.sign + fake.email()

# 新增报表
name_report = fake.name_male() + 'vcvdsfsdfsdfdsfsdfdsfxx报表'
address_report = 'www.baidu.com'
Пример #15
0
temp_shop = ['已勾选', '未勾选']
temp_order = ['已付款', '未付款']
temp_pay_en = ['淘宝', '京东', '拼多多', '唯品会']
temp_pay = ['支付成功', '支付失败']
temp_obj = ['衣', '食', '住', '行']
fake = Factory().create('zh_CN')
users, shops, orders, orders_chl, pays, objs = [], [], [], [], [], []
obj_name_ = []
for _ in range(30):
    name = fake.name()
    while True:
        obj_name = fake.color_name()
        if obj_name not in obj_name_:
            obj_name_.append(obj_name)
            break
    users.append(User(name, fake.password(), fake.email(), fake.address()))
    objs.append(
        Obj(temp_obj[random.randint(0, 3)], obj_name, random.randint(1, 1000)))
    shops.append(
        Shop(name=name,
             obj_name='None',
             number=random.randint(1, 500),
             status=temp_shop[random.randint(0, 1)]))
#print("INSERT INTO `用户` (`用户名`, `密码`, `邮箱`) VALUES ",end="")

for index in range(30):
    i = random.randint(0, 29)
    id = fake.ean8()
    shops[index].obj_name = objs[i].obj_name
    orders.append(
        Order(id, users[i].name, users[i].address, random.randint(1, 1000),
Пример #16
0
import json

from faker import Factory

from common.myCommon import Assertion
from common.myCommon.TestBaseCase import TestBaseCase
from common.mydb import MysqlClent
from reborn.test import case_stream
from reborn.testAction import PlatformAction as JtlbasicAction, loginAction

fake = Factory().create('zh_CN')
name = fake.name_male()

# 渠道
channelname_stream = fake.company() + '渠道' + '下级stream'
email_stream = fake.email()
name_stream = fake.name_male()
namecount_stream = fake.name_male()
# 商户
# 与产品绑定的商户
merchantname_stream = fake.company() + '流程stream'
account_name_stream = fake.name_male()
st_name_stream = fake.name_male()
# 产品使用资金包
pFundSidename = fake.name_male() + '资方名stream'
pFundPackagename = fake.name_male() + '资金包名stream'
# 解绑商户
merchantname_stream_del = fake.company() + 'dele'
# 产品名称
productname = fake.name_male()
# 解除产品绑定
Пример #17
0
@Author     : 罗林
@File       : loginAction.py
@desc       : 
"""

import requests
import json
from common.myConfig import ConfigUtils as conf
from common.myConfig import MysqlConfig
from common.mydb import MysqlClent
from faker import Factory

fake = Factory().create('zh_CN')
nameadmin = fake.name_male() + 'stream管理员'
phoneadmin = fake.ean8()
emailadmin = fake.email()
phoneadmin = '135' + phoneadmin
DB = MysqlClent.get_conn('192.168.15.129', 3306, 'cgi78dkv23', 'cgi78dk', 'dfljlcl39*33$@e')
# baseUrl = "http://test.jtlservice.78dk.cgi78dkom"
baseUrl = MysqlConfig.get('platform_apiURL', 'reborn')
sign = conf.get('report', 'sign')


def login():
    # 管理员用户
    # 新增用户测试--非email
    url = baseUrl + '/api/78dk/platform/sys/user/login'
    payload = {"email": "*****@*****.**", "password": "******"}
    headers = {'content-type': 'application/json'}
    r = requests.post(url, data=json.dumps(payload), headers=headers)
    token = r.json()['data']['token']