Example #1
0
    def test_register(self, with_login):
        account_api = AccountApi()
        manager = PlatformManager('tenant')
        api = manager.account_api
        verify_api = manager.verify_api
        user = register_with_login('tenant', with_login, [api, verify_api, account_api])
        self.data['user'] = user
        account_info = account_api.accounts_account_info_get()
        account_id = account_info.account_info.account_id
        self.data['account_id'] = account_id
        # 绑定电话
        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)

        user1 = register_with_login('tenant', with_login, [api, verify_api])
        self.data['user1'] = user1
        # 绑定电话
        email1 = user1.get('email')
        phone1 = faker.phone_number()
        verify = verify_info(manager, email1, "bind_phone")
        manager.bind_phone(phone1, DEFAULT_VERIFY_CODE,
                           area_code="+86", token=verify.token)
Example #2
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
Example #3
0
    def test_exchange(self, with_login):
        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
        id_number = get_random_id_number()
        individual_verify('tenant', id_number, user['token'])

        e_api = StaffExchangeManagementApi()
        a_api = AccountManagementApi()
        admin_token = get_admin_token()
        audit_api = AuditApi()
        set_login_status(audit_api, admin_token)
        set_login_status(e_api, admin_token)
        set_login_status(a_api, admin_token)
        # 用户列表
        rv = a_api.accounts_investors_get(account_id=account_id)
        assert rv.items

        # 后台开通交易所
        req = {
            "accountId": account_id,
            "area": "+86",
            "email": str(int(time.time())) + "@qq.com",
            "logo": "",
            "name": str(int(time.time())),
            "phone": "15548494655",
            "tags": ""
        }
        e_api.exchange_post(req)
        # 交易所审核列表
        rv = audit_api.tenant_audits_get(uid=account_id)
        item = rv.items[0]
        assert item.status == 'approved'
Example #4
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
Example #5
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
Example #7
0
 def test_close_market(self, with_login):
     """7.新增市场——获取交易对市场列表——关闭市场——获取交易对市场"""
     a_api = AccountApi()
     audit_api = AuditApi()
     v_api = VerificationApi()
     m_api = MarketManagementApi()
     e_api = ExchangeManagementApi()
     user = self.data['user']
     email, password = user['email'], user['password']
     token = with_login('tenant', [a_api, m_api, v_api, e_api], email,
                        password)
     rv = m_api.markets_get()
     market_id = rv.items[0].id
     res = PostMarketCloseRequest(id=market_id, closing_reason='a' * 11)
     data = {
         "challenge": "048ebbe51f829995db76ac4b81546403",
         "seccode": "048ebbe51f829995db76ac4b81546403",
         "validate": "true",
         "account": "mailto:[email protected]",
         "code": "666666",
         "secondCode": "Ls1w1w",
         "type": "close_market"
     }
     rv = v_api.accounts_verify_post(data)
     res.token = rv.token
     rv = m_api.markets_close_post(res)
     res = m_api.markets_get()
     item = res.items[0]
     assert item.status == 'in_review'
     # 合并测试用例
     """11.前台申请关闭交易市场——关闭交易所市场审核列表——关闭交易所市场审核详情初审
     ——提交关闭交易所审核初审——关闭交易所市场审核列表"""
     # 审核列表
     rv = e_api.exchange_exchange_id_get()
     exchange_id = rv.id
     admin_token = get_admin_token()
     set_login_status(audit_api, admin_token)
     rv = audit_api.shutdown_market_audits_get(page=1,
                                               exchange_id=exchange_id)
     item = rv.items[0]
     status = item.status
     assert status == 'audit'
     ticket_number = item.ticket_number
     rv = audit_api.shutdown_market_audits_id_tasks_audit_get(ticket_number)
     account_info = a_api.accounts_account_info_get()
     account_id = account_info.account_info.account_id
     assert rv.uid == account_id
     assert rv.exchange_id == exchange_id
     s = self.data['s_coin'].name
     b = self.data['b_coin'].name
     assert rv.trading_pair == f'{s}/{b}'
     # 初审
     data = PostShutdownMarketAuditRequest(id=ticket_number,
                                           status='approved')
     audit_api.shutdown_market_audits_audit_post(data)
     res = m_api.markets_get()
     item = res.items[0]
     assert item.status == 'in_review'
     # 获取初审详情
     rv = audit_api.shutdown_market_audits_id_audit_get(ticket_number)
     assert rv.audit_status == 'approved'
     rv = audit_api.shutdown_market_audits_get(exchange_id=exchange_id)
     item = rv.items[0]
     assert item.status == 're_audit'
     # 合并测试用例
     """12.申请关闭交易所市场初审通过——关闭交易所市场审核列表
     ——提交关闭交易所审核复审——关闭交易所市场审核列表"""
     rv = audit_api.shutdown_market_audits_id_tasks_re_audit_get(
         id=ticket_number)
     assert rv.audit_status == 'approved'
     # 复审
     data = PostShutdownMarketReAuditRequest(id=ticket_number,
                                             status='approved')
     audit_api.shutdown_market_audits_re_audit_post(data)
     # 复审详情
     rv = audit_api.shutdown_market_audits_id_re_audit_get(ticket_number)
     assert rv.audit_status == 'approved'
     assert rv.re_status == 'approved'
     rv = audit_api.shutdown_market_audits_get(exchange_id=exchange_id)
     item = rv.items[0]
     assert item.status == 'approved'
     res = m_api.markets_get()
     item = res.items[0]
     assert item.status == 'wait_close'
