Commit 072be617 authored by lujuan's avatar lujuan

新增智能接单自动化脚本

parent 50073f77
This diff is collapsed.
......@@ -24,6 +24,7 @@ class AutoAcceptanceCase:
sub_order_title_suffix: str
verify_mode: str = "hall"
merchant_name: str = ""
workshop_name: str = ""
@dataclass(frozen=True)
......@@ -39,11 +40,14 @@ class GuaranteeAutoAcceptanceCase:
sub_order_title_suffix: str
receive_price: str = "80"
dispatch_price: str = "70"
dispatch_price_mode: str = "percent"
security_deposit: str = "0"
efficiency_deposit: str = "0"
expected_wanzhanggui_statuses: tuple[str, ...] = ("待接单", "代练中")
expected_scope: str = "私单"
verify_mode: str = "create"
close_guarantee_after_case: bool = False
merchant_name: str = "测试001"
CASES = [
......@@ -60,6 +64,7 @@ CASES = [
sub_order_title_suffix="私单标识",
verify_mode="branch",
merchant_name="测试001",
workshop_name="旺仔工作室",
),
# 用例1.2:关闭自动接指派单后创建私单,校验丸掌柜待接单且丸友集抢单大厅-私单可见。
AutoAcceptanceCase(
......@@ -74,6 +79,7 @@ CASES = [
sub_order_title_suffix="私单标识",
verify_mode="hall",
merchant_name="测试001",
workshop_name="旺仔工作室",
),
# 用例1.1:开启自动接指派单后创建私单,校验丸掌柜代练中且丸友集订单列表已接单。
AutoAcceptanceCase(
......@@ -88,6 +94,7 @@ CASES = [
sub_order_title_suffix="私单标识",
verify_mode="accepted",
merchant_name="测试001",
workshop_name="旺仔工作室",
),
# 用例2:创建公池单,校验丸友集抢单大厅-公池单可见。
AutoAcceptanceCase(
......@@ -101,24 +108,45 @@ CASES = [
expected_scope="公池单",
sub_order_title_suffix="公池单标识",
verify_mode="hall",
workshop_name="旺仔工作室",
),
]
GUARANTEE_CASES = [
# 用例3.1:独立创建一笔担保私单;搜索到丸掌柜状态为代练中后点击详情提取ORB,再校验担保交易扣除金额;结束后不关闭担保。
# 用例3.1:独立创建一笔担保私单;私单应进入代练中,随后点击详情提取ORB并校验担保交易扣除金额;结束后不关闭担保。
GuaranteeAutoAcceptanceCase(
use_case_no="3.1",
case_id="AUTO-ACCEPT-GUARANTEE-TRADE-AMOUNT",
title="担保单代练中后进详情提取ORB并核对担保交易扣除金额",
title="担保单代练中后进详情提取ORB并核对担保交易扣除金额",
wanzhanggui_phone="17788888888",
wanyouji_phone="18800000001",
workshop_name="旺仔工作室",
strategy_name="指定-旺仔",
strategy_type="单平台指定",
sub_order_title_suffix="担保私单标识",
dispatch_price="0.1",
dispatch_price_mode="fixed",
expected_wanzhanggui_statuses=("代练中",),
verify_mode="trade_amount",
),
# 用例3.1:独立创建一笔担保公池单;公池单应保持待接单,并在丸友集抢单大厅-公池单可见;结束后不关闭担保。
GuaranteeAutoAcceptanceCase(
use_case_no="3.1",
case_id="AUTO-ACCEPT-GUARANTEE-POOL",
title="担保公池单待接单并在丸友集公池单可见",
wanzhanggui_phone="17788888888",
wanyouji_phone="18800000001",
workshop_name="旺仔工作室",
strategy_name="多发测试",
strategy_type="多工作室同时分发",
sub_order_title_suffix="担保公池单标识",
dispatch_price="0.1",
dispatch_price_mode="fixed",
expected_wanzhanggui_statuses=("待接单",),
expected_scope="公池单",
verify_mode="hall",
),
# 用例3.2:检查担保已开启,若关闭则开启;独立创建一笔发单价80000的担保私单,结束后不关闭担保。
GuaranteeAutoAcceptanceCase(
use_case_no="3.2",
......@@ -282,6 +310,14 @@ def test_自动接单用例_普通单发单和分支校验(
order_page = WanzhangguiOrderPage(page, settings.tenant_home_url, bug_reporter)
fulfillment_page = WanyoujiFulfillmentPage(page, settings.tenant_home_url, bug_reporter)
try:
if case.workshop_name:
order_page.login_main_account(case.wanzhanggui_phone, wanzhanggui_account.password)
order_page.ensure_workshop_guarantee(case.workshop_name, enabled=False)
bug_reporter.record_if_errors(
account=case.wanzhanggui_phone,
location=f"{case.case_id} 发单前关闭工作室担保 {case.workshop_name}",
)
if case.verify_mode == "branch" and case.merchant_name:
fulfillment_page.login_main_account(case.wanyouji_phone, wanyouji_account.password)
fulfillment_page.ensure_auto_accept_assignment(case.merchant_name, enabled=False)
......@@ -461,6 +497,7 @@ def test_自动接单用例_担保单发单和担保交易校验(
strategy_type=case.strategy_type,
receive_price=case.receive_price,
dispatch_price=case.dispatch_price,
dispatch_price_mode=case.dispatch_price_mode,
security_deposit=case.security_deposit,
efficiency_deposit=case.efficiency_deposit,
role_name=f"AAG角色{timestamp[-4:]}",
......@@ -468,6 +505,15 @@ def test_自动接单用例_担保单发单和担保交易校验(
order_page = WanzhangguiOrderPage(page, settings.tenant_home_url, bug_reporter)
try:
if case.merchant_name:
fulfillment_page = WanyoujiFulfillmentPage(page, settings.tenant_home_url, bug_reporter)
fulfillment_page.login_main_account(case.wanyouji_phone, wanyouji_account.password)
fulfillment_page.ensure_auto_accept_assignment(case.merchant_name, enabled=True)
bug_reporter.record_if_errors(
account=case.wanyouji_phone,
location=f"{case.case_id} 发担保单前确认{case.merchant_name}自动接指派单开启",
)
order_page.login_main_account(case.wanzhanggui_phone, wanzhanggui_account.password)
bug_reporter.record_if_errors(
account=case.wanzhanggui_phone,
......@@ -524,10 +570,10 @@ def test_自动接单用例_担保单发单和担保交易校验(
)
if case.verify_mode != "trade_amount":
fulfillment_page.verify_order_reached_hall(source_order_no, order_title, "私单")
fulfillment_page.verify_order_reached_hall(source_order_no, order_title, case.expected_scope)
bug_reporter.record_if_errors(
account=case.wanyouji_phone,
location=f"{case.case_id} 丸友集抢单大厅-私单可见 {source_order_no}",
location=f"{case.case_id} 丸友集抢单大厅-{case.expected_scope}可见 {source_order_no}",
)
store.mark_order_dispatched(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment