예제 #1
0
    def test_exchange_post(self, with_login):
        exchange_api = ExchangeManagementApi()
        user = self.data['user']
        email, password = user['email'], user['password']
        token = with_login('tenant', [exchange_api], email, password)
        id_number = get_random_id_number()
        individual_verify('tenant', id_number, token)
        e = Exchange(exchange_api, token)
        exchange = e.get_exchange()
        exchange_api.exchange_post(exchange)
        rv = exchange_api.exchange_exchange_status_get()
        assert rv.status == 'pending'
        # 初审
        audit_api = AuditApi()
        uid = self.data['account_id']
        admin_token = get_admin_token()
        set_login_status(audit_api, admin_token)
        rv = audit_api.tenant_audits_get(uid=uid,
                                         exchange_name=exchange.name,
                                         type='audit')
        task = rv.items[0]
        task_id = task.id
        res = PostTenantAuditRequest(id=task_id, is_data_received=True,
                                     status='approved',
                                     failure_type='ENTERPRISE_LICENSE')
        audit_api.tenant_audits_audit_post(res)
        # 复审
        res = PostTenantReAuditRequest(id=task_id,
                                       status='disapproved',
                                       failure_type=1)
        audit_api.tenant_audits_re_audit_post(res)

        rv = exchange_api.exchange_exchange_status_get()
        assert rv.status == 'disapproved'
예제 #2
0
 def test_legals_trans_coin_fail(self, amount, coin_name, otc_user):
     """
     法币化转到币币失败
     """
     # 后台登录验证
     staff_token = get_admin_token()
     set_login_status(staff_balance_api, staff_token)
     set_login_status(staff_asset_api, staff_token)
     user_res_info = otc_user([otc_balance_api, otc_asset_api])
     coin_id = user_res_info['buyer_coin_id']
     # 获取otc法币余额,币币余额
     before_res1 = otc_balance_api.balance_info_currency_id_get(
         currency_id=coin_id)
     assert before_res1
     before_res2 = otc_asset_api.asset_mgmt_assets_coin_id_get(
         coin_id=coin_id)
     assert before_res2
     # 币币划转到法币失败
     transload = TransferToRequest(currency_id=coin_id, amount=amount)
     try:
         otc_balance_api.balance_transfer_to_post(transload)
     except ApiException as e:
         assert e.status == 400
     # 获取otc法币余额,币币余额
     after_res1 = otc_balance_api.balance_info_currency_id_get(
         currency_id=coin_id)
     assert round(float(after_res1.available),
                  8) == round(float(before_res1.available), 8)
     after_res2 = otc_asset_api.asset_mgmt_assets_coin_id_get(
         coin_id=coin_id)
     assert round(float(after_res2.balance),
                  8) == round(float(before_res2.balance), 8)
예제 #3
0
 def test_models_case1(self):
     # 后台登录
     content_api = ContentManagementApi()
     staff_token = get_admin_token()
     set_login_status(content_api, staff_token)
     # 新建文章模型
     payload = {
         'identification': get_random_name(2, 50),
         'name': get_random_name(2, 50),
         'status': True,
         'order': random.randint(100000, 999999),
         'type': 'article'  # article文章,kinmall金猫
     }
     content_api.models_post(body=payload)
     # 获取文章模型列表
     res = content_api.models_get(type='article')
     for item in res.items:
         if item.name == payload['name']:
             assert item.identification == payload['identification']
             assert item.id
     # 获取文章模型名称列表
     res = content_api.models_names_get(type='article')
     id_ = ''
     for item in res.items:
         if item.name == payload['name']:
             assert item.id
             id_ = item.id
     # 获取文章模型详情
     res = content_api.models_id_get(id=id_)
     assert res.name == payload['name']
     assert res.status == payload['status']
     assert res.order == payload['order']
     assert res.type == payload['type']
     assert res.identification == payload['identification']
예제 #4
0
 def test_bind_device(self, device_type):
     manager = PlatformManager("main")
     device_api = DeviceManagerApi()
     user = random_user()
     email = user.get("email")
     password = user.get("password")
     country = user.get("country_abbreviation")
     manager.register(email=email,
                      password=password,
                      promotion_code=None,
                      verification_code="666666",
                      nationality_code=country,
                      challenge=self.challenge,
                      sec_code=self.sec_code,
                      validate=self.validate)
     token = manager.login(account=email,
                           password=password,
                           challenge=self.challenge,
                           sec_code=self.sec_code,
                           validate=self.validate)
     set_login_status(device_api, token)
     device_id = uuid.uuid4().hex
     device_type = device_type
     device_api.device_bind_post(device_id=device_id,
                                 device_type=device_type)
     device_api.device_unbind_post(device_id=device_id,
                                   device_type=device_type)