Example #8
0
    def test_market_exchange(self, with_login):
        """添加测试用例,两个交易所对接同一个市场,手动在数据库中修改两者为深度共享"""
        manager = PlatformManager('tenant')
        m_api = MarketManagementApi()
        e_api = ExchangeManagementApi()
        api = manager.account_api
        verify_api = manager.verify_api
        account_api = AccountApi()
        v_api = VerificationApi()
        pm = ProjectManagementApi()
        vc = VentureContactsApi()
        user = register_with_login(
            'tenant', with_login,
            [vc, pm, api, v_api, verify_api, m_api, e_api, account_api])
        self.data['user1'] = user
        token0 = 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, token0)
        exchange_api = ExchangeManagementApi()
        e = Exchange(exchange_api, token0)
        exchange = e.get_exchange()
        e_api.exchange_post(exchange)
        rv = account_api.accounts_account_info_get()
        account_id = rv.account_info.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',
                                     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 = e_api.exchange_exchange_id_get()
        exchange_id = rv.id
        # 对接币种
        contacts_api = ContactsApi()
        user = self.data['user']
        email, password = user['email'], user['password']
        token = with_login('tenant', [contacts_api], email, password)
        project_id = self.data['project_id']
        req = {
            'exchangeId': exchange_id,
            'projectId': project_id,
            'sponsor': 'tenant'
        }

        rv = contacts_api.contacts_post(req)
        # 处理对接邀请
        rv = pm.projects_id_contacts_get(project_id, 'tenant')
        # 处理对接邀请
        contact_id = rv.items[0].contact_id
        vc.contacts_put({'contactId': contact_id, 'status': 'accepted'})
        #
        # rv = contacts_api.contacts_projects_exchange_id_get(exchange_id,
        #                                                     'pending')
        # contact_id = rv.items[0].id
        # contacts_api.contacts_put({'contactId': contact_id,
        #                            'status': 'accepted'})
        rv = contacts_api.contacts_check_get(project_id=project_id,
                                             exchange_id=exchange_id)
        assert rv.result
        rv = e_api.exchange_exchange_coin_get()
        res = PostOrderMarketRequest()
        s_coin = self.data['s_coin']
        b_coin = self.data['b_coin']
        res.seller_coin_id = s_coin.id
        res.buyer_coin_id = b_coin.id
        res.allotted_time = AllottedTime._6month
        res.fee_rate = TestMarket1.fee_rate
        rv = e_api.exchange_exchange_coin_get()
        # 配置交易对市场
        rv = e_api.exchange_order_market_post(res)
        order_id = rv.order_id
        usdt_id = b_coin.id
        # 充钱
        free_charge(token0, usdt_id, account_id)

        data = {
            "challenge": "048ebbe51f829995db76ac4b81546403",
            "seccode": "048ebbe51f829995db76ac4b81546403",
            "validate": "true",
            "account": "mailto:[email protected]",
            "code": "666666",
            "secondCode": "Ls1w1w",
            "type": "pay"
        }
        rv = v_api.accounts_verify_post(data)
        p = PutOrderMarketRequest(order_id=order_id, token=rv.token)
        e_api.exchange_order_market_put(p)
        # 获取交易对市场
        rv = m_api.markets_get()
        items = rv.items
        assert len(items) == 1
