def test_announcement1(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 = "A" + 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 # 发送项目公告 announcement_api = AnnouncementManagementApi() set_login_status(announcement_api, token) payload1 = { 'title': '项目公告' + str(random.randint(1000, 9999)), 'language': 'zh_cn', 'content': '公告内容', 'project_id': audit_project_id } req = PostNoticesRequest(**payload1) announcement_api.announcements_post(body=req) # 获取项目公告列表 res = announcement_api.announcements_project_id_get( project_id=audit_project_id) assert res.meta.total_count == 1 for item in res.items: assert item.language == 'zh_cn' assert item.title == payload1['title'] assert item.id
def test_applications14(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 = "U" + 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_full_name = '' for item in res.items: up_full_name = item.full_name # 申请项目 project_name1 = get_random_name(2, 16) short_name1 = get_random_name(2, 6) payload1 = { "project_name": project_name1, "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_name, "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) res = project_api.applications_post(body=req) project_apply_id = res.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]) try: sponsor_api.projects_sponsor_put(put_project_sponsor_request={ "id": project_apply_id, "status": 1, "remark": "remark" }) except ApiException as e: assert e.status == 400 message = json.loads(e.body)['message'] assert message == '币种全称已经存在' else: assert False
def test_applications6(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 = "M" + 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": get_random_name(2, 16), "nationality": "+86", "phone": '+8613567' + str(random.randint(100000, 999999)), "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) # 获取项目列表 set_login_status(project_api, token) res = project_api.projects_get(page=1) id_ = '' for item in res.items: if item.project_name == project_name: assert item.full_name == full_name assert item.short_name == short_name assert item.init is True assert item.project_id == item.coin_id id_ = item.project_id # 申请接入交易所 exchange_project_api = ProjectManagementApi() set_login_status(exchange_project_api, token) res = exchange_project_api.projects_id_exchanges_get( id=id_, exchange_name=exchange['name']) exchange_id = '' for item in res.items: exchange_id = item.exchange_id # 申请对接 contacts_api = ContactsApi() set_login_status(contacts_api, token) contacts = { "exchangeId": exchange_id, "projectId": id_, "sponsor": "venture" } contacts_api.contacts_post(contacts) # 获取交易所对接的项目列表 exchange_contacts_api = ExchangeContacts() set_login_status(exchange_contacts_api, token) res = exchange_contacts_api.contacts_projects_exchange_id_get( exchange_id=exchange_id, status="pending") contacts_id = '' for item in res.items: if item.full_name == full_name: contacts_id = item.id # 交易所处理对接邀请—拒绝 contacts = {"contactId": contacts_id, "status": "rejected"} exchange_contacts_api.contacts_put(body=contacts) # 判断项目方与交易所是否已经申请对接 res = exchange_contacts_api.contacts_check_get(project_id=id_, exchange_id=exchange_id) assert res.result is False
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_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_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_failure_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 = "R" + 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": 0, "remark": "remark" } ) # 保荐失败记录 res = sponsor_api.sponsor_record_failure_get(page=1) assert res.meta.total_count == 1
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
def create_venture(): faker = Faker() manager = PlatformManager("venture") user = random_user() manager.register(email=user.get("email"), password=user.get("password"), promotion_code=None, verification_code="666666", nationality_code=user.get("country_abbreviation")) token = manager.login(account=user.get("email"), password=user.get("password")) # 个人实名认证 individual_verify(platform="venture", id_number=get_random_id_number(), token=token) # 申请项目 project_api = ProjectApi() set_login_status(project_api, token) project_name = get_random_name(2, 16) full_name = get_random_name(2, 12) short_name = get_random_name(2, 6) # project_name = "USDT" # short_name = "USDT" res = project_api.applications_post( body={ "projectName": project_name, "description": "{}-project-description".format(project_name), "officialWebsite": "www.{}.com".format(project_name), "whitePaperKey": "{}-whitePaper".format(project_name), "areaCode": "+86", "projectPosterKey": faker.uri_page(), # "projectPosterUrl": faker.url(), "cellphone": "123456789", "telephone": "12345678910", "email": faker.email(), "fullName": "{}的全部名".format(full_name), "shortName": short_name, "issuePrice": "2.24545", "issuedVolume": "1000000", "circulationVolume": "1000000", "issuedDate": "2018-08-08", "coinLogoKey": faker.uri_page(), # "coinLogoUrl": faker.url(), "blockchainType": "public_chain", "dataLink": "{}-data-link".format(project_name), "blockBrowser": "{}-block-Browser".format(project_name) }) 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(8, 20), "password": faker.password(), "name": get_random_name(2, 20), "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" }) # 获取币种列表 asset_api = AssetManagementApi() set_login_status(asset_api, staff_token) res = asset_api.asset_mgmt_coins_get(coin_name=short_name) coin = res.items.pop() coin_id = coin.id # 项目初始化 # staff_project_api = StaffProjectApi() # set_login_status(staff_project_api, staff_token) # staff_project_api.projects_coin_id_init_put(coin_id=coin_id, # body={ # "initFee": 111 # }) rc_confirmed_times = 2 wc_confirmed_times = 2 asset_api.asset_mgmt_coins_id_init_put(id=coin_id, body={ "usdtPrice": "1", "rcTimes": rc_confirmed_times, "wcTimes": wc_confirmed_times, "withdrawRate": "0.003", "minWithdrawFee": "0.1", "minWithdraw": "20", "maxWithdraw": "1000", "dayWithdrawTotal": "30000", "minRecharge": "0.1", "addressTagSwitch": True, "addressType": short_name, "addressUrl": "addressUrl", "txidUrl": "fdfsfdstxidUrl" }) # # 修改币种配置 # asset_api.asset_mgmt_coins_id_put( # id=coin.id, body={ # "rcTimes": 2, # "wcTimes": 2, # "withdrawRate": "0.003", # "minWithdrawFee": "0.1", # "minWithdraw": "20", # "maxWithdraw": "1000", # "dayWithdrawTotal": "30000", # "minRecharge": "0.1", # "addressTagSwitch": True, # "addressType": short_name, # "addressUrl": "addressUrl", # "txidUrl": "fdfsfdstxidUrl" # }) register_wallet(short_name) return coin.id, coin.coin_id, short_name, rc_confirmed_times, wc_confirmed_times
def test_announcement4(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 = "AB" + 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 # 发送报告 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) # 获取项目报告列表 staff_am_api = AnnouncementManagementApi() set_login_status(staff_am_api, token) report_id = '' status = '' res = staff_am_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.status is True report_id = item.id status = item.status # 修改项目报告状态 staff_am_api.reports_id_status_put(id=report_id, status=False) # 获取项目报告列表 res = staff_am_api.reports_project_id_get(project_id=report_id) for item in res.items: assert item.title == payload1['title'] assert item.type == payload1['type'] assert item.status is False assert item.status != status
def test_register(self, with_login): manager = PlatformManager('tenant') m_api = MarketManagementApi() e_api = ExchangeManagementApi() api = manager.account_api verify_api = manager.verify_api account_api = AccountApi() venture_api = VentureApi() va_api = VentureAccountApi() contacts_api = ContactsApi() vc = VentureContactsApi() pm = ProjectManagementApi() user = register_with_login('tenant', with_login, [ api, verify_api, m_api, e_api, account_api, venture_api, va_api, contacts_api, pm, vc ]) token = user['token'] email = user.get('email') self.data['token1'] = token # 绑定电话 faker = Faker('zh_CN') phone = faker.phone_number() verify = verify_info(manager, email, "bind_phone") manager.bind_phone(phone, DEFAULT_VERIFY_CODE, area_code="+86", token=verify.token) id_number = get_random_id_number() individual_verify('tenant', id_number, token) # 授权 res = PostPlatFormRegisterRequest() va_api.create_platform(body=res) # 申请项目 project1 = get_project(token) rv = venture_api.applications_post(body=project1) application_id_1 = rv.id sponsor = get_sponsors() # 登录保健方 account, password = sponsor['account'], sponsor['password'] sponsor_token = get_sponsor_token(account, password, email='test') project2 = get_project(token) # req = ApplicationRequest(**project) rv = venture_api.applications_post(body=project2) application_id_2 = rv.id rv = venture_api.projects_get(page=1) assert len(rv.items) == 0 rv = venture_api.applications_get(page=1) assert len(rv.items) == 2 # 设置保健机构 venture_api.applications_id_set_sponsor_put( application_id_1, {'sponsorId': sponsor['id']}) venture_api.applications_id_set_sponsor_put( application_id_2, {'sponsorId': sponsor['id']}) sponsor_project_api = SponsorsProjectApi() set_login_status(sponsor_project_api, sponsor_token) sponsor_project_api.projects_sponsor_put({ 'id': application_id_1, 'status': 1, 'remark': 'test' }) sponsor_project_api.projects_sponsor_put({ 'id': application_id_2, 'status': 1, 'remark': 'test' }) rv = venture_api.projects_get(page=1) project_id1 = rv.items[1].project_id project_id2 = rv.items[0].project_id self.data['project_id1'] = project_id1 self.data['project_id2'] = project_id2 # 设置接入方式 setting = PutProjectRequestSetting(access_method='verification', open=True) req = PutProjectRequest() req.setting = setting venture_api.projects_id_put(project_id1, 'setting', req) venture_api.projects_id_put(project_id2, 'setting', req) # 获取项目详情 # 初始化项目 s_api = SystemManagementApi() staff_project_api = StaffProjectApi() asset_management_api = AssetManagementApi() admin_token = get_admin_token() set_login_status(staff_project_api, admin_token) set_login_status(asset_management_api, admin_token) set_login_status(s_api, admin_token) coin_name1 = project1['shortName'] rv = asset_management_api.asset_mgmt_coins_get(coin_name=coin_name1) coin_config_id1 = rv.items[0].id coin_name2 = project2['shortName'] rv = asset_management_api.asset_mgmt_coins_get(coin_name=coin_name2) coin_config_id2 = rv.items[0].id # 修改币种配置 res = PutSystemCoinsInitRequest() res.usdt_price = '1251' res.rc_times = 8 res.wc_times = 8 res.withdraw_rate = 0.1 res.min_withdraw = 100 res.min_withdraw_fee = 0.1 res.max_withdraw = 1000 res.min_recharge = 10 res.address_tag_switch = True res.day_withdraw_total = 125564 res.address_type = 'OX' res.address_url = 'http://unknown.com' res.txid_url = 'http://unknown.com' asset_management_api.asset_mgmt_coins_id_init_put(coin_config_id1, res) asset_management_api.asset_mgmt_coins_id_init_put(coin_config_id2, res)
def test_add_market2(self, with_login): user = self.data['user'] email, password = user['email'], user['password'] m_api = MarketManagementApi() e_api = ExchangeManagementApi() s_api = SponsorApi() venture_api = VentureApi() va_api = VentureAccountApi() project_api = ProjectApi() contacts_api = ContactsApi() tam_api = TenantAssetManagementApi() v_api = VerificationApi() ma_api = MainExchangeApi() vc = VentureContactsApi() pm = ProjectManagementApi() tenant_ca = TenantContactsApi() token = with_login('tenant', [ pm, vc, ma_api, v_api, contacts_api, project_api, m_api, e_api, va_api, s_api, venture_api, tam_api, tenant_ca ], email, password) # 交易币种 rv = e_api.exchange_exchange_coin_get() seller_coin = rv.seller_coin buyer_coin = rv.buyer_coin b_coin = buyer_coin[0] if seller_coin: s_coin = seller_coin[0] else: sponsor = get_sponsors() # 登录保健方 account, password = sponsor['account'], sponsor['password'] sponsor_api = SponsorApi() sponsor_token = get_sponsor_token(account, password, email='test') set_login_status(sponsor_api, sponsor_token) project = get_project(token) # req = ApplicationRequest(**project) rv = venture_api.applications_post(body=project) application_id = rv.id # 查看申请列表 rv = venture_api.applications_get(page=1, order='desc') assert len(rv.items) == 2 item = rv.items[0] assert item.project_name == project['projectName'] assert item.fullname == project['fullName'] assert item.short_name == project['shortName'] rv = venture_api.applications_num_get(status='under_review') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='passed') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='undone') assert int(rv.result) == 1 # 设置保健机构 venture_api.applications_id_set_sponsor_put( application_id, {'sponsorId': sponsor['id']}) rv = venture_api.applications_num_get(status='undone') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='under_review') assert int(rv.result) == 1 rv = venture_api.applications_num_get(status='passed') assert int(rv.result) == 0 project_name = project['projectName'] sponsor_project_api = SponsorsProjectApi() set_login_status(sponsor_project_api, sponsor_token) rv = sponsor_project_api.projects_get(page=1, project_name=project_name) assert len(rv.items) >= 1 rv = sponsor_project_api.projects_id_get(id=application_id) assert rv sponsor_project_api.projects_sponsor_put({ 'id': application_id, 'status': 1, 'remark': 'test' }) rv = venture_api.applications_num_get(status='undone') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='under_review') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='passed') assert int(rv.result) == 1 rv = venture_api.applications_num_get(status='turn_down') assert int(rv.result) == 1 # 保鉴成功列表 rv = sponsor_project_api.sponsor_record_success_get( page=1, coin_name=project['shortName']) # 项目列表 rv = venture_api.projects_get(page=1) project_id = rv.items[0].project_id self.data['project_id'] = project_id # 设置接入方式 setting = PutProjectRequestSetting(access_method='accept', open=True) req = PutProjectRequest() req.setting = setting venture_api.projects_id_put(project_id, 'setting', req) # 获取项目详情 rv = venture_api.projects_id_get(project_id) exchange_id = TestMarket1.data['exchange_id'] rv = project_api.projects_get(coin_name=project['shortName']) assert len(rv.items) == 0 # 初始化项目 s_api = SystemManagementApi() staff_project_api = StaffProjectApi() asset_management_api = AssetManagementApi() admin_token = get_admin_token() set_login_status(staff_project_api, admin_token) set_login_status(asset_management_api, admin_token) set_login_status(s_api, admin_token) coin_name = project['shortName'] rv = asset_management_api.asset_mgmt_coins_get(coin_name=coin_name) coin_id = rv.items[0].coin_id coin_config_id = rv.items[0].id # 修改币种配置 res = PutSystemCoinsInitRequest() res.usdt_price = '1251' res.rc_times = 8 res.wc_times = 8 res.withdraw_rate = 0.1 res.min_withdraw = 100 res.min_withdraw_fee = 0.1 res.max_withdraw = 1000 res.min_recharge = 10 res.address_tag_switch = True res.day_withdraw_total = 125564 res.address_type = 'OX' res.address_url = 'http://unknown.com' res.txid_url = 'http://unknown.com' # asset_management_api.asset_mgmt_coins_id_put(coin_id, res) asset_management_api.asset_mgmt_coins_id_init_put( coin_config_id, res) rv = project_api.projects_get(coin_name=project['shortName']) assert len(rv.items) == 1 setting = PutProjectRequestSetting(access_method='refuse', open=True) req = PutProjectRequest() req.setting = setting venture_api.projects_id_put(project_id, 'setting', req) # refuse rv = project_api.projects_get(coin_name=project['shortName']) assert len(rv.items) == 0 setting = PutProjectRequestSetting(access_method='verification', open=True) req = PutProjectRequest() req.setting = setting venture_api.projects_id_put(project_id, 'setting', req) rv = project_api.projects_get(coin_name=project['shortName']) assert len(rv.items) == 1 rv = s_api.system_trading_pair_get(name=project['shortName'], partition_id=b_coin.id) # 对接币种 req = { 'exchangeId': exchange_id, 'projectId': project_id, 'sponsor': 'tenant' } contacts_api.contacts_post(req) rv = pm.projects_id_exchanges_get(project_id) rv = pm.projects_id_contacts_get(project_id, 'tenant') assert rv.items[0].exchange_id == exchange_id rv1 = contacts_api.contacts_check_get(project_id=project_id, exchange_id=exchange_id) assert rv1.result r1 = contacts_api.contacts_project_id_status_get(project_id) assert r1.status == 'pending' # 处理对接邀请 contact_id = rv.items[0].contact_id r = tenant_ca.contacts_projects_exchange_id_get( exchange_id, 'pending') assert not r.items vc.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 = contacts_api.contacts_project_id_status_get(project_id) assert rv.status == 'accepted' rv = e_api.exchange_exchange_coin_get() seller_coin = rv.seller_coin s_coin = seller_coin[0] # 主平台获取买卖方币种列表 rv = ma_api.exchanges_exchange_coin_exchange_id_get(exchange_id) assert rv.seller_coin[0].name == project['shortName'] self.data['s_coin'] = s_coin self.data['b_coin'] = b_coin res = PostOrderMarketRequest() 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 now = datetime.now() disabled_at = now + relativedelta(months=AllottedTime._6month) 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 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)
def test_add_market1(self, with_login): user = self.data['user'] email, password = user['email'], user['password'] m_api = MarketManagementApi() e_api = ExchangeManagementApi() s_api = SponsorApi() venture_api = VentureApi() va_api = VentureAccountApi() project_api = ProjectApi() contacts_api = ContactsApi() tam_api = TenantAssetManagementApi() v_api = VerificationApi() ma_api = MainExchangeApi() vc = VentureContactsApi() pm = ProjectManagementApi() token = with_login('tenant', [ pm, vc, ma_api, v_api, contacts_api, project_api, m_api, e_api, va_api, s_api, venture_api, tam_api ], email, password) # 授权 res = PostPlatFormRegisterRequest() va_api.create_platform(body=res) # 交易币种 rv = e_api.exchange_exchange_coin_get() seller_coin = rv.seller_coin buyer_coin = rv.buyer_coin b_coin = buyer_coin[0] if seller_coin: s_coin = seller_coin[0] else: sponsor = get_sponsors() # 登录保健方 account, password = sponsor['account'], sponsor['password'] sponsor_api = SponsorApi() sponsor_token = get_sponsor_token(account, password, email='test') set_login_status(sponsor_api, sponsor_token) project = get_project(token) # req = ApplicationRequest(**project) rv = venture_api.applications_post(body=project) application_id = rv.id # 查看申请列表 rv = venture_api.applications_get(page=1) assert len(rv.items) == 1 item = rv.items[0] assert item.project_name == project['projectName'] assert item.fullname == project['fullName'] assert item.short_name == project['shortName'] rv = venture_api.applications_num_get(status='under_review') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='passed') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='undone') assert int(rv.result) == 1 # 设置保健机构 venture_api.applications_id_set_sponsor_put( application_id, {'sponsorId': sponsor['id']}) rv = venture_api.applications_num_get(status='undone') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='under_review') assert int(rv.result) == 1 rv = venture_api.applications_num_get(status='passed') assert int(rv.result) == 0 project_name = project['projectName'] sponsor_project_api = SponsorsProjectApi() set_login_status(sponsor_project_api, sponsor_token) rv = sponsor_project_api.projects_get(page=1, project_name=project_name) assert len(rv.items) >= 1 rv = sponsor_project_api.projects_id_get(id=application_id) assert rv # 保健不通过 sponsor_project_api.projects_sponsor_put({ 'id': application_id, 'status': 0, 'remark': 'test' }) rv = venture_api.applications_num_get(status='undone') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='under_review') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='passed') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='turn_down') assert int(rv.result) == 1 # 保鉴成功列表 rv = sponsor_project_api.sponsor_record_success_get( page=1, coin_name=project['shortName']) assert not rv.items # 项目列表 rv = venture_api.projects_get(page=1) assert len(rv.items) == 0