1
0
forked from erp-dev/erp

fix: process id change when plate_order and printing_order update

This commit is contained in:
2026-01-15 16:35:46 +08:00
parent 9a367caab7
commit ea9f378de9
9 changed files with 384 additions and 8 deletions

View File

@@ -33,6 +33,10 @@ class PrintingJobAPITestCase(TestCase):
password='testpass123',
email='test@example.com'
)
# PrintingJobViewSet 默认做 merchant 隔离;本测试集不关注该隔离逻辑,
# 设为 superuser 以避免因测试数据未设置 merchant 导致的 404/列表为空。
self.user.is_superuser = True
self.user.save(update_fields=['is_superuser'])
# 创建员工并关联商户
self.employee = basic_models.Employee.objects.create(
@@ -257,6 +261,36 @@ class PrintingJobAPITestCase(TestCase):
self.assertEqual(job.quantity, 200)
self.assertEqual(job.unit, '')
self.assertEqual(job.pieces, 20)
def test_cannot_change_printing_order_on_update(self):
"""测试:不允许通过更新接口修改 PrintingJob.printing_order"""
job = printing_models.PrintingJob.objects.create(
printing_order=self.printing_order,
product=self.product,
quantity=100,
unit='',
)
other_order = printing_models.PrintingOrder.objects.create(
customer=self.customer,
fabric='其他布料',
width='160cm',
)
update_data = {
'printing_order': other_order.id, # 尝试变更绑定关系
'product': self.product.id,
'quantity': 200,
'unit': '',
}
response = self.client.put(
f'/api/v1/printing-jobs/{job.id}/',
update_data,
format='json'
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertIn('printing_order', response.data)
def test_partial_update_printing_job(self):
"""测试部分更新款式明细"""