forked from erp-dev/erp
feat: added pre sales order and pre purchase order models and crud
This commit is contained in:
@@ -1542,6 +1542,13 @@ class PrintingJobWorkStateAPITestCase(TestCase):
|
||||
|
||||
job_id = resp.data['id']
|
||||
detail = self.client.get(f'/api/v1/printing-jobs/{job_id}/')
|
||||
# 客户可见性过滤:customer 未绑定 created_by/visible_employees 时,任务对该员工不可见 => 404
|
||||
self.assertEqual(detail.status_code, status.HTTP_404_NOT_FOUND)
|
||||
|
||||
# 将客户显式授权给当前 employee 后应可见 => 200
|
||||
self.customer.created_by = self.employee
|
||||
self.customer.save(update_fields=['created_by'])
|
||||
detail = self.client.get(f'/api/v1/printing-jobs/{job_id}/')
|
||||
self.assertEqual(detail.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(detail.data['work_state_display'], '待送货')
|
||||
|
||||
@@ -1558,10 +1565,29 @@ class PrintingJobWorkStateAPITestCase(TestCase):
|
||||
{'work_state': printing_models.PrintingJobWorkStateEnum.FINISHED},
|
||||
format='json',
|
||||
)
|
||||
# merchant 隔离:job.merchant 为空时,不属于当前员工商户 => 404
|
||||
self.assertEqual(patch_resp.status_code, status.HTTP_404_NOT_FOUND)
|
||||
|
||||
# 创建一个显式属于当前商户的 job,并让 customer 对 employee 可见后应可更新/可查询
|
||||
self.customer.created_by = self.employee
|
||||
self.customer.save(update_fields=['created_by'])
|
||||
visible_job = printing_models.PrintingJob.objects.create(
|
||||
merchant=self.merchant,
|
||||
printing_order=self.printing_order,
|
||||
product=self.product,
|
||||
quantity=5,
|
||||
unit='米',
|
||||
)
|
||||
visible_url = f'/api/v1/printing-jobs/{visible_job.id}/'
|
||||
patch_resp = self.client.patch(
|
||||
visible_url,
|
||||
{'work_state': printing_models.PrintingJobWorkStateEnum.FINISHED},
|
||||
format='json',
|
||||
)
|
||||
self.assertEqual(patch_resp.status_code, status.HTTP_200_OK)
|
||||
job.refresh_from_db()
|
||||
self.assertEqual(job.work_state, printing_models.PrintingJobWorkStateEnum.FINISHED)
|
||||
detail = self.client.get(url)
|
||||
visible_job.refresh_from_db()
|
||||
self.assertEqual(visible_job.work_state, printing_models.PrintingJobWorkStateEnum.FINISHED)
|
||||
detail = self.client.get(visible_url)
|
||||
self.assertEqual(detail.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(detail.data['work_state_display'], '已完结')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user