forked from erp-dev/erp
feat: log formatted
This commit is contained in:
@@ -114,12 +114,14 @@ class PrintingJobAPITestCase(TestCase):
|
||||
'unit': '米',
|
||||
'size': '50*60',
|
||||
'pieces': 10,
|
||||
'sub_id': 7,
|
||||
'description': '测试备注'
|
||||
}
|
||||
|
||||
response = self.client.post('/api/v1/printing-jobs/', data, format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||
self.assertEqual(response.data['external_order_id'], 'KD20410611')
|
||||
self.assertEqual(response.data['sub_id'], 7)
|
||||
|
||||
# 新增字段:批量推进记录(稳定输出 key,默认空数组)
|
||||
self.assertIn('batch_advance_records', response.data)
|
||||
@@ -135,6 +137,7 @@ class PrintingJobAPITestCase(TestCase):
|
||||
self.assertEqual(job.quantity, 100)
|
||||
self.assertEqual(job.unit, '米')
|
||||
self.assertEqual(job.pieces, 10)
|
||||
self.assertEqual(job.sub_id, 7)
|
||||
self.assertFalse(job.is_production_completed)
|
||||
|
||||
def test_create_printing_job_ignores_is_production_completed(self):
|
||||
@@ -162,7 +165,8 @@ class PrintingJobAPITestCase(TestCase):
|
||||
quantity=100,
|
||||
unit='米',
|
||||
size='50*60',
|
||||
pieces=10
|
||||
pieces=10,
|
||||
sub_id=101
|
||||
)
|
||||
job2 = printing_models.PrintingJob.objects.create(
|
||||
printing_order=self.printing_order,
|
||||
@@ -170,12 +174,16 @@ class PrintingJobAPITestCase(TestCase):
|
||||
quantity=200,
|
||||
unit='米',
|
||||
size='60*70',
|
||||
pieces=20
|
||||
pieces=20,
|
||||
sub_id=202
|
||||
)
|
||||
|
||||
response = self.client.get('/api/v1/printing-jobs/')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(response.data['count'], 2)
|
||||
sub_ids_by_id = {item['id']: item['sub_id'] for item in response.data['results']}
|
||||
self.assertEqual(sub_ids_by_id[job1.id], 101)
|
||||
self.assertEqual(sub_ids_by_id[job2.id], 202)
|
||||
|
||||
# 新增字段:批量推进记录(稳定输出 key)
|
||||
for item in response.data['results']:
|
||||
@@ -640,6 +648,7 @@ class PrintingJobAPITestCase(TestCase):
|
||||
'unit': '码',
|
||||
'size': '60*70',
|
||||
'pieces': 20,
|
||||
'sub_id': 8,
|
||||
'description': '更新后的备注'
|
||||
}
|
||||
|
||||
@@ -650,11 +659,13 @@ class PrintingJobAPITestCase(TestCase):
|
||||
)
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(response.data['external_order_id'], 'KD20410611')
|
||||
self.assertEqual(response.data['sub_id'], 8)
|
||||
|
||||
job.refresh_from_db()
|
||||
self.assertEqual(job.quantity, 200)
|
||||
self.assertEqual(job.unit, '码')
|
||||
self.assertEqual(job.pieces, 20)
|
||||
self.assertEqual(job.sub_id, 8)
|
||||
self.assertFalse(job.is_production_completed)
|
||||
|
||||
def test_update_printing_job_ignores_is_production_completed(self):
|
||||
@@ -724,7 +735,8 @@ class PrintingJobAPITestCase(TestCase):
|
||||
|
||||
patch_data = {
|
||||
'quantity': 150,
|
||||
'pieces': 15
|
||||
'pieces': 15,
|
||||
'sub_id': None
|
||||
}
|
||||
|
||||
response = self.client.patch(
|
||||
@@ -734,10 +746,12 @@ class PrintingJobAPITestCase(TestCase):
|
||||
)
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(response.data['external_order_id'], 'KD20410611')
|
||||
self.assertIsNone(response.data['sub_id'])
|
||||
|
||||
job.refresh_from_db()
|
||||
self.assertEqual(job.quantity, 150)
|
||||
self.assertEqual(job.pieces, 15)
|
||||
self.assertIsNone(job.sub_id)
|
||||
self.assertEqual(job.unit, '米') # 未修改字段保持不变
|
||||
|
||||
def test_delete_printing_job_forbidden(self):
|
||||
|
||||
Reference in New Issue
Block a user