예제 #5
0
 def test_get_coin_config(self):
     (coin_id, coin_id_, coin_name, rc_confirmed_time,
      wc_confirmed_time) = create_venture()
     admin_token = get_admin_token()
     api = AssetManagementApi()
     set_login_status(api, admin_token)
     # 设置充提币
     api.asset_mgmt_coins_id_recharge_put(id=coin_id, rechargeable=True)
     api.asset_mgmt_coins_id_withdraw_put(id=coin_id, withdrawable=True)
     # 获取币种列表
     res = api.asset_mgmt_coins_get(coin_name=coin_name)
     assert len(res.items) == 1
     coin_config = res.items.pop()
     assert coin_config.coin_name == coin_name.upper()
     assert coin_config.coin_id == coin_id_
     assert coin_config.id == coin_id
     assert coin_config.rechargeable
     assert coin_config.withdrawable
     assert coin_config.initialized
     # 通过id获取币种配置
     res = api.asset_mgmt_coins_id_get(id=coin_id)
     assert res.id == coin_id
     # 获取币种提示信息
     api.asset_mgmt_coins_id_prompt_get(id=coin_id)
     # 修改币种提示信息
     api.asset_mgmt_coins_id_prompt_put(id=coin_id,
                                        body={"prompt": "prompt"})
     # 获取币种提示信息
     res = api.asset_mgmt_coins_id_prompt_get(id=coin_id)
     assert res.prompt == "prompt"
예제 #6
0
 def test_revenue(self):
     admin_token = get_admin_token()
     api = AssetManagementApi()
     set_login_status(api, admin_token)
     res = api.asset_mgmt_revenue_get(coin_id="1")
     assert res.meta.requested_page == 1
     assert res.query.coin_id == "1"
예제 #7
0
def get_project(token):
    v_api = VentureApi()
    set_login_status(v_api, token)
    today = datetime.today().date()
    while True:
        project_name = "project" + str(random.randint(1, 10000))
        rv = v_api.applications_check_project_name_post(project_name)
        if not rv.result:
            break
    return {
        "projectName": project_name,
        "description": "XXXXXXXXXXXXXXXX",
        "officialWebsite": "www.xxxx.com",
        "whitePaperKey": "url/pdf123455",
        "areaCode": "+86",
        "projectPosterKey": 'f210c0d8a4e747cb8438031fe2b99931',
        "cellphone": "13510022445",
        "telephone": 12874846,
        "email": "*****@*****.**",
        "fullName": get_random_coin_full_name(),
        "shortName": get_random_coin_short_name(),
        "issuePrice": "2.24545",
        "issuedVolume": "1000000",
        "circulationVolume": "1000000",
        "issuedDate": str(today),
        "coinLogoKey": 'f210c0d8a4e747cb8438031fe2b99931',
        "blockchainType": "public_chain",
        "dataLink": "www.baidu.com",
        "blockBrowser": "www.baidu.com"
    }
예제 #8
0
    def test_exchange_post(self, with_login):
        user = self.data['user']
        exchange_api = ExchangeManagementApi()
        email, password = user['email'], user['password']
        token = with_login('tenant', [exchange_api], email, password)
        id_number = get_random_id_number()
        individual_verify('tenant', id_number, token)
        e = Exchange(exchange_api, token)
        exchange = e.get_exchange()
        exchange_api.exchange_post(exchange)
        rv = exchange_api.exchange_exchange_status_get()
        assert rv.status == 'pending'
        audit_api = AuditApi()
        uid = self.data['account_id']
        admin_token = get_admin_token()
        set_login_status(audit_api, admin_token)
        rv = audit_api.tenant_audits_get(uid=uid,
                                         exchange_name=exchange.name,
                                         type='audit')
        task = rv.items[0]
        task_id = task.id
        res = PostTenantAuditRequest(id=task_id, is_data_received=True,
                                     status='approved',
                                     failure_type='ENTERPRISE_LICENSE')
        audit_api.tenant_audits_audit_post(res)
        # 复审
        res = PostTenantReAuditRequest(id=task_id,
                                       status='approved',
                                       failure_type='ENTERPRISE_LICENSE')
        audit_api.tenant_audits_re_audit_post(res)

        rv = exchange_api.exchange_exchange_status_get()
        assert rv.status == 'approved'
        rv = exchange_api.exchange_exchange_id_get()
        exchange_id = rv.id
        TestExchange10.data['exchange_id'] = exchange_id
        TestExchange10.data['exchange'] = exchange
        # 用另外一个账号再创建一个交易所
        manager = PlatformManager('tenant')
        account_api = AccountApi()
        api = manager.account_api
        verify_api = manager.verify_api
        user = register_with_login('tenant', with_login,
                                   [api, verify_api, account_api])
        token1 = user['token']
        id_number = get_random_id_number()
        individual_verify('tenant', id_number, token1)
        exchange1 = e.get_exchange()
        exchange_api.exchange_get()
        name_used = exchange1.name
        # 用已有的交易所名称更新前一个交易所
        r = GetExchangeRequest(name=name_used)
        try:
            exchange_api.exchange_put(r)
        except ApiException as e:
            assert e.status == 400
        else:
            assert False, '交易所名称已经注册'
    def test_investors(self, with_login):
        """3.未开通交易所——获取投资人列表列表———投资人详情(exchange id is None)"""
        manager = PlatformManager('tenant')
        account_api = AccountApi()
        api = manager.account_api
        verify_api = manager.verify_api
        user = register_with_login('tenant', with_login,
                                   [api, verify_api, account_api])
        # 绑定电话
        email = user.get('email')
        faker = Faker('zh_CN')
        phone = faker.phone_number()
        verify = verify_info(manager, email, "bind_phone")
        manager.bind_phone(phone, DEFAULT_VERIFY_CODE,
                           area_code="+86", token=verify.token)

        account_info = account_api.accounts_account_info_get()
        account_id = account_info.account_info.account_id

        exchange_api = ExchangeManagementApi()
        email, password = user['email'], user['password']
        token = with_login('tenant', [exchange_api], email, password)
        id_number = get_random_id_number()
        individual_verify('tenant', id_number, token)
        e = Exchange(exchange_api, token)
        exchange = e.get_exchange()
        exchange_api.exchange_post(exchange)
        rv = exchange_api.exchange_exchange_status_get()
        assert rv.status == 'pending'
        audit_api = AuditApi()
        admin_token = get_admin_token()
        set_login_status(audit_api, admin_token)
        rv = audit_api.tenant_audits_get(uid=account_id,
                                         exchange_name=exchange.name,
                                         type='audit')
        task = rv.items[0]
        task_id = task.id
        res = PostTenantAuditRequest(id=task_id, is_data_received=True,
                                     status='approved')
        audit_api.tenant_audits_audit_post(res)
        # 复审不通过
        res = PostTenantReAuditRequest(id=task_id,
                                       status='disapproved',
                                       failure_type='ENTERPRISE_LICENSE')
        audit_api.tenant_audits_re_audit_post(res)

        api = AccountManagementApi()
        admin_token = get_admin_token()
        set_login_status(api, admin_token)
        a_api = AccountApi()
        token = with_login('tenant', [a_api], email, password)
        account_info = a_api.accounts_account_info_get()
        account_id = account_info.account_info.account_id
        rv = api.accounts_investors_get(account_id=account_id)
        investors = rv.items
        assert len(investors) > 0
        rv = api.accounts_accounts_id_get(id=account_id)
        assert rv.basic_info.exchange_id is None
