forked from erp-dev/erp
feat: added migrate for set id init value into 8000 of plate_order
This commit is contained in:
@@ -188,6 +188,49 @@ class PlateOrderAPITestCase(TestCase):
|
||||
self.assertIn('customer_name', response.data)
|
||||
self.assertIn('salesperson_name', response.data)
|
||||
|
||||
def test_design_code_fallback_in_detail(self):
|
||||
"""design_code 为空时返回补零后的主键"""
|
||||
plate_order = printing_models.PlateOrder.objects.create(
|
||||
customer=self.customer,
|
||||
design_code='',
|
||||
plate_type='圆网',
|
||||
style_name='测试款式',
|
||||
fabric='棉布',
|
||||
)
|
||||
|
||||
response = self.client.get(f'/api/v1/plate-orders/{plate_order.id}/')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(response.data['design_code'], f'{plate_order.id:06d}')
|
||||
|
||||
def test_design_code_fallback_in_list(self):
|
||||
"""列表接口也应返回补零后的设计编号"""
|
||||
printing_models.PlateOrder.objects.create(
|
||||
customer=self.customer,
|
||||
design_code='',
|
||||
plate_type='圆网',
|
||||
style_name='款式1',
|
||||
fabric='棉布',
|
||||
)
|
||||
|
||||
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
|
||||
self.assertEqual(results[0]['design_code'], f"{results[0]['id']:06d}")
|
||||
|
||||
def test_fabric_source_field_in_detail(self):
|
||||
"""验证布料来源字段在返回中存在"""
|
||||
plate_order = printing_models.PlateOrder.objects.create(
|
||||
customer=self.customer,
|
||||
design_code='DESIGN010',
|
||||
plate_type='圆网',
|
||||
fabric='棉布',
|
||||
fabric_source='客户提供',
|
||||
)
|
||||
|
||||
response = self.client.get(f'/api/v1/plate-orders/{plate_order.id}/')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(response.data['fabric_source'], '客户提供')
|
||||
|
||||
def test_update_plate_order(self):
|
||||
"""测试更新开版订单"""
|
||||
plate_order = printing_models.PlateOrder.objects.create(
|
||||
|
||||
Reference in New Issue
Block a user