Example #9
0
    def test_exchange_project(self):
        """2.新增项目——对接交易所——获取交易所卖买方币种列表
            ——单一币种在单一交易所币对的行情统计"""
        exchange = new_exchange()
        exchange_api = ExchangeManagementApi()
        user_data = TestProject.data['user']
        token = user_data['token']
        exchange_api.api_client.set_default_header("Authentication-Token",
                                                   token)
        account_api = AccountApi()
        account_api.api_client.set_default_header("Authentication-Token",
                                                  token)
        account_info = account_api.accounts_account_info_get()
        account_id = account_info.accountInfo.accountId
        TestProject.data['account_id'] = account_id
        exchange_api.exchange_post(exchange)
        manager = PlatformManager('tenant')
        token = manager.login(sponsor_account, sponsor_pwd)
        audit_api = AuditApi()
        audit_api.api_client.set_default_header("Authentication-Token", token)
        # 初审
        rv = audit_api.tenant_audits_get()
        audit_list = rv.items
        _id = None
        for each in audit_list:
            if each.uid == account_id:
                _id = each.id  # 工单id
        assert not _id
        res = PostTenantAuditRequest(id=_id,
                                     is_data_received=True,
                                     status='approved',
                                     failure_type=1)
        audit_api.tenant_audits_audit_post(res)
        # 复审
        PostTenantReAuditRequest(id=_id, status='approved', failure_type=None)
        exchange_id = exchange_api.exchange_exchange_id_get()
        # 对接项目方
        contacts_api = ContactsApi()
        contacts_api.api_client.set_default_header("Authentication-Token",
                                                   token)
        req = {
            'exchangeId': exchange_id,
            'projectId': TestProject.data['project_id'],
            'sponsor': 'tenant'
        }
        contacts_api.contacts_post(req)
        # 获取交易所买卖方币种
        m_api = MarketManagementApi()
        m_api.api_client.set_default_header("Authentication-Token", token)
        trading_coins = m_api.markets_trading_coins_get()
        seller_coin = trading_coins.seller_coin
        s_coin = seller_coin[0]
        buyer_coin = trading_coins.buyer_coin
        b_coin = buyer_coin[0]
        assert s_coin == TestProject.data['project']['short_name']

        # 新建市场
        res = PostOrderMarketRequest()
        res.seller_coin_id = s_coin.id
        res.buyer_coin_id = b_coin.id
        TestProject.data['s_coin'] = s_coin
        TestProject.data['b_coin'] = b_coin
        res.allotted_time = AllottedTime._6month
        res.fee_rate = TestProject.fee_rate
        # 配置交易对市场
        rv = exchange_api.exchange_order_market_post(res)
        order_id = rv.order_id
        token = get_verify_token()
        p = PutOrderMarketRequest(order_id=order_id, token=token)
        exchange_api.exchange_order_market_put(p)

        # 单一币种在单一交易所币对的行情统计
        dashboard_api = DashboardApi()
        dashboard_api.api_client.set_default_header("Authentication-Token",
                                                    token)
        dashboard_api.dashboard_quotation_historical_data_post()
        dashboard_api.dashboard_quotations_summary_get(page_no=1,
                                                       page_size=10,
                                                       seller_coin=seller_coin)
        # 3.新增项目——对接交易所——获取交易所卖买方币种列表——单一币种在各交易所的行情概要
        dashboard_api.dashboard_daily_statistics_get()