예제 #10
0
 def test_coin_market(self, with_login):
     manager = PlatformManager('tenant')
     m_api = MarketManagementApi()
     e_api = ExchangeManagementApi()
     api = manager.account_api
     verify_api = manager.verify_api
     account_api = AccountApi()
     user = register_with_login(
         'tenant', with_login, [api, verify_api, m_api, e_api, account_api])
     self.data['user'] = user
     token = user['token']
     email = user.get('email')
     # 绑定电话
     faker = Faker('zh_CN')
     phone = faker.phone_number()
     verify = verify_info(manager, email, "bind_phone")
     manager.bind_phone(phone,
                        DEFAULT_VERIFY_CODE,
                        area_code="+86",
                        token=verify.token)
     id_number = get_random_id_number()
     individual_verify('tenant', id_number, token)
     exchange_api = ExchangeManagementApi()
     e = Exchange(exchange_api, token)
     exchange = e.get_exchange()
     e_api.exchange_post(exchange)
     # 获取交易对市场列表
     try:
         m_api.markets_get()
     except ApiException as e:
         # 交易所不存在
         assert e.status == 400
     else:
         assert False, '市场应当不存在'
     # 初审复审
     rv = account_api.accounts_account_info_get()
     account_id = rv.account_info.account_id
     self.data['account_id'] = account_id
     audit_api = AuditApi()
     admin_token = get_admin_token()
     set_login_status(audit_api, admin_token)
     rv = audit_api.tenant_audits_get(uid=account_id,
                                      exchange_name=exchange.name,
                                      type='audit')
     task = rv.items[0]
     task_id = task.id
     res = PostTenantAuditRequest(id=task_id,
                                  is_data_received=True,
                                  status='approved')
     audit_api.tenant_audits_audit_post(res)
     # 复审
     res = PostTenantReAuditRequest(id=task_id, status='approved')
     audit_api.tenant_audits_re_audit_post(res)
     rv = e_api.exchange_exchange_id_get()
     exchange_id = rv.id
     self.data['exchange_id'] = exchange_id
    def test_add_times_limit(self, otc_user):
        payload = PostPaymodeRequest()
        type_map = {"bank": 3, "ali_pay": 2, "we_chat": 1}
        payload.status = 0
        ways = ["bank", "ali_pay", "we_chat"]
        pay_ids = []
        user_info = otc_user([pay_mode_api])
        payload.asset_password = user_info['asset_password']
        for i in range(10):
            payload.qrcode = get_random_lowercase(10)
            payload.account = f"liujun@19{i}.com"
            way = random.choice(ways)
            payload.type = type_map[way]
            if way == 'bank':
                payload.bank_name = "招商银行"
                payload.branch_name = "深圳罗湖支行"
            pay_way_res = pay_mode_api.paymode_add_post(body=payload)
            pay_ids.append(pay_way_res.id)

        # 测试最多可以三个启用
        first_three = pay_ids[:3]
        print(first_three)
        for i in first_three:
            pay_mode_api.paymode_enable_paymode_id_put(paymode_id=i)

        try:
            paymode_id = pay_ids[5]
            pay_mode_api.paymode_enable_paymode_id_put(paymode_id=paymode_id)
        except ApiException as e:
            assert e.status == 400

        # 后台获取开启的支付方式列表
        pay_mode_api.paymode_disable_paymode_id_put(paymode_id=first_three[2])
        set_login_status(staff_pay_mode_api, user_info['admin_token'])
        opend_paymodes = staff_pay_mode_api.admin_paymode_user_list_get(user_id=user_info['account_id'])
        assert set(first_three[:2]) == set([i.id for i in opend_paymodes.items])

        # 测试最多十个
        way = random.choice(ways)
        payload.type = type_map[way]
        if way == 'bank':
            payload.bank_name = "招商银行"
            payload.branch_name = "深圳罗湖支行"
        try:
            pay_mode_api.paymode_add_post(body=payload)
        except ApiException as e:
            assert e.status == 400

        # 删除支付方式
        pay_mode_api.paymode_delete_paymode_id_delete(pay_ids[9])

        # 获取自己的支付方式列表
        my_pay_modes = pay_mode_api.paymode_my_list_get(page_size=10)
        assert len(my_pay_modes.items) == 9
    def test_application_success(self, otc_business_user):
        """
        otc平台获取账户id,otc平台申请成为商家,后台管理获取申请列表,后台管理查看申请记录,后台管理审核申请
        """
        otc_business_user([otc_buss_api, otc_ac_api])
        return
        # 后台登录
        staff_token = get_admin_token()
        set_login_status(staff_buss_api, staff_token)
        set_login_status(staff_sys_api, staff_token)
        # ot平台获取账户id
        ac_info = otc_ac_api.accounts_account_info_get()
        assert ac_info
        ac_id = ac_info.account_info.account_id

        # otc平台申请成为商家
        otc_buss_api.biz_apply_post()
        biz_info = otc_buss_api.biz_info_get()
        assert biz_info.code == 1

        # otc平台查询押金信息
        otc_margin_res = otc_buss_api.biz_margin_info_get()
        logger.info(f'押金信息:{otc_margin_res}')

        # 后台管理获取申请列表
        application_rec = staff_buss_api.admin_biz_find_page_get(user_id=ac_id)
        order_num = application_rec.items[0].id
        logger.info(f'后台申请列表:{application_rec}')
        # 后台管理查看申请记录
        staff_biz_info = staff_buss_api.admin_biz_info_get(id=order_num)
        assert staff_biz_info.status == 1

        # 后台管理审核申请成功
        success_reaason = '您的信良好,继续保持'
        payload = AuditRequest(id=order_num,
                               status=2,
                               reason=success_reaason,
                               file_recved=1)
        staff_buss_api.admin_biz_audit_post(payload)

        # 检查后台查看申请记录
        staff_app_list = staff_buss_api.admin_biz_find_page_get(user_id=ac_id)
        order_id = staff_app_list.items[0].id
        assert staff_app_list.items[0].status == 2

        # 后台管理查看申请记录
        staff_biz_info2 = staff_buss_api.admin_biz_info_get(id=order_id)
        assert staff_biz_info2.status == 2
        # 检查otc平台结果
        biz_res = otc_buss_api.biz_info_get()
        assert biz_res and biz_res.code == 2
        assert biz_res.reason == success_reaason
