Beispiel #1
0
 def test_applications_id_put(
         self, project_name, description, official_website, white_paper,
         area_code, project_poster, cellphone, telephone, email, full_name,
         short_name, issue_price, issued_volume, circulation_volume,
         issued_at, coin_logo, blockchain_type, data_link, block_browser):
     """Test case for applications_id_put
     修改申请信息  # noqa: E501
     """
     payload = {
         'project_name': project_name,
         'description': description,
         'official_website': official_website,
         'white_paper': white_paper,
         'area_code': area_code,
         'project_poster': project_poster,
         'cellphone': cellphone,
         'telephone': telephone,
         'email': email,
         'full_name': full_name,
         'short_name': short_name,
         'issue_price': issue_price,
         'issued_volume': issued_volume,
         'circulation_volume': circulation_volume,
         'issued_at': issued_at,
         'coin_logo': coin_logo,
         'blockchain_type': blockchain_type,
         'data_link': data_link,
         'block_browser': block_browser
     }
     req = ApplicationRequest(**payload)
     api.applications_id_put(id='', body=req)
Beispiel #2
0
    def test_applications_id_set_sponsor_put(self):
        """Test case for applications_id_set_sponsor_put

        设置项目保荐机构  # noqa: E501
        """
        payload = {"sponsorId": ""}
        req = ApplicationRequest(**payload)
        api.applications_id_set_sponsor_put(id='', body=req)
Beispiel #3
0
 def test_applications_post(
         self, project_name, description, official_website, white_paper,
         area_code, project_poster, cellphone, telephone, email, full_name,
         short_name, issue_price, issued_volume, circulation_volume,
         issued_at, coin_logo, blockchain_type, data_link, block_browser):
     """Test case for applications_post
     申请项目  # noqa: E501
     """
     payload = {
         'project_name': project_name,
         'description': description,
         'official_website': official_website,
         'white_paper': white_paper,
         'area_code': area_code,
         'project_poster': project_poster,
         'cellphone': cellphone,
         'telephone': telephone,
         'email': email,
         'full_name': full_name,
         'short_name': short_name,
         'issue_price': issue_price,
         'issued_volume': issued_volume,
         'circulation_volume': circulation_volume,
         'issued_at': issued_at,
         'coin_logo': coin_logo,
         'blockchain_type': blockchain_type,
         'data_link': data_link,
         'block_browser': block_browser
     }
     try:
         req = ApplicationRequest(**payload)
         api.applications_post(body=req)
     except ApiException as e:
         if not all(payload["project_name"] == ''):
             assert e.status == 400
         elif any([
                 True for i in [project_name, full_name, short_name]
                 if (len(i) > 16 or len(i) < 2)
         ]):
             assert e.status == 400
         elif any([
                 True
                 for i in [issue_price, issued_volume, circulation_volume]
                 if (len(i) > 16 or len(i) < 1)
         ]):
             assert e.status == 400
         elif any([True for i in telephone if (len(i) > 16 or len(i) < 8)]):
             assert e.status == 400
Beispiel #4
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 #8
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
Beispiel #9
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
Beispiel #11
0
 def test_applications_post(self, mocking):
     project_application = ApplicationRequest(**TEST_PROJECT)
     result = api_projects.applications_post(body=project_application)
     assert result.id
     pytest.application_id = result.id