Example #10
0
    def test_get_project(self, with_login):
        """1.新增项目——获取所有项目——获取项目详情"""
        sponsor = get_sponsors()
        venture_api = VentureApi()
        user_data = register_with_login('venture', with_login, [venture_api])
        TestProject.data['user'] = user_data
        project = get_project()
        TestProject.data['project'] = project
        req = ApplicationRequest(**project)
        rv = venture_api.applications_post(req)
        project_id = rv.id
        TestProject.data['project_id'] = project_id
        # 设置接入方式
        setting = PutProjectRequestSetting(access_method='accept')
        project_info = PutProjectRequestProjectInfo(access_method='accept')
        req = PutProjectRequest(project_info=project_info, setting=setting)
        venture_api.projects_id_put(req)
        # 设置保健机构

        venture_api.applications_id_set_sponsor_put(project_id,
                                                    {'sponsorId': sponsor.id})
        project_name = project['project_name']
        sponsor_api = SponsorsProjectApi()
        manager = PlatformManager('sponsor')
        token = manager.login(sponsor_account, sponsor_pwd)
        sponsor_api.api_client.set_default_header("Authentication-Token",
                                                  token)
        rv = sponsor_api.projects_get(page=1, project_name=project_name)
        assert len(rv.items) == 1
        assert rv.items[0].id == project_id
        rv = sponsor_api.projects_id_get(id=project_id)
        assert rv.project_info.project_name == project['project_name']
        assert rv.coin_info.short_name == project['short_name']

        # 保健通过
        sponsor_api.projects_sponsor_put({
            'id': project_id,
            'status': 1,
            'remark': 'test'
        })

        project_api = ProjectApi()

        project_api.api_client.set_default_header("Authentication-Token",
                                                  user_data['token'])
        rv = project_api.projects_get()
        assert len(rv.items) == 1
        p = rv.items[0]
        assert p.project_id == project_id

        # 获取项目详情
        rv = project_api.projects_id_get(id=project_id)
        assert rv.sponsor_info.sponsor_id == sponsor.id
        assert rv.project_info.id == project_id
        assert rv.coin_info.short_name == project['short_name']

        # 合并测试用例
        """1.新增项目——获取项目列表——收藏——收藏列表(项目)"""
        token = user_data['token']
        account_api = AccountApi()
        account_api.api_client.set_default_header("Authentication-Token",
                                                  token)
        account_info = account_api.accounts_account_info_get()
        account_id = account_info.accountInfo.accountId

        f_api = FavoriteManagementApi()
        f_api.api_client.set_default_header("Authentication-Token", token)
        req = PostFavoriterRequest()
        req.favorite_id = project_id
        req.type = 'project'
        f_api.favorites_post(req)

        # 收藏列表
        flag = False
        pages = Pager(f_api.favorites_get)
        favorite_record_id = None
        for page in pages:
            for record in page.items:
                if record.favorite_id == project_id:
                    if record.type == 'project':
                        flag = True
                        favorite_record_id = record.id
                        break
            if flag:
                break
        assert flag

        # 合并测试用例
        """5.收藏项目成功——收藏列表(项目)——取消收藏"""
        # 取消收藏
        req = DeleteFavoriterRequest()
        req.id_items = [favorite_record_id]
        f_api.favorites_ids_delete(req)
        rv = f_api.favorites_is_favorite_get(favorite_id=project_id,
                                             type='project')
        assert not rv.status
 def test_applications8(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"),
                      nick_name='fghfg')
     token = manager.login(account=email, password=password)
     # 个人实名认证
     individual_verify(platform="venture",
                       id_number=get_random_id_number(),
                       token=token)
     # 申请项目
     project_name = get_random_name(2, 16)
     short_name = "O" + str(random.randint(10000, 99999))
     full_name = get_random_name(2, 16)
     project_api = ProjectApi()
     set_login_status(project_api, token)
     pay = copy.deepcopy(dict(payload))
     pay.update({
         'project_name': project_name,
         'short_name': short_name,
         'full_name': full_name
     })
     req = ApplicationRequest(**pay)
     res = project_api.applications_post(body=req)
     project_apply_id = res.id
     # 创建保健方账号
     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)
     # 新建交易所标签
     website_api = WebsiteManagementApi()
     set_login_status(website_api, staff_token)
     website = {
         "name":
         "交易所标签" + str(random.randint(10000, 99999)),
         "otherLanguage": [{
             "key": "英语",
             "value": "public_chain"
         }, {
             "key": "法语",
             "value": "public_chain"
         }]
     }
     website_api.exchange_tags_post(body=website)
     # 项目方获取保健列表
     venture_api = SMApi()
     set_login_status(venture_api, token)
     res = venture_api.sponsors_get(page=1, name=sponsor.get("name"))
     item = res.items.pop()
     sponsor_id = item.id
     # 项目方设置保健方
     project_api.applications_id_set_sponsor_put(
         id=project_apply_id, sponsor_request={"sponsorId": sponsor_id})
     # 保健方登
     # 保健项目
     sponsor_api = SponsorsProjectApi()
     get_sponsor_token(account=sponsor.get("account"),
                       password=sponsor.get("password"),
                       email=sponsor.get("email"),
                       api_list=[sponsor_api])
     sponsor_api.projects_sponsor_put(put_project_sponsor_request={
         "id": project_apply_id,
         "status": 1,
         "remark": "remark"
     })
     # 币种配置列表
     asset_api = AssetManagementApi()
     set_login_status(asset_api, staff_token)
     res = asset_api.asset_mgmt_coins_get(page=1, coin_name=short_name)
     coin_id = ''
     assert res.meta.total_count == 1
     for item in res.items:
         assert item.coin_name == short_name
         coin_id = item.id
     # 初始化币种配置
     payload1 = {
         "usdtPrice": "1",
         "rcTimes": 0,
         "wcTimes": 0,
         "withdrawRate": "1",
         "minWithdrawFee": "1",
         "minWithdraw": "1",
         "maxWithdraw": "1",
         "dayWithdrawTotal": "1",
         "minRecharge": "1",
         "addressTagSwitch": True,
         "addressType": "1",
         "addressUrl": "1",
         "txidUrl": "1"
     }
     asset_api.asset_mgmt_coins_id_init_put(id=coin_id, body=payload1)
     # 授权登录
     api = AccountApi()
     set_login_status(api, token)
     api.create_platform()
     # 提交交易所申请
     exchange_api = ExchangeManagementApi()
     set_login_status(exchange_api, token)
     exchange = {
         "email": email,
         "logo": "gdfgdvdfvdf",
         "name": "交易所" + str(random.randint(10000, 99999)),
         "nationality": "+86",
         "phone": '+86135678' + str(random.randint(10000, 99999)),
         "tags": website['name']
     }
     exchange_api.exchange_post(exchange)
     # 交易所账号审核列表
     audit_api = AuditApi()
     set_login_status(audit_api, staff_token)
     res = audit_api.tenant_audits_get(exchange_name=exchange['name'])
     audit_id = ''
     for item in res.items:
         audit_id = item.id
     # 交易所初审
     audit = {
         "failureType": "string",
         "id": audit_id,
         "isDataReceived": True,
         "status": "approved"
     }
     audit_api.tenant_audits_audit_post(body=audit)
     # 交易所账号审核列表
     res = audit_api.tenant_audits_get(exchange_name=exchange['name'])
     re_audit_id = ''
     for item in res.items:
         re_audit_id = item.id
     # 交易所账号复审
     re_audit = {
         "failureType": "string",
         "id": re_audit_id,
         "status": "approved"
     }
     audit_api.tenant_audits_re_audit_post(body=re_audit)
     # 获取交易所id
     exchange_id_ = ''
     res = exchange_api.exchange_exchange_id_get()
     exchange_id_ = res.id
     # 获取项目列表
     exchange_project_api = ExchangeProject()
     set_login_status(exchange_project_api, token)
     project_id = ''
     res = exchange_project_api.projects_get(coin_name=short_name)
     for item in res.items:
         project_id = item.project_id
     # 申请对接
     contacts_api = ExchangeContacts()
     set_login_status(contacts_api, token)
     contacts = {
         "exchangeId": exchange_id_,
         "projectId": project_id,
         "sponsor": "tenant"
     }
     contacts_api.contacts_post(contacts)
     # 获取项目未处理的邀请记录数量
     contacts_project_api = ContactsApi()
     set_login_status(contacts_project_api, token)
     res = contacts_project_api.contacts_invite_number_get(id=project_id)
     assert res.result == '1'
     # 获取交易所对接的项目列表
     api = ProjectManagementApi()
     set_login_status(api, token)
     contacts_id = ''
     res = api.projects_id_contacts_get(id=project_id, sponsor="pending")
     for item in res.items:
         if item.exchange_name == exchange['name']:
             contacts_id = item.contact_id
     # 处理对接邀请
     payload2 = {"contactId": contacts_id, "status": "accepted"}
     contacts_project_api.contacts_put(body=payload2)
     # 判断项目方与交易所是否已经申请对接
     res = contacts_project_api.contacts_check_get(project_id=project_id,
                                                   exchange_id=exchange_id_)
     assert res.result