예제 #13
0
 def test_models_case11(self):
     # 后台登录
     content_api = ContentManagementApi()
     staff_token = get_admin_token()
     set_login_status(content_api, staff_token)
     # 新建文章模型
     payload = {
         'identification': get_random_name(2, 50),
         'name': get_random_name(2, 50),
         'status': True,
         'order': random.randint(1000, 9999),
         'type': 'kinmall'  # article文章,kinmall金猫
     }
     content_api.models_post(body=payload)
     # 获取文章模型列表
     models_id = ''
     page = 1
     res = content_api.models_get(type='kinmall', page=page)
     total_page = res.meta.total_page
     while page <= total_page:
         res = content_api.models_get(type='kinmall', page=page)
         for item in res.items:
             if item.name == payload['name']:
                 assert item.status is True
                 assert item.order == payload['order']
                 assert item.type == 'kinmall'
                 models_id = item.id
         page += 1
     # 新建子模型
     sub_payload = {
         "identification": get_random_name(2, 50),
         "name": get_random_name(2, 50),
         "status": True,
         "order": random.randint(1000, 9999),
         "modelId": models_id
     }
     content_api.sub_models_post(body=sub_payload)
     # 获取子模型列表
     id_ = ''
     res = content_api.sub_models_get(parent_id=models_id)
     for item in res.items:
         if item.name == sub_payload['name']:
             assert item.status is True
             assert item.order == sub_payload['order']
             id_ = item.id
     # 获取子模型详情
     res = content_api.sub_models_id_get(id=id_)
     assert res.name == sub_payload['name']
     assert res.status == sub_payload['status']
     assert res.order == sub_payload['order']
예제 #14
0
    def test_exchange_post(self, with_login):
        exchange_api = ExchangeManagementApi()
        user = self.data['user']
        email, password = user['email'], user['password']
        token = with_login('tenant', [exchange_api], email, password)
        id_number = get_random_id_number()
        individual_verify('tenant', id_number, token)
        e = Exchange(exchange_api, token)
        exchange = e.get_exchange()
        exchange_api.exchange_post(exchange)
        rv = exchange_api.exchange_exchange_status_get()
        assert rv.status == 'pending'
        # 初审
        audit_api = AuditApi()
        admin_token = get_admin_token()
        set_login_status(audit_api, admin_token)
        uid = self.data['account_id']
        rv = audit_api.tenant_audits_get(uid=uid,
                                         exchange_name=exchange.name,
                                         type='audit')
        task = rv.items[0]
        task_id = task.id
        res = PostTenantAuditRequest(id=task_id, is_data_received=True,
                                     status='approved',
                                     failure_type='ENTERPRISE_LICENSE')
        audit_api.tenant_audits_audit_post(res)
        # 复审
        res = PostTenantReAuditRequest(id=task_id,
                                       status='approved',
                                       failure_type='ENTERPRISE_LICENSE')
        audit_api.tenant_audits_re_audit_post(res)
        rv = exchange_api.exchange_exchange_status_get()
        assert rv.status == 'approved'
        rv = exchange_api.exchange_get()
        assert rv.name == exchange.name
        assert rv.logo_key == exchange.logo
        assert rv.email == exchange.email
        assert rv.nationality == exchange.nationality
        exchange.logo = img1
        exchange_api.exchange_put(exchange)
        rv = exchange_api.exchange_get()
        assert rv.name == exchange.name
        assert rv.logo_key == exchange.logo
        assert rv.email == exchange.email
        assert rv.nationality == exchange.nationality

        """合并测试用例"""
        """12.交易所审核通过——获取交易所ID——获取交易所买卖方币种列表"""
        coin = exchange_api.exchange_exchange_coin_get()
        assert coin.seller_coin == []
