forked from erp-dev/erp
feat: added plate order clone
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
PlateOrder API 测试
|
||||
"""
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
from rest_framework.test import APIClient
|
||||
from rest_framework import status
|
||||
@@ -294,6 +295,35 @@ class PlateOrderAPITestCase(TestCase):
|
||||
results = response.data['results'] if isinstance(response.data, dict) else response.data
|
||||
self.assertEqual(results[0]['design_code'], str(results[0]['id']))
|
||||
|
||||
def test_plate_order_list_includes_content_type_id(self):
|
||||
"""列表接口应包含 content_type_id(来源 business_object.content_type_id)"""
|
||||
process = stateflow_models.Process.objects.create(name='P-ct')
|
||||
ct = ContentType.objects.get_for_model(stateflow_models.Process)
|
||||
|
||||
bo = stateflow_models.BusinessObject.objects.create(
|
||||
name='BO-ct',
|
||||
process=process,
|
||||
content_type=ct,
|
||||
object_id=123,
|
||||
)
|
||||
plate_order = printing_models.PlateOrder.objects.create(
|
||||
customer=self.customer,
|
||||
design_code='DESIGN-CT',
|
||||
plate_type='圆网',
|
||||
style_name='款式-ct',
|
||||
fabric='棉布',
|
||||
process=process.id,
|
||||
business_object=bo,
|
||||
)
|
||||
|
||||
response = self.client.get('/api/v1/plate-orders/')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
results = response.data['results'] if isinstance(response.data, dict) else response.data
|
||||
|
||||
target = next(item for item in results if item['id'] == plate_order.id)
|
||||
self.assertIn('content_type_id', target)
|
||||
self.assertEqual(target['content_type_id'], ct.id)
|
||||
|
||||
def test_fabric_source_field_in_detail(self):
|
||||
"""验证布料来源字段在返回中存在"""
|
||||
plate_order = printing_models.PlateOrder.objects.create(
|
||||
@@ -687,6 +717,12 @@ class PlateOrderAPITestCase(TestCase):
|
||||
|
||||
self.assertIsNotNone(plate_order.business_object)
|
||||
self.assertEqual(plate_order.business_object.process.id, self.process.id)
|
||||
# 新逻辑:BusinessObject 绑定回 PlateOrder
|
||||
self.assertEqual(
|
||||
plate_order.business_object.content_type_id,
|
||||
ContentType.objects.get_for_model(printing_models.PlateOrder).id
|
||||
)
|
||||
self.assertEqual(plate_order.business_object.object_id, plate_order.id)
|
||||
|
||||
def test_advance_to_next_state(self):
|
||||
"""测试推进到下一个状态"""
|
||||
|
||||
Reference in New Issue
Block a user