forked from erp-dev/erp
feat: added wecom notify when printing_job production was completed(new status) and shipment was created
This commit is contained in:
@@ -3,8 +3,10 @@ Shipment API 测试
|
||||
"""
|
||||
|
||||
from decimal import Decimal
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.test import TestCase
|
||||
from django.test import override_settings
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.utils import timezone
|
||||
@@ -1294,6 +1296,26 @@ class ShipmentCreateAPITestCase(TestCase):
|
||||
self.assertEqual(self.sales_item1.shipment_id, result["id"])
|
||||
self.assertEqual(self.sales_item2.shipment_id, result["id"])
|
||||
|
||||
@override_settings(TESTING=False, SHIPMENT_CREATED_WECOM_NOTIFY_ENABLED=True)
|
||||
def test_create_shipment_enqueues_wecom_notification_task(self):
|
||||
"""测试创建出货单后投递企业微信通知任务"""
|
||||
data = {
|
||||
"customer": self.customer.id,
|
||||
"shipment_date": "2026-01-14",
|
||||
"sales_items": [self.sales_item1.id, self.sales_item2.id],
|
||||
}
|
||||
|
||||
with patch("shipment.tasks.notify_shipment_created_wecom.delay") as mock_delay:
|
||||
with self.captureOnCommitCallbacks(execute=True):
|
||||
response = self.client.post("/api/v1/shipment/shipments/", data, format="json")
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||
shipment_id = response.json()["id"]
|
||||
mock_delay.assert_called_once_with(
|
||||
shipment_id=shipment_id,
|
||||
created_by_id=self.user.id,
|
||||
)
|
||||
|
||||
def test_create_shipment_without_sales_items(self):
|
||||
"""测试创建出货单但不关联销售品"""
|
||||
data = {
|
||||
@@ -2208,11 +2230,17 @@ class SalesItemCreateAPITestCase(APITestCase):
|
||||
area="测试地区Sales",
|
||||
)
|
||||
|
||||
self.category = basic_models.ProductCategory.objects.create(
|
||||
merchant=self.merchant,
|
||||
name="测试分类Sales",
|
||||
)
|
||||
|
||||
# 创建产品
|
||||
self.product = basic_models.Product.objects.create(
|
||||
merchant=self.merchant,
|
||||
category=self.category,
|
||||
name="测试产品",
|
||||
code="TEST001",
|
||||
human_id="TEST001",
|
||||
unit=basic_models.ProductUnitEnum.METER,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user