예제 #15
0
 def test_post_tag(self):
     """创建tag"""
     api = WebsiteManagementApi()
     admin_token = get_admin_token()
     set_login_status(api, admin_token)
     res = PostExchangeTagsRequest()
     res.name = 'test_tag_' + str(random.randint(1, 10000))
     res.other_language = [
         {
             'key': '英语',
             'value': 'public_chain'
         }
     ]
     api.exchange_tags_post(res)
예제 #16
0
    def test_exchange_post(self, with_login):
        audit_api = AuditApi()
        user = self.data['user']
        email = user['email']
        password = user['password']
        exchange_api = ExchangeManagementApi()
        token = with_login('tenant', [exchange_api], email, password)
        id_number = get_random_id_number()
        individual_verify('tenant', id_number, token)
        e = Exchange(exchange_api, token)
        exchange = e.get_exchange()
        exchange_api.exchange_post(exchange)

        admin_token = get_admin_token()
        set_login_status(audit_api, admin_token)
        # 初审
        uid = self.data['account_id']
        rv = audit_api.tenant_audits_get(uid=uid,
                                         exchange_name=exchange.name,
                                         type='audit')
        task = rv.items[0]
        task_id = task.id
        res = PostTenantAuditRequest(id=task_id, is_data_received=True,
                                     status='approved', failure_type=1)
        audit_api.tenant_audits_audit_post(res)
        # 复审
        res = PostTenantReAuditRequest(id=task_id,
                                       status='approved',
                                       failure_type=None)
        audit_api.tenant_audits_re_audit_post(res)
        rv = exchange_api.exchange_exchange_status_get()
        assert rv.status == 'approved'
        try:
            user1 = self.data['user1']
            email1, password1 = user1['email'], user1['password']
            exchange_api1 = ExchangeManagementApi()
            token1 = with_login('tenant', [exchange_api1], email1, password1)
            id_number = get_random_id_number()
            individual_verify('tenant', id_number, token1)
            # print(token1)
            exchange1 = e.get_exchange()
            exchange1.name = exchange.name
            # pprint(exchange1)
            exchange_api1.exchange_post(exchange1)
        except ApiException as e:
            assert e.status == 400
        else:
            assert False, '交易所名称重复不应当创建'
        assert exchange_name_verify(token, exchange.name), '交易所名称应当已经存在'
예제 #17
0
 def test_exchange_list(self):
     """1.前台申请交易所并审核成功——获取交易所列表——获取交易所详情"""
     # 获取交易所列表
     api = StaffExchangeManagementApi()
     admin_token = get_admin_token()
     set_login_status(api, admin_token)
     exchange_id = TestExchange10.data['exchange_id']
     res = api.exchanges_get(exchange_id=exchange_id)
     assert len(res.items) == 1
     exchange_name = TestExchange10.data['exchange'].name
     assert len(res.items) >= 1
     # 获取交易所详情
     rv = api.exchange_id_get(id=exchange_id)
     assert rv.exchange_name == exchange_name
     assert rv.exchange_id == exchange_id
    def test_down_ad(self, status, action, test_type, otc_user):
        ad_creator = otc_user([ad_api, pay_mode_api])
        pay_way_id = create_paymode(pay_mode_api, ad_creator['asset_password'])
        price, amount = get_random_data()
        # 卖币
        response = create_ad(ad_api, (price, amount),
                             ad_creator['buyer_coin_id'],
                             ad_creator['asset_password'])

        # 创建用户
        order_creator = otc_user([order_api])

        if status == 'up_no_transaction':
            ad_api.advertise_put_off_ad_id_post(ad_id=response.ad_id)
            ad_on_lines = ad_api.advertise_online_list_get(
                currency_id=ad_creator['buyer_coin_id'],
                type='2',
                page_size=10)
            ids = [i.ad_id for i in ad_on_lines.items]
            assert response.ad_id not in ids
            return
        # 创建买币订单
        set_login_status(pay_mode_api, order_creator['user_token'])
        create_paymode(pay_mode_api, order_creator['asset_password'])
        create_order = CreateOrderRequest(ad_id=response.ad_id, amount=amount)
        res = order_api.order_create_post(create_order)
        ad_info = ad_api.advertise_info_ad_id_get(ad_id=response.ad_id)
        assert ad_info.status == 1  # 交易未成功,广告不下线

        # 买家确认
        order_api.order_buyer_paid_order_id_paymode_id_post(
            order_id=res.order_id, paymode_id=pay_way_id)
        # 卖家确认放行
        set_login_status(order_api, ad_creator['user_token'])
        order_api.order_seller_confirm_order_id_post(order_id=res.order_id)

        # 不在上线广告内
        time.sleep(1)
        ad_on_lines = ad_api.advertise_online_list_get(
            currency_id=ad_creator['buyer_coin_id'], type='2', page_size=10)
        ids = [i.ad_id for i in ad_on_lines.items]
        assert response.ad_id not in ids

        order_info = order_api.order_info_order_id_get(order_id=res.order_id)
        assert order_info.status == 30

        ad_info = ad_api.advertise_info_ad_id_get(ad_id=response.ad_id)
        assert ad_info.status == 2  # 交易成功
 def test_favorite_project_case9(self):
     faker = Faker()
     manager = PlatformManager("main")
     email = random_email()
     password = faker.password()
     country = random_get_country_ob()
     manager.register(email=email,
                      password=password,
                      promotion_code=None,
                      verification_code="666666",
                      nationality_code=country.get("k"))
     token = manager.login(account=email, password=password)
     # 个人实名认证
     individual_verify(platform="main",
                       id_number=get_random_id_number(),
                       token=token)
     # 交易所排行列表
     exchange_api = ExchangeApi()
     set_login_status(exchange_api, token)
     res = exchange_api.exchanges_exchanges_get()
     exchange_id = ''
     for item in res.items:
         exchange_id = item.id
     # 收藏列表
     favorite_api = FavoriteExchangeApi()
     set_login_status(favorite_api, token)
     res = favorite_api.favorites_exchange_get(page=1)
     assert res.meta.total_count == 0
     # 收藏
     payload = {
         'exchangeId': exchange_id,
     }
     favorite_api.favorites_exchange_post(body=payload)
     # 收藏列表
     res = favorite_api.favorites_exchange_get(page=1)
     id_ = ''
     assert res.meta.total_count == 1
     for item in res.items:
         assert item.exchange_id == exchange_id
         assert item.id
         assert item.exchange_name
         id_ = item.id
     # 取消收藏
     favorite_api.favorites_exchange_delete(id=id_)
     # 收藏列表
     res = favorite_api.favorites_exchange_get(page=1)
     assert res.meta.total_count == 0