Beispiel #12
0
    def test_applications4(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 = "K" + 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"
        })
        # 获取项目列表
        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
        # 获取项目详情
        res = project_api.projects_id_get(id=audit_project_id)
        assert res.sponsor_info.sponsor_name == sponsor.get("name")
        assert res.sponsor_info.sponsor_id
        assert res.project_info.project_name == project_name
        assert res.project_info.id
        assert res.coin_info.short_name == short_name
        assert res.coin_info.full_name == full_name
        assert res.coin_info.id
        # 修改项目信息
        project_info1 = {
            "white_paper_key": "url/pdf123455",
            "official_website": "www.xxxx.com",
            "email": "*****@*****.**",
            "area_code": "+86",
            "cellphone": "13510022445",
            "telephone": "12874846",
            "project_poster_key": "url/image123455",
            "description": "以太坊(英文Ethereum)是一个开源的有智能合约功能的公共区块链平台"
        }
        communities = {'type': 'QQ', 'value': 'www.qq.com'}
        setting = {'open': True, 'access_method': 'accept'}
        data = PutProjectRequest()
        data.project_info = PutProjectRequestProjectInfo(**project_info1)
        data.setting = PutProjectRequestSetting(**setting)
        data.communities = [PutProjectRequestCommunities(**communities)]
        project_api.projects_id_put(id=audit_project_id,
                                    type='base',
                                    body=data)
        # 获取项目列表
        res = project_api.projects_get(page=1)
        audit_project_id = ''
        for item in res.items:
            if item.project_name == project_name:
                audit_project_id = item.project_id
        # 获取项目详情
        res = project_api.projects_id_get(id=audit_project_id)
        assert res.sponsor_info.sponsor_name == sponsor.get("name")
        assert res.sponsor_info.sponsor_id
        assert res.project_info.project_name == project_name
        assert res.project_info.id
        assert res.coin_info.short_name == short_name
        assert res.coin_info.full_name == full_name
        assert res.coin_info.id
    def test_applications17(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 = "W" + 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"
        })
        # 获取项目列表
        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
        # 获取项目详情
        res = project_api.projects_id_get(id=audit_project_id)
        assert res.sponsor_info.sponsor_name == sponsor.get("name")
        assert res.sponsor_info.sponsor_id
        assert res.project_info.project_name == project_name
        assert res.project_info.id
        assert res.coin_info.short_name == short_name
        assert res.coin_info.full_name == full_name
        assert res.coin_info.id
        # 修改申请项目
        payload1 = {
            "communities": [{
                "type": "QQ",
                "value": "http://qq.com"
            }, {
                "type": "Facebook",
                "value": "http://Facebook.com"
            }, {
                "type": "twitter",
                "value": "http://www.twitter.com"
            }]
        }
        project_api.projects_id_put(id=audit_project_id,
                                    type="community",
                                    body=payload1)
        # 获取项目列表
        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
        # 获取项目详情
        res = project_api.projects_id_get(id=audit_project_id)
        assert res.sponsor_info.sponsor_name == sponsor.get("name")
        assert res.sponsor_info.sponsor_id
        assert res.project_info.project_name == project_name
        assert res.project_info.id
        assert res.coin_info.short_name == short_name
        assert res.coin_info.full_name == full_name
        assert res.coin_info.id
        for ties in res.project_info.communities:
            assert ties.type in ('qq', 'facebook', 'twitter')
            assert ties.type in ties.value.lower()
    def test_announcement3(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 = "AQ" + str(random.randint(100, 999))
        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
        # 发送新闻资讯
        news_api = NewManagementApi()
        set_login_status(news_api, token)
        payload1 = {
            'title': '新闻资讯' + str(random.randint(1000, 9999)),
            'link': 'www.baidu.com',
            'source': '百度',
            'project_id': audit_project_id
        }
        req = PostNewsRequest(**payload1)
        news_api.news_post(body=req)
        # 获取项目资讯列表
        staff_am_api = AnnouncementManagementApi()
        set_login_status(staff_am_api, token)
        news_id = ''
        staff_am_api = AnnouncementManagementApi()
        set_login_status(staff_am_api, token)
        res = staff_am_api.news_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.source == payload1['source']
            assert item.status is True
            assert item.url
            news_id = item.id
        # 修改项目资讯状态
        staff_am_api.news_id_status_put(id=news_id, status=False)
        # 获取项目列表资讯
        res = staff_am_api.news_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.source == payload1['source']
            assert item.status is False
Beispiel #15
0
    def test_staff_venture_case1(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 = "WE" + str(random.randint(1000, 9999))
        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"
        })
        # 币种配置列表
        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)
        # 后台查询项目方用户列表
        staff_venture_api = VentureManagementApi()
        set_login_status(staff_venture_api, token)
        res = staff_venture_api.accounts_ventures_get(email=email)
        assert res.meta.total_count == 1
        uid = ''
        for item in res.items:
            assert item.email == email
            assert item.venture_id
            uid = item.uid
        # 获取项目方用户信息
        res = staff_venture_api.accounts_ventures_id_get(id=uid)
        assert res.email == email
        assert res.account_id
        assert res.venture_id