Beispiel #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'
Beispiel #2
0
    def test_favorite_project_case6(self, with_login):
        user = register_with_login('main', with_login, [favorite_api])
        # 个人实名认证
        individual_verify(platform="main",
                          id_number=get_random_id_number(),
                          token=user["token"])

        # 主平台获取项目列表
        set_login_status(favorite_api, user["token"])
        res = main_api.projects_get(page=1, sort_key="volume", limit=100)
        main_project_id = ''
        for item in res.items:
            main_project_id = item.project_id
        # 收藏列表
        res = favorite_api.favorites_projects_get(page=1)
        assert res.meta.total_count == 0
        # 收藏
        payload = {'projectId': main_project_id}
        favorite_api.favorites_projects_post(body=payload)
        # 收藏列表
        res = favorite_api.favorites_projects_get(page=1)
        assert res.meta.total_count == 1
        for item in res.items:
            assert item.project_id == main_project_id
            assert item.id
            assert item.full_name
            assert item.project_name
            assert item.short_name
        # 判断是否收藏
        res = favorite_api.favorites_projects_is_favorite_get(
            project_id=main_project_id)
        assert res.status is True
        assert res.id
Beispiel #3
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
 def test_get_normal_individual_info(self, platform, with_login):
     manager = PlatformManager(platform)
     account_api = manager.account_api
     user = register_with_login(platform, with_login, [account_api])
     id_number = get_random_id_number()
     individual_verify(platform, id_number, token=user["token"])
     res = account_api.accounts_individual_get()
     assert res.number[:2] == id_number[:2]
     assert res.number[-2:] == id_number[-2:]
Beispiel #6
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_favorite_project_case10(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
     # 获取交易对市场列表
     market_api = MarketApi()
     set_login_status(market_api, token)
     res = market_api.markets_get(exchange_id=exchange_id, page=1)
     market_id = ''
     for item in res.items:
         market_id = item.id
     # 收藏列表
     favorite_api = FavoriteMarketApi()
     set_login_status(favorite_api, token)
     res = favorite_api.favorites_market_get(page=1,
                                             exchange_id=exchange_id)
     assert res.meta.total_count == 0
     # 收藏
     payload = {'marketId': market_id}
     favorite_api.favorites_market_post(body=payload)
     # 收藏列表
     res = favorite_api.favorites_market_get(page=1,
                                             exchange_id=exchange_id)
     favorite_id = ''
     assert res.meta.total_count == 1
     for item in res.items:
         assert item.market_id == market_id
         assert item.id
         favorite_id = item.id
     # 取消收藏
     favorite_api.favorites_market_delete(id=favorite_id)
     # 收藏列表
     res = favorite_api.favorites_market_get(page=1,
                                             exchange_id=exchange_id)
     assert res.meta.total_count == 0
Beispiel #8
0
 def test_exchange_post(self, with_login):
     exchange_api = ExchangeManagementApi()
     user = self.data['user']
     email = user.get('email')
     password = user.get('password')
     token = with_login('tenant', [exchange_api], email, password)
     e = Exchange(exchange_api, token)
     exchange = e.get_exchange()
     self.data['exchange'] = exchange
     id_number = get_random_id_number()
     individual_verify('tenant', id_number, token)
     exchange_api.exchange_post(exchange)
Beispiel #9
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 == []
Beispiel #10
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), '交易所名称应当已经存在'
Beispiel #11
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'
Beispiel #12
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'
Beispiel #13
0
 def test_exchange_post(self, with_login):
     exchange_api = ExchangeManagementApi()
     user = self.data['user']
     email = user['email']
     password = user['password']
     token = with_login('tenant', [exchange_api], email, password)
     id_number = get_random_id_number()
     individual_verify('tenant', id_number, token, 'REJECTED',
                       'INDIVIDUAL_PASSPORT')
     e = Exchange(exchange_api, token)
     exchange = e.get_exchange()
     try:
         exchange_api.exchange_post(exchange)
     except ApiException as e:
         assert e.status == 400
     else:
         assert False, '审核未过不应该创建交易所'
 def test_favorite_project_case8(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)
     assert res.meta.total_count == 1
     for item in res.items:
         assert item.exchange_id == exchange_id
         assert item.id
         assert item.exchange_name
     # 判断是否收藏
     res = favorite_api.favorites_exchange_is_favorite_get(
         exchange_id=exchange_id)
     assert res.status is True
     assert res.id
