def test_process_submission_message_succesfully(
        self, mock_rs, mock_basename
    ):
        message = {
            "challenge_pk": self.challenge.pk,
            "phase_pk": self.challenge_phase.pk,
            "submission_pk": self.submission.pk,
        }
        user_annotation_file_path = (
            "mocked/dir/submission_{}/user_annotation_file.txt".format(
                self.submission.pk
            )
        )

        with mock.patch(
            "scripts.workers.submission_worker.extract_submission_data"
        ) as mock_esd:
            submission_worker.process_submission_message(message)
            mock_esd.assert_called_with(self.submission.pk)

        submission_worker.process_submission_message(message)

        mock_rs.assert_called_with(
            self.challenge.pk,
            self.challenge_phase,
            self.submission,
            user_annotation_file_path,
        )
Esempio n. 2
0
    def test_process_submission_message_when_submission_does_not_exist(
            self, mock_esd):
        message = {
            "challenge_pk": self.challenge.pk,
            "phase_pk": self.challenge_phase.pk,
            "submission_pk": self.submission.pk
        }
        mock_esd.return_value = None

        submission_worker.process_submission_message(message)

        self.assertEqual(submission_worker.process_submission_message(message),
                         None)
Esempio n. 3
0
    def test_process_submission_message_when_challenge_phase_does_not_exist(
            self, mock_logger, mock_esd):
        message = {
            "challenge_pk": self.challenge.pk,
            "phase_pk": self.challenge_phase.pk + 999,
            "submission_pk": self.submission.pk
        }
        mock_esd.return_value = self.submission
        phase_pk = self.challenge_phase.pk + 999
        with self.assertRaises(Exception):
            submission_worker.process_submission_message(message)

        mock_logger.assert_called_with(
            "Challenge Phase {} does not exist".format(phase_pk))