예제 #20
0
    def test_exchange_post(self, with_login):
        audit_api = AuditApi()
        user = self.data['user']
        email = user['email']
        password = user['password']
        exchange_api = ExchangeManagementApi()
        e_api = ExchangeApi()
        f_api = FavoriteManagementApi()
        token = with_login('tenant',
                           [exchange_api, e_api, f_api],
                           email, password)
        id_number = get_random_id_number()
        individual_verify('tenant', id_number, token)
        e = Exchange(exchange_api, token)
        exchange = e.get_exchange()
        exchange_api.exchange_post(exchange)
        rv = exchange_api.exchange_exchange_status_get()
        assert rv.status == 'pending'
        admin_token = get_admin_token()
        set_login_status(audit_api, admin_token)
        # 初审
        uid = self.data['account_id']
        rv = audit_api.tenant_audits_get(uid=uid,
                                         exchange_name=exchange.name,
                                         type='audit')
        task = rv.items[0]
        task_id = task.id
        res = PostTenantAuditRequest(id=task_id, is_data_received=True,
                                     status='approved')
        audit_api.tenant_audits_audit_post(res)
        # 初审详情
        rv = audit_api.tenant_audits_results_id_company_audit_get(task_id)
        assert rv.audit_status == 'approved'
        assert rv.uid == uid
        # 复审
        res = PostTenantReAuditRequest(id=task_id,
                                       status='disapproved')
        audit_api.tenant_audits_re_audit_post(res)
        # 复审详情
        rv = audit_api.tenant_audits_results_id_company_re_audit_get(task_id)
        assert rv.audit_status == 'approved'
        assert rv.uid == uid
        assert rv.re_status == 'disapproved'

        rv = exchange_api.exchange_exchange_status_get()
        assert rv.status == 'disapproved'
예제 #21
0
        def biz_apply():
            # 后台登录
            admin_token = get_admin_token()
            user_res_info["admin_token"] = admin_token
            set_login_status(staff_buss_api, admin_token)

            # 前端申请
            # 后端通过
            otc_buss_api.biz_apply_post()
            admin_biz_rec = staff_buss_api.admin_biz_find_page_get(user_id=user_res_info['account_id'])
            order_num = admin_biz_rec.items[0].id

            staff_buss_api.admin_biz_info_get(id=order_num)

            success_reaason = "您的信良好"
            payload = AuditRequest(id=order_num, status=2, reason=success_reaason, file_recved=1)
            staff_buss_api.admin_biz_audit_post(payload)
예제 #22
0
 def test_investors(self, with_login):
     """3.前台已开通交易所——获取用户列表——获取账号信息详情"""
     api = AccountManagementApi()
     admin_token = get_admin_token()
     set_login_status(api, admin_token)
     a_api = AccountApi()
     user = self.data['user']
     email, password = user['email'], user['password']
     token = with_login('tenant', [a_api], email, password)
     account_info = a_api.accounts_account_info_get()
     account_id = account_info.account_info.account_id
     rv = api.accounts_investors_get(account_id=account_id)
     investors = rv.items
     assert len(investors) > 0
     rv = api.accounts_accounts_id_get(id=account_id)
     exchange_id = TestExchange10.data['exchange_id']
     assert rv.basic_info.exchange_id == exchange_id
