Пример #1
0
 def test_update_package_locations(self, mock_ona_form_def, mock_ona_form_submissions):
     self.assertFalse(FormSubmission.objects.all())
     # The test DATA fixture already contains the form def json
     submission = json.loads(PACKAGE_DATA)
     mock_ona_form_def.return_value = submission['form_definition']
     mock_ona_form_submissions.return_value = [submission]
     process_new_package_scans.run()
     self.assertEqual(1, FormSubmission.objects.count())
     # Only add the record once
     process_new_package_scans.run()
     self.assertEqual(1, FormSubmission.objects.count())
Пример #2
0
 def test_update_package_locations(self, mock_ona_form_def,
                                   mock_ona_form_submissions):
     self.assertFalse(FormSubmission.objects.all())
     # The test DATA fixture already contains the form def json
     submission = json.loads(PACKAGE_DATA)
     mock_ona_form_def.return_value = submission['form_definition']
     mock_ona_form_submissions.return_value = [submission]
     process_new_package_scans.run()
     self.assertEqual(1, FormSubmission.objects.count())
     # Only add the record once
     process_new_package_scans.run()
     self.assertEqual(1, FormSubmission.objects.count())
Пример #3
0
 def test_update_package_multiple_locations(self, mock_ona_form_def, mock_ona_form_submissions):
     PackageFactory(code=QR_CODE)
     self.assertFalse(FormSubmission.objects.all())
     # The test DATA fixture already contains the form def json
     submission = json.loads(PACKAGE_DATA)
     other_submission = deepcopy(submission)
     other_submission.update(
         _uuid="2a11435f-8eaf-44f9-bd75-00a4bac8fbce",
         current_location="STATUS_RECEIVED",
         _submission_time="2014-07-25T17:19:16",
     )
     mock_ona_form_def.return_value = submission['form_definition']
     mock_ona_form_submissions.return_value = [submission, other_submission]
     process_new_package_scans.run()
     self.assertEqual(2, FormSubmission.objects.count())
     loc = PackageScan.objects.all().order_by('when')[0]
     self.assertEqual(loc.status_label, 'English Zero_Point')
     self.assertEqual(loc.package.status, Shipment.STATUS_RECEIVED)
     self.assertEqual(loc.package.shipment.status, Shipment.STATUS_RECEIVED)
     loc = PackageScan.objects.all().order_by('when')[1]
     self.assertEqual(loc.status_label, 'English Received')
     self.assertEqual(loc.package.status, Shipment.STATUS_RECEIVED)
     self.assertEqual(loc.package.shipment.status, Shipment.STATUS_RECEIVED)
Пример #4
0
 def test_update_package_multiple_locations(self, mock_ona_form_def,
                                            mock_ona_form_submissions):
     PackageFactory(code=QR_CODE)
     self.assertFalse(FormSubmission.objects.all())
     # The test DATA fixture already contains the form def json
     submission = json.loads(PACKAGE_DATA)
     other_submission = deepcopy(submission)
     other_submission.update(
         _uuid="2a11435f-8eaf-44f9-bd75-00a4bac8fbce",
         current_location="STATUS_RECEIVED",
         _submission_time="2014-07-25T17:19:16",
     )
     mock_ona_form_def.return_value = submission['form_definition']
     mock_ona_form_submissions.return_value = [submission, other_submission]
     process_new_package_scans.run()
     self.assertEqual(2, FormSubmission.objects.count())
     loc = PackageScan.objects.all().order_by('when')[0]
     self.assertEqual(loc.status_label, 'English Zero_Point')
     self.assertEqual(loc.package.status, Shipment.STATUS_RECEIVED)
     self.assertEqual(loc.package.shipment.status, Shipment.STATUS_RECEIVED)
     loc = PackageScan.objects.all().order_by('when')[1]
     self.assertEqual(loc.status_label, 'English Received')
     self.assertEqual(loc.package.status, Shipment.STATUS_RECEIVED)
     self.assertEqual(loc.package.shipment.status, Shipment.STATUS_RECEIVED)
Пример #5
0
 def test_bad_form_id(self, mock_logger, mock_ona_form_def, mock_ona_form_submissions):
     mock_ona_form_def.return_value = None
     process_new_package_scans.run()
     self.assertIn(settings.ONA_PACKAGE_FORM_ID, bad_form_ids)
     self.assertTrue(mock_logger.error.called)
Пример #6
0
 def test_bad_form_id(self, mock_logger, mock_ona_form_def,
                      mock_ona_form_submissions):
     mock_ona_form_def.return_value = None
     process_new_package_scans.run()
     self.assertIn(settings.ONA_PACKAGE_FORM_ID, bad_form_ids)
     self.assertTrue(mock_logger.error.called)