Example #12
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()
     contacts_api = ContactsApi()
     vc = VentureContactsApi()
     venture_pm = ProjectManagementApi()
     tenant_ca = TenantContactsApi()
     user = register_with_login('tenant', with_login, [
         api, verify_api, m_api, e_api, account_api, contacts_api, vc,
         venture_pm, tenant_ca
     ])
     self.data['user2'] = 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
     rv = e_api.exchange_exchange_coin_get()
     seller_coin = rv.seller_coin
     buyer_coin = rv.buyer_coin
     b_coin = buyer_coin[0]
     if seller_coin:
         s_coin = seller_coin[0]
     else:
         # 对接币种
         # 租户主动发起对接
         project_id1 = self.data['project_id1']
         project_id2 = self.data['project_id2']
         req = {
             'exchangeId': exchange_id,
             'projectId': project_id1,
             'sponsor': 'tenant'
         }
         contacts_api.contacts_post(req)
         # 项目方主动发起对接
         req = {
             'exchangeId': exchange_id,
             'projectId': project_id2,
             'sponsor': 'venture'
         }
         vc.contacts_post(req)
         rv1 = venture_pm.projects_id_contacts_get(project_id1, 'tenant')
         rv2 = tenant_ca.contacts_projects_exchange_id_get(
             exchange_id, 'pending')
         # 处理对接邀请
         contact_id1 = rv1.items[0].contact_id
         contact_id2 = rv2.items[0].id
         vc.contacts_put({'contactId': contact_id1, 'status': 'accepted'})
         rv = contacts_api.contacts_check_get(project_id=project_id1,
                                              exchange_id=exchange_id)
         # pprint(rv)
         contacts_api.contacts_put({
             'contactId': contact_id2,
             'status': 'accepted'
         })
         rv = vc.contacts_check_get(project_id2, exchange_id)
         rv = contacts_api.contacts_check_get(project_id1, exchange_id)
         assert rv.result
         rv = contacts_api.contacts_project_id_status_get(project_id1)
         assert rv.status == 'accepted'
         rv = contacts_api.contacts_project_id_status_get(project_id2)
         assert rv.status == 'accepted'