예제 #23
0
 def test_sponsor_account_case2(self):
     faker = Faker()
     # 创建保健方账号
     staff_api = SponsorsManagermentApi()
     staff_token = get_admin_token()
     set_login_status(staff_api, staff_token)
     sponsor = {"account": get_random_name(6, 50), "password": faker.password(),
                "name": faker.user_name(), "email": faker.email(),
                "phone": faker.phone_number()}
     staff_api.staff_sponsors_post(post_sponsor=sponsor)
     # 极验初始化
     verification_api = VerificationApi()
     challenge = ''
     res = verification_api.accounts_init_captcha_get()
     assert res.new_captcha == 'true'
     assert res.success == '1'
     challenge = res.challenge
     # 获取绑定的手机和邮箱
     api = SponsorApi()
     api.sponsor_info_post(sponsor_info={"userName": sponsor['account'],
                                         "challenge": challenge,
                                         "seccode": "fdhfghfdghfghfjhfghfasfas",
                                         "validate": "dfhdfgdfgfdgfdgsadfasfas"})
     # 二次验证
     base_token = ''
     res = api.sponsor_verify_post(post_verify_request={"userName": sponsor['account'],
                                                        "uri": "mailto:" + str(sponsor['email']),
                                                        "code": "666666",
                                                        "type": "forget_pwd"})
     base_token = res.base_token
     # 重置密码
     set_password = {"password": faker.password()}
     api.sponsor_set_password_post(sponsor_rest_pwd={"userName": sponsor['account'],
                                                     "baseToken": base_token,
                                                     "password": set_password['password']})
     # 保荐方登录
     sponsor_api = SponApi()
     get_sponsor_token(account=sponsor.get("account"),
                       password=set_password.get("password"),
                       email=sponsor.get("email"), api_list=[sponsor_api, api])
     # 获取保荐方排行榜
     res = sponsor_api.sponsors_ranking_get(page=1)
     assert res.ranking == res.meta.total_count
     # 保荐方退出
     api.sponsor_logout_post()
    def igtest_done(self, direction, status, fail_type, otc_user):
        one_user_info = otc_user([ad_api, order_api, pay_mode_api])
        pay_way_id = create_paymode(pay_mode_api,
                                    one_user_info['asset_password'])
        price, amount = get_random_data()
        if direction == 'sell':
            # 获取买币广告
            response = create_ad(ad_api, (price, amount),
                                 one_user_info['seller_coin_id'],
                                 one_user_info['asset_password'],
                                 direction=1)
        else:
            # 获取卖币广告
            response = create_ad(ad_api, (price, amount),
                                 one_user_info['seller_coin_id'],
                                 one_user_info['asset_password'])
        ad_info = ad_api.advertise_info_ad_id_get(ad_id=response.ad_id)
        ad = ad_info.to_dict()
        print(ad_info)
        amount = float(ad['amount']) - round(
            100 / float(ad['price']), 2)  # 这里为了省事直接把广告的总数买完,由于是场外不需要考虑买方资产问题

        sec_user_info = otc_user([pay_mode_api, order_api])
        print(f'order user {sec_user_info}')
        sec_pay_way_id = create_paymode(pay_mode_api,
                                        sec_user_info['asset_password'])
        create_order = CreateOrderRequest(ad_id=ad['ad_id'], amount=amount)
        res = order_api.order_create_post(create_order)

        if direction == 'sell':
            # 买币广告
            # 卖币订单
            set_login_status(order_api, one_user_info['user_token'])
            order_api.order_buyer_paid_order_id_paymode_id_post(
                order_id=res.order_id, paymode_id=sec_pay_way_id)
            # 卖家确认放行
            set_login_status(order_api, sec_user_info['user_token'])
            order_api.order_seller_confirm_order_id_post(order_id=res.order_id)
        else:
            # 卖币广告
            # 买币订单
            order_api.order_buyer_paid_order_id_paymode_id_post(
                order_id=res.order_id, paymode_id=pay_way_id)
            # 卖家确认放行
            set_login_status(order_api, one_user_info['user_token'])
            order_api.order_seller_confirm_order_id_post(order_id=res.order_id)

        order_info = order_api.order_info_order_id_get(order_id=res.order_id)
        assert int(order_info.status) == 30

        set_login_status(staff_order_api, sec_user_info['admin_token'])
        check_info = staff_order_api.admin_order_find_page_get(
            ad_id=ad['ad_id'], order_id=res.order_id)
        assert int(check_info.items[0].status) == 30
예제 #25
0
 def test_sponsors_case5(self):
     faker = Faker()
     manager = PlatformManager("venture")
     email = random_email()
     password = faker.password()
     country = random_get_country_ob()
     manager.register(email=email,
                      password=password,
                      promotion_code=None,
                      verification_code="666666",
                      nationality_code=country.get("k"))
     token = manager.login(account=email, password=password)
     # 个人实名认证
     individual_verify(platform="venture",
                       id_number=get_random_id_number(),
                       token=token)
     # 创建保健方账号
     staff_api = SponsorsManagermentApi()
     staff_token = get_admin_token()
     set_login_status(staff_api, staff_token)
     sponsor = {
         "account": get_random_name(6, 25),
         "password": faker.password(),
         "name": faker.user_name(),
         "email": email,
         "phone": faker.phone_number()
     }
     staff_api.staff_sponsors_post(post_sponsor=sponsor)
     # 管理后台获取保健列表
     res = staff_api.staff_sponsors_get(page=1, name=sponsor.get("name"))
     assert res.meta.total_count == 1
     for item in res.items:
         assert item.account == sponsor.get("account")
         assert item.email == sponsor.get("email")
         assert item.name == sponsor.get("name")
         assert item.status is True
         assert item.id
     # 项目方获取保健列表
     venture_api = SMApi()
     set_login_status(venture_api, token)
     res = venture_api.sponsors_get(page=1, name=sponsor.get("name"))
     item = res.items.pop()
     assert item.name == sponsor.get("name")
     assert item.id