Beispiel #15
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
    def test_normal_individual(self, platform, with_login):
        user = register_with_login(platform, with_login, [])
        email = user["email"]
        id_number = get_random_id_number()
        # 进行个人实名认证
        individual_verify(platform=platform,
                          id_number=id_number,
                          token=user["token"],
                          verify_status="ACCEPTED")

        api = account_management_api.AccountManagementApi()
        admin_token = get_admin_token()
        api.api_client.set_default_header("Authorization",
                                          "Bearer " + admin_token)
        # 通过列表获取账户id
        investors_resp = api.accounts_investors_get(email=user["email"])
        account = investors_resp.items.pop()
        assert account.email == email
        user_id = account.account_id
        individual_info = api.accounts_id_individual_get(id=user_id)
        assert individual_info.type == "ID"
        assert individual_info.number == id_number
Beispiel #17
0
    def login(api_list, platform='main'):
        # 注册
        # 登录
        manager = PlatformManager(platform)
        account_api = manager.account_api
        asset_api = manager.asset_api
        verify_api = manager.verify_api
        tenant_market_api = MarketManagementApi()
        user = register_with_login(platform, entrust_login, [
            account_api, asset_api, exchange_api, verify_api, market_api,
            tenant_market_api
        ] + api_list)

        email = user.get("email")
        # 实名认证
        id_number = get_random_id_number()
        individual_verify(platform, id_number, user.get('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)
        # 随机资金密码
        assert_password = faker.password()
        # 设置资金密码,
        # 需要二次验证才能设置资金密码
        verify_info_res = verify_info(manager, email, 'edit_asset_pwd')
        base_token = verify_info_res.token
        asset_api.asset_mgmt_asset_password_put(
            body={
                "password": user.get("password"),
                "traPassword": assert_password,
                "baseToken": base_token
            })
        res = asset_api.asset_mgmt_asset_password_get()
        assert res.is_set

        # 获取交易所
        exchange_items = exchange_api.exchanges_suggestion_get(EXCHANGE_NAME)
        # 获取市场
        markets = market_api.markets_get(
            exchange_id=exchange_items[0]['id'], page=1)
        market_item = random.choice(markets.items)
        # print('市场信息:', markets)
        market_info = market_api.markets_id_get(market_item.id)

        buyer_coin_id = market_info.buyer_coin_id
        coin_id = market_info.seller_coin_id

        # 充币金手指
        headers = {"Authorization": "Bearer {}".format(user.get('token'))}
        host = configuration.host
        user_info = account_api.accounts_account_info_get()
        account_id = user_info.account_info.account_id
        res = requests.post(
            f'{host}/asset-test/asset-initialize/{coin_id}/100000000000',
            headers=headers)
        res = requests.post(
            f'{host}/asset-test/asset-initialize/{buyer_coin_id}/100000000000',
            headers=headers)

        result = {
            "coin_id": coin_id,
            "buyer_coin_id": buyer_coin_id,
            "account_id": account_id,
            "headers": headers,
            "market_id": market_item.id,
            "exchange_id": exchange_items[0]['id'],
            "precision": market_info.price_places
        }
        return result
Beispiel #18
0
    def login(api_list, platform='main'):
        # 注册
        # 登录
        tenant_ac_api = TenantAccountApi()
        manager = PlatformManager(platform)
        account_api = manager.account_api
        tenant_market_api = MarketManagementApi()
        market_api = MarketApi()
        main_asset_api = AssetManagementApi()
        asset_api = manager.asset_api
        verify_api = manager.verify_api
        user = register_with_login(platform, entrust_login, [
            account_api, asset_api, verify_api, market_api, tenant_ac_api,
            main_asset_api, tenant_market_api
        ] + api_list)

        # 租户平台授权登录
        # tenant_ac_api.create_platform()
        email = user.get("email")
        token = user.get('token')
        # 实名认证
        id_number = get_random_id_number()
        individual_verify(platform, id_number, user.get('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)
        # 随机资金密码
        assert_password = faker.password()
        # 设置资金密码,
        # 需要二次验证才能设置资金密码
        verify_info_res = verify_info(manager, email, 'edit_asset_pwd')
        print('二次验证信息:', verify_info_res)
        base_token = verify_info_res.token
        asset_api.asset_mgmt_asset_password_put(
            body={
                "password": user.get("password"),
                "traPassword": assert_password,
                "baseToken": base_token
            })
        res = asset_api.asset_mgmt_asset_password_get()
        assert res.is_set
        # 获取市场交易服务费率
        tenant_market_api.service_rate_get()
        # 获取交易所
        exchange_item = exchange_api.exchanges_suggestion_get(name=ENTRUST_EXCHANGE_NAME)
        exchange_id = exchange_item[0]['id']
        print('交易所id:', exchange_id)
        # 获取市场
        markets = market_api.markets_get(
            exchange_id=exchange_id, page=1)
        print('市场列表信息:', markets)
        # market_item = random.choice(markets.items)
        market_info = market_api.markets_id_get(markets.items[2].id)
        # market_item = [i for i in markets.items if i.id == '61']
        # market_info = market_api.markets_id_get(market_item[0].id)
        print('市场信息:', market_info)
        buy_coin_id = market_info.buyer_coin_id
        sell_coin_id = market_info.seller_coin_id
        # 充币金手指
        headers = {"Authorization": "Bearer {}".format(user.get('token'))}
        host = configuration.host
        user_info = account_api.accounts_account_info_get()
        account_id = user_info.account_info.account_id
        res = requests.post(
            f'{host}/asset-test/asset-initialize/{buy_coin_id}/100000000000',
            headers=headers)
        print('res:', res)
        res = requests.post(
            f'{host}/asset-test/asset-initialize/{sell_coin_id}/100000000000',
            headers=headers)
        # print('res:', res)
        # 获取币币余额
        main_bb_bal = main_asset_api.asset_mgmt_assets_get()
        asset_res_list = [i for i in main_bb_bal.asset_info if i.coin_id == buy_coin_id]
        print('主平台bb余额:', asset_res_list)
        result = {
            'buy_coin_id': buy_coin_id,
            'sell_coin_id': sell_coin_id,
            'account_id': account_id,
            'headers': headers,
            'market_id': markets.items[2].id,
            'exchange_id': exchange_id,
            'precision': market_info.price_places,
            'total_rate': market_info.total_rate,
            'token': token
        }
        return result
Beispiel #19
0
    def login(api_list, platform='main'):
        # 注册
        # 登录
        manager = PlatformManager(platform)
        account_api = manager.account_api
        asset_api = manager.asset_api
        verify_api = manager.verify_api
        tenant_market_api = MarketManagementApi()
        user = register_with_login(platform, entrust_login, [
            account_api, asset_api, exchange_api, verify_api, market_api, tenant_market_api
        ] + api_list)

        email = user.get('email')
        token = user.get('token')
        # 个人实名认证
        id_number = get_random_id_number()
        individual_verify(platform, id_number, user.get('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)
        # 随机资金密码
        asset_password = faker.password()
        # 设置资金密码,
        # 需要二次验证才能设置资金密码
        verify_info_res = verify_info(manager, email, 'edit_asset_pwd')
        base_token = verify_info_res.token
        asset_api.asset_mgmt_asset_password_put(
            body={
                'password': user.get('password'),
                'traPassword': asset_password,
                'baseToken': base_token
            }
        )
        res = asset_api.asset_mgmt_asset_password_get()
        assert res.is_set
        # 获取交易所
        exchange_item = exchange_api.exchanges_suggestion_get(name=ENTRUST_EXCHANGE_NAME)
        exchange_id = exchange_item[0]['id']
        print('交易所id:', exchange_id)
        # 获取市场
        markets = market_api.markets_get(
            exchange_id=exchange_id, page=1)
        print('市场列表信息:', markets)
        # market_item = random.choice(markets.items)
        market_item = [i for i in markets.items if i.id == '61']
        # market_item = [i for i in markets.items if i.id == '218']
        market_info = market_api.markets_id_get(market_item[0].id)
        print('市场信息:', market_info)
        buy_coin_id = market_info.buyer_coin_id
        sell_coin_id = market_info.seller_coin_id

        # 冲币金手指
        headers = {'Authorization': 'Bearer {}'.format(user.get('token'))}
        host = configuration.host
        user_info = account_api.accounts_account_info_get()
        account_id = user_info.account_info.account_id
        res = requests.post(
            f'{host}/asset-test/asset-initialize/{buy_coin_id}/100000000000',
            headers=headers)
        res = requests.post(
            f'{host}/asset-test/asset-initialize/{sell_coin_id}/100000000000',
            headers=headers)
        result = {
            'buy_coin_id': buy_coin_id,
            'sell_coin_id': sell_coin_id,
            'account_id': account_id,
            'headers': headers,
            'market_id': market_item[0].id,
            'exchange_id': exchange_id,
            'precision': market_info.price_places,
            'total_rate': market_info.total_rate,
            'token': token
        }
        return result
Beispiel #20
0
    def test_applications1(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)
        # 申请项目
        project_name = get_random_name(2, 16)
        short_name = "H" + 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)

        # 项目方获取保健列表
        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})
        # 查看项目申请列表
        res = project_api.applications_get(page=1)
        project_id = ''
        for item in res.items:
            assert item.project_name == project_name
            assert item.fullname == full_name
            assert item.short_name == short_name
            assert item.status == 'under_review'
            project_id = item.id
        # 查看申请项目详情
        res = project_api.applications_id_get(id=project_id)
        assert res.sponsor_id == sponsor_id
        assert res.sponsor_name == sponsor['name']
        assert res.id == project_id
        assert res.project_name == project_name
        assert res.short_name == short_name
        assert res.full_name == full_name
        assert res.status == 'under_review'
    def test_report4(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)
        # 申请项目
        project_name = get_random_name(2, 16)
        short_name = "F" + 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": email,
            "phone": faker.phone_number()
        }
        staff_api.staff_sponsors_post(post_sponsor=sponsor)
        # 项目方获取保健列表
        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"
        })
        # 获取项目列表
        res = project_api.projects_get(page=1)
        audit_project_id = ''
        for item in res.items:
            assert item.project_name == project_name
            assert item.full_name == full_name
            assert item.short_name == short_name
            audit_project_id = item.project_id
        # 发送项目报告
        report_api = ReportManagementApi()
        set_login_status(report_api, token)
        payload1 = {
            "title": "项目报告" + str(random.randint(1000, 9999)),
            "type": "daily",
            "report_url": "C:\pc\Desktop\wanshare.pdf",
            "project_id": audit_project_id
        }
        req = PostReportRequest(**payload1)
        report_api.reports_post(body=req)
        # 获取报告列表
        res = report_api.reports_project_id_get(project_id=audit_project_id)
        assert res.meta.total_count == 1
        for item in res.items:
            assert item.title == payload1['title']
            assert item.type == payload1['type']
            assert item.id
 def test_applications(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)
     # 创建保荐方账号
     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)
     # 保荐方登
     sponsor_api = SponsorsProjectApi()
     get_sponsor_token(account=sponsor.get("account"),
                       password=sponsor.get("password"),
                       email=sponsor.get("email"),
                       api_list=[sponsor_api])
     # 保荐成功记录
     res = sponsor_api.sponsor_record_success_get(page=1)
     assert not res.meta
     # 个人实名认证
     individual_verify(platform="venture",
                       id_number=get_random_id_number(),
                       token=token)
     # 申请项目
     project_name = get_random_name(2, 16)
     short_name = "Q" + 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
     # 项目方获取保健列表
     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"
     })
     # 保荐成功记录
     res = sponsor_api.sponsor_record_success_get(page=1)
     assert res.meta.total_count == 1
 def test_applications2(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)
     # 申请项目
     project_name = get_random_name(2, 16)
     short_name = "I" + 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)
     # 项目方获取保健列表
     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})
     # 查看项目申请列表
     res = project_api.applications_get(page=1)
     project_id = ''
     for item in res.items:
         assert item.project_name == project_name
         assert item.fullname == full_name
         assert item.short_name == short_name
         assert item.status == 'under_review'
         project_id = item.id
     # 查看申请项目详情
     res = project_api.applications_id_get(id=project_id)
     assert res.sponsor_id == sponsor_id
     assert res.sponsor_name == sponsor.get("name")
     assert res.id == project_id
     assert res.project_name == project_name
     assert res.short_name == short_name
     assert res.full_name == full_name
     assert res.status == 'under_review'
     # 修改申请项目
     project_name1 = '项目方' + str(random.randint(1000, 9999))
     full_name1 = 'BitCoin' + str(random.randint(1000, 9999))
     short_name1 = 'BTC' + str(random.randint(100, 999))
     payload2 = {
         'project_name': project_name1,
         'description': 'XXXXXXXXXXXXXXXX',
         'official_website': 'www.xxxx.com',
         'white_paper_key': 'url/pdf123455',
         'area_code': '+86',
         "project_poster_key": "123455",
         'cellphone': '13510022445',
         'telephone': '12874846',
         'email': '*****@*****.**',
         'full_name': full_name1,
         'short_name': short_name1,
         'issue_price': '2.24545',
         'issued_volume': '1000000',
         'circulation_volume': '1000000',
         "coin_logo_key": "456455",
         'blockchain_type': 'public_chain',
         'data_link': 'www.baidu.com',
         'block_browser': 'www.baidu.com'
     }
     req = ApplicationRequest(**payload2)
     try:
         project_api.applications_id_put(id=project_id, body=req)
     except ApiException as apiexc:
         assert apiexc.status == 400
     else:
         assert False