Example #13
0
    def test_register(self, with_login):
        manager = PlatformManager('tenant')
        m_api = MarketManagementApi()
        e_api = ExchangeManagementApi()
        api = manager.account_api
        verify_api = manager.verify_api
        account_api = AccountApi()
        venture_api = VentureApi()
        va_api = VentureAccountApi()
        contacts_api = ContactsApi()
        vc = VentureContactsApi()
        pm = ProjectManagementApi()
        user = register_with_login('tenant', with_login, [
            api, verify_api, m_api, e_api, account_api, venture_api, va_api,
            contacts_api, pm, vc
        ])
        token = user['token']
        email = user.get('email')
        self.data['token1'] = token
        # 绑定电话
        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)
        # 授权
        res = PostPlatFormRegisterRequest()
        va_api.create_platform(body=res)
        # 申请项目
        project1 = get_project(token)
        rv = venture_api.applications_post(body=project1)
        application_id_1 = rv.id
        sponsor = get_sponsors()
        # 登录保健方
        account, password = sponsor['account'], sponsor['password']
        sponsor_token = get_sponsor_token(account, password, email='test')
        project2 = get_project(token)
        # req = ApplicationRequest(**project)
        rv = venture_api.applications_post(body=project2)
        application_id_2 = rv.id
        rv = venture_api.projects_get(page=1)
        assert len(rv.items) == 0
        rv = venture_api.applications_get(page=1)
        assert len(rv.items) == 2
        # 设置保健机构
        venture_api.applications_id_set_sponsor_put(
            application_id_1, {'sponsorId': sponsor['id']})
        venture_api.applications_id_set_sponsor_put(
            application_id_2, {'sponsorId': sponsor['id']})
        sponsor_project_api = SponsorsProjectApi()
        set_login_status(sponsor_project_api, sponsor_token)

        sponsor_project_api.projects_sponsor_put({
            'id': application_id_1,
            'status': 1,
            'remark': 'test'
        })
        sponsor_project_api.projects_sponsor_put({
            'id': application_id_2,
            'status': 1,
            'remark': 'test'
        })
        rv = venture_api.projects_get(page=1)
        project_id1 = rv.items[1].project_id
        project_id2 = rv.items[0].project_id
        self.data['project_id1'] = project_id1
        self.data['project_id2'] = project_id2
        # 设置接入方式
        setting = PutProjectRequestSetting(access_method='verification',
                                           open=True)
        req = PutProjectRequest()
        req.setting = setting
        venture_api.projects_id_put(project_id1, 'setting', req)
        venture_api.projects_id_put(project_id2, 'setting', req)
        # 获取项目详情
        # 初始化项目
        s_api = SystemManagementApi()
        staff_project_api = StaffProjectApi()
        asset_management_api = AssetManagementApi()
        admin_token = get_admin_token()
        set_login_status(staff_project_api, admin_token)
        set_login_status(asset_management_api, admin_token)
        set_login_status(s_api, admin_token)
        coin_name1 = project1['shortName']
        rv = asset_management_api.asset_mgmt_coins_get(coin_name=coin_name1)
        coin_config_id1 = rv.items[0].id
        coin_name2 = project2['shortName']
        rv = asset_management_api.asset_mgmt_coins_get(coin_name=coin_name2)
        coin_config_id2 = rv.items[0].id
        # 修改币种配置
        res = PutSystemCoinsInitRequest()
        res.usdt_price = '1251'
        res.rc_times = 8
        res.wc_times = 8
        res.withdraw_rate = 0.1
        res.min_withdraw = 100
        res.min_withdraw_fee = 0.1
        res.max_withdraw = 1000
        res.min_recharge = 10
        res.address_tag_switch = True
        res.day_withdraw_total = 125564
        res.address_type = 'OX'
        res.address_url = 'http://unknown.com'
        res.txid_url = 'http://unknown.com'
        asset_management_api.asset_mgmt_coins_id_init_put(coin_config_id1, res)
        asset_management_api.asset_mgmt_coins_id_init_put(coin_config_id2, res)