refactor(douyu): 统一账号准入与本地查询链路
This commit is contained in:
@@ -118,6 +118,42 @@ def test_supply_inventory_separates_available_and_allocatable(db):
|
||||
assert inventory.needs_replenishment is True
|
||||
|
||||
|
||||
def test_supply_allocatable_uses_the_same_pool_owner_filter_as_selection(db):
|
||||
customer = User(
|
||||
username="supply-customer",
|
||||
password_hash="h",
|
||||
role="customer",
|
||||
is_active=True,
|
||||
)
|
||||
free = _account("supply-pool-free", points=400)
|
||||
customer_assigned = _account("supply-customer-assigned", points=400)
|
||||
db.add(customer)
|
||||
db.flush()
|
||||
customer_assigned.assigned_to = customer.id
|
||||
db.add_all([free, customer_assigned])
|
||||
db.flush()
|
||||
db.add_all([_state(free), _state(customer_assigned)])
|
||||
db.add(
|
||||
AccountSupplyTarget(
|
||||
platform="douyu",
|
||||
scope="elite",
|
||||
commodity_id="C",
|
||||
value_class=VALUE_HIGH,
|
||||
target_covered=2,
|
||||
target_available=2,
|
||||
target_allocatable=2,
|
||||
)
|
||||
)
|
||||
db.commit()
|
||||
target = db.query(AccountSupplyTarget).one()
|
||||
|
||||
inventory = evaluate_supply_target(db, target, now=NOW)
|
||||
|
||||
assert inventory.covered == 2
|
||||
assert inventory.available == 2
|
||||
assert inventory.allocatable == 1
|
||||
|
||||
|
||||
def test_global_supply_inventory_batches_value_classes_in_two_queries(db):
|
||||
user = User(
|
||||
username="global-supply-owner",
|
||||
|
||||
Reference in New Issue
Block a user