Beispiel #24
0
    def create_all_done_account(api_list, platform='otc'):
        # 注册
        # 登录
        manager = PlatformManager(platform)
        account_api = manager.account_api
        asset_api = manager.asset_api
        verify_api = manager.verify_api
        user = register_with_login(platform, with_login, [
            account_api, otc_balance_api, asset_api, verify_api, otc_buss_api,
            otc_asset_api
        ] + api_list)
        email = user.get("email")
        # 实名认证
        id_number = get_random_id_number()
        individual_verify(platform, id_number, user.get('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)
        # 随机资金密码
        assert_password = faker.password()
        # print(user)
        # 设置资金密码,
        # 需要二次验证才能设置资金密码
        res = verify_info(manager, email, 'edit_asset_pwd')
        base_token = res.token
        asset_api.asset_mgmt_asset_password_put(
            body={
                "password": user.get("password"),
                "traPassword": assert_password,
                "baseToken": base_token
            })
        res = asset_api.asset_mgmt_asset_password_get()
        assert res.is_set
        user_res_info = dict()
        user_res_info['asset_password'] = assert_password
        # 查询otc交易支持的币种列表
        otc_coin_list = otc_balance_api.balance_otc_coin_list_get()
        # print('otc交易支持的币种列表:', otc_coin_list)
        seller_coins = []
        for i in otc_coin_list.items:
            i = i.to_dict()
            if i['short_name'] == 'USDT':
                usdt_coin_id = i['coin_id']
            else:
                seller_coins.append(i['coin_id'])
        coin_id = random.choice(seller_coins or [usdt_coin_id + 1])  # random_coin.coin_id

        # 充币金手指
        headers = {"Authorization": "Bearer {}".format(user.get('token'))}
        host = configuration.host
        account_info = account_api.accounts_account_info_get()
        account_id = account_info.account_info.account_id
        user_res_info['account_id'] = account_id

        res = requests.post(
            f'{host}/asset-test/asset-initialize/{coin_id}/100000000',
            headers=headers)
        # print(res)
        res = requests.post(
            f'{host}/asset-test/asset-initialize/{usdt_coin_id}/100000000',
            headers=headers)
        # print(coin_id)
        # print(usdt_coin_id)
        bb_res2 = otc_asset_api.asset_mgmt_assets_coin_id_get(coin_id=coin_id)
        # print('币币余额:', bb_res2)
        # 认证商户
        # 后台登录
        user_token = get_admin_token()
        user_res_info['admin_token'] = user_token
        user_res_info['buyer_coin_id'] = usdt_coin_id
        user_res_info['seller_coin_id'] = coin_id
        user_res_info['user_token'] = user.get('token')
        set_login_status(staff_buss_api, user_token)
        set_login_status(staff_bal_api, user_token)
        # 前台申请,后端通过
        # otc平台申请成为商家
        res = otc_buss_api.biz_apply_post()

        admin_biz_rec = staff_buss_api.admin_biz_find_page_get(
            user_id=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)

        # 币币划拨资产到法币余额
        transload = TransferFromRequest(
            currency_id=usdt_coin_id, amount=1000000)
        otc_balance_api.balance_transfer_from_post(transload)
        transload = TransferFromRequest(currency_id=coin_id, amount=1000000)
        otc_balance_api.balance_transfer_from_post(transload)
        return user_res_info
Beispiel #25
0
 def individual():
     id_number = get_random_id_number()
     individual_verify(platform, id_number, token)
Beispiel #26
0
 def create_all_done_account(api_list, platform='otc'):
     # 注册
     # 登录
     manager = PlatformManager(platform)
     account_api = manager.account_api
     asset_api = manager.asset_api
     verify_api = manager.verify_api
     user = register_with_login(platform, with_login, [
         account_api, otc_balance_api, asset_api, verify_api, otc_buss_api,
         otc_asset_api
     ] + api_list)
     email = user.get("email")
     # 实名认证
     id_number = get_random_id_number()
     individual_verify(platform, id_number, user.get('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)
     # 随机资金密码
     assert_password = faker.password()
     # 设置资金密码,
     # 需要二次验证才能设置资金密码
     res = verify_info(manager, email, 'edit_asset_pwd')
     base_token = res.token
     asset_api.asset_mgmt_asset_password_put(
         body={
             "password": user.get("password"),
             "traPassword": assert_password,
             "baseToken": base_token
         })
     res = asset_api.asset_mgmt_asset_password_get()
     assert res.is_set
     user_res_info = dict()
     user_res_info['asset_password'] = assert_password
     # 查询otc交易支持的币种列表
     otc_coin_list = otc_balance_api.balance_otc_coin_list_get()
     print('otc交易支持的币种列表:', otc_coin_list)
     seller_coins = []
     for i in otc_coin_list.items:
         i = i.to_dict()
         if i['short_name'] == 'USDT':
             usdt_coin_id = i['coin_id']
         else:
             seller_coins.append(i['coin_id'])
     coin_id = random.choice(seller_coins or [usdt_coin_id + 1])
     # assert len(res) == 0
     # return
     # random_coin = random.choice(res)
     # 充币金手指
     headers = {"Authorization": "Bearer {}".format(user.get('token'))}
     print('headers:', headers)
     host = configuration.host
     account_info = account_api.accounts_account_info_get()
     account_id = account_info.account_info.account_id
     user_res_info['account_id'] = account_id
     # for _ in range(100):
     res = requests.post(
         f'{host}/asset-test/asset-initialize/{coin_id}/1000000000',
         headers=headers)
     res = requests.post(
         f'{host}/asset-test/asset-initialize/{usdt_coin_id}/10000000000',
         headers=headers)
     print('冲币res:', res)
     bb_res2 = otc_asset_api.asset_mgmt_assets_coin_id_get(coin_id=coin_id)
     print('币币余额:', bb_res2)
     return
     # 币币划拨资产到法币余额
     transload = TransferFromRequest(currency_id=coin_id, amount=1000000000)
     otc_balance_api.balance_transfer_from_post(transload)
     return user_res_info
Beispiel #27
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
Beispiel #28
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()
        ma_api = MainAccountApi()
        f_api = FavoriteManagementApi()
        token = with_login('tenant',
                           [exchange_api, e_api, f_api, ma_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='approved')
        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 == 'approved'

        rv = exchange_api.exchange_exchange_status_get()
        assert rv.status == 'approved'

        # 合并测试用例
        """2.新增交易所——交易所列表模糊查询——收藏——收藏列表(交易所)"""
        # res = PostPlatFormRegisterRequest()
        # ma_api.create_platform(body=res)
        rv = e_api.exchanges_suggestion_get(name=exchange.name)
        assert len(rv) >= 1
        exchange_id = rv[0]['id']
        # 收藏
        req = PostFavoriterRequest()
        req.favorite_id = exchange_id
        req.type = 'exchange'
        f_api.favorites_post(req)
        # 收藏列表
        rv = f_api.favorites_get(type='exchange')
        items = rv.items
        assert len(items) == 1
        item = items[0]
        assert item.favorite_id == exchange_id
        favorite_record_id = item.id

        """6.收藏交易所成功——收藏列表(交易所)——取消收藏"""
        # 取消收藏
        f_api.favorites_delete(favorite_record_id)
        rv = f_api.favorites_is_favorite_get(favorite_id=exchange_id,
                                             type='exchange')
        assert not rv.status
Beispiel #29
0
 def test_applications19(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)
     # 申请项目
     project_name = get_random_name(2, 16)
     short_name = "Y" + 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)
     # 项目方获取保健列表
     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"
     })
     # 后台获取所有项目列表
     staff_project = Sta_project()
     set_login_status(staff_project, token)
     res = staff_project.projects_get(project_name=project_name)
     up_project_name = ''
     for item in res.items:
         up_project_name = item.project_name
     # 申请项目
     try:
         full_name1 = get_random_name(2, 16)
         short_name1 = get_random_name(2, 6)
         payload1 = {
             "project_name": project_name,
             "description": "{}-description".format(project_name),
             "official_website": "www.{}.com".format(project_name),
             "white_paper_key": "{}-whitePaper".format(project_name),
             "area_code": "+86",
             "project_poster_key": "123455",
             "cellphone": "123456789",
             "telephone": "12345678910",
             "email": faker.email(),
             "full_name": full_name1,
             "short_name": short_name1,
             "issue_price": "2.24545",
             "issued_volume": "1000000",
             "circulation_volume": "1000000",
             "issued_date": "2018-08-08",
             "coin_logo_key": "456455",
             "blockchain_type": "public_chain",
             "data_link": "{}-data-link".format(project_name),
             "block_browser": "{}-block-Browser".format(project_name)
         }
         req = ApplicationRequest(**payload1)
         project_api.applications_post(body=req)
     except ApiException as e:
         assert e.status == 400
         message = json.loads(e.body)['message']
         assert message == '项目名称已经存在'
     else:
         assert False
 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