예제 #26
0
def get_sponsors():
    """获取保鉴机构"""
    admin_token = get_admin_token()
    s_api = SponsorsManagermentApi()
    set_login_status(s_api, admin_token)
    name = 'sponsors_name_' + str(random.randint(1, 100000))
    email = str(random.randint(100000, 50000000)) + '@qq.com'
    data = dict(account='s' + str(int(time.time())),
                name=name,
                password='******',
                phone='15526548799',
                email=email)
    req = PostSponsorRequest(**data)
    s_api.staff_sponsors_post(req)
    # 获取保健方id
    rv = s_api.staff_sponsors_get(page=1, name=name, email=email)
    sponsors_id = rv.items[0].id
    data['id'] = sponsors_id
    return data
예제 #27
0
 def test_apply_company_verify(self, with_login):
     exchange_api = ExchangeManagementApi()
     user = self.data['user']
     email, password = user['email'], user['password']
     social_code = get_social_code()
     token = with_login('tenant', [exchange_api], email, password)
     company_verify('tenant', social_code, token)
     a_api = AuditApi()
     admin_token = get_admin_token()
     set_login_status(a_api, admin_token)
     rv = a_api.accounts_company_audits_get(social_number=social_code,
                                            status='ACCEPTED')
     item = rv.items[0]
     account_id = item.account_id
     rv = a_api.accounts_company_audits_id_get(account_id)
     assert rv.account_id == account_id
     e = Exchange(exchange_api, token)
     exchange = e.get_exchange()
     exchange_api.exchange_post(exchange)
예제 #28
0
    def test_normal_commission_config(self, admin_token):
        api = SystemManagementApi()
        set_login_status(api, admin_token)
        # 提交佣金设置
        # api.system_commission_post(body={
        #                                   "commissionRate": "string",
        #                                   "startAt": datetime.utcnow(),
        #                                   "endAt": datetime.utcnow(),
        #                                   "ageDays": 100
        #                                 })
        #
        
        # res = api.system_commission_get(page=1)
        # print(res)
        
        # # 获取系统配置
        # api.system_system_config_get()
        # # 修改系统配置
        # api.system_system_config_id_put(
        #     id="1", body={
        #                   "configValue": 123.123
        #                 })
        # # 获取系统配置
        # res = api.system_system_config_get()
        # print(res)

        # 获取审核失败原因
        api.system_failure_reasons_get()
        # 新增审核失败原因
        api.system_failure_reasons_post(
            body={
                  "failureReason": "_failure_reason",
                  "type": "PERSONAL_AUTHENTICATE"
                  })
        # 获取审核失败原因
        res = api.system_failure_reasons_get()
        print(res)
        
        # 获取提币审核失败原因
        res = api.system_failure_reasons_withdraw_get()
        # 根据类型获取失败原因
        res = api.system_failure_reasons_type_get(type="PERSONAL_AUTHENTICATE")
        print(res)
 def test_sponsors_case3(self):
     faker = Faker()
     # 创建保健方账号
     staff_api = SponsorsManagermentApi()
     staff_token = get_admin_token()
     set_login_status(staff_api, staff_token)
     sponsor = {
         "account": get_random_name(6, 25),
         "password": faker.password(),
         "name": faker.user_name(),
         "email": faker.email(),
         "phone": faker.phone_number()
     }
     staff_api.staff_sponsors_post(post_sponsor=sponsor)
     # 管理后台获取保健列表
     res = staff_api.staff_sponsors_get(page=1, name=sponsor.get("name"))
     sponsor_id = ''
     assert res.meta.total_count == 1
     for item in res.items:
         assert item.account == sponsor.get("account")
         assert item.email == sponsor.get("email")
         assert item.name == sponsor.get("name")
         assert item.status is True
         sponsor_id = item.id
     # 修改保荐方信息
     payload1 = {
         'id': sponsor_id,
         'logo': 'url/images',
         'website': 'www.baidu.com',
         'summary': '这是简介',
         'password': '******',
         'phone': '13877778888',
         'email': '*****@*****.**'
     }
     staff_api.staff_sponsors_put(put_sponsor=payload1)
     # 获取保荐方列表
     res = staff_api.staff_sponsors_get(page=1)
     for item in res.items:
         if item.name == sponsor.get("name"):
             assert item.account == sponsor.get("account")
             assert item.email == payload1['email']
             assert item.status is True
             assert item.id
예제 #30
0
 def get_random_tags(self):
     rv = self.manager.tags_get()
     tags = rv.tags
     if tags:
         amount = random.randint(1, min(3, len(tags)))
         rv = random.sample(tags, amount)
         tag = ','.join(rv)
         return tag
     else:
         admin_token = get_admin_token()
         api = WebsiteManagementApi()
         set_login_status(api, admin_token)
         res = PostExchangeTagsRequest()
         res.name = 'tag_' + str(random.randint(1, 122222))
         res.other_language = [{
           "key": "英语",
           "value": "public_chain"
         }]
         api.exchange_tags_post(res)
         return res.name