def test_6_fail_create_huge_submission(self):
        self.assertTrue(len(SubmissionTest.context_used["context_gus"]) > 1)

        submission_request = dict(
            helpers.get_dummy_submission(
                SubmissionTest.context_used["context_gus"], SubmissionTest.context_used["fields"]
            )
        )

        submission_request["receivers"] = [SubmissionTest.receiver_used["receiver_gus"]]
        submission_request["context_gus"] = SubmissionTest.context_used["context_gus"]

        for key in submission_request["wb_fields"].keys():
            submission_request["wb_fields"][key] = unicode("You know nothing John Snow" * 100 * 100)

        submission_request["finalize"] = True

        try:
            r = yield submission.create_submission(submission_request, finalize=True)
            self.assertTrue(False)
        except InvalidInputFormat:
            self.assertTrue(True)
        except GLException, e:
            log.debug("GLException %s %s" % (str(e), e.reason))
            self.assertTrue(False)
Example #2
0
    def test_fields_fail_missing_required(self):

        required_key = self.dummyContext["fields"][0]["key"]
        sbmt = helpers.get_dummy_submission(self.dummySubmission["context_gus"], self.dummyContext["fields"])
        del sbmt["wb_fields"][required_key]

        try:
            yield submission.create_submission(sbmt, finalize=True)
            self.assertTrue(False)
        except Exception as excep:
            self.assertTrue(excep.reason.startswith("Submission do not validate the input fields [Missing field"))
Example #3
0
    def test_fields_fail_unexpected_presence(self):

        sbmt = helpers.get_dummy_submission(self.dummySubmission["context_gus"], self.dummyContext["fields"])
        sbmt["wb_fields"].update({"alien": "predator"})

        try:
            yield submission.create_submission(sbmt, finalize=True)
            self.assertTrue(False)
        except Exception as excep:
            self.assertEqual(
                excep.reason,
                "Submission do not validate the input fields [Submitted field 'alien' not expected in context]",
            )
    def test_2_create_submission_missing_receiver(self):
        self.assertTrue(len(SubmissionTest.context_used["context_gus"]) > 1)

        submission_request = dict(
            helpers.get_dummy_submission(
                SubmissionTest.context_used["context_gus"], SubmissionTest.context_used["fields"]
            )
        )
        submission_request["finalize"] = True

        try:
            r = yield submission.create_submission(submission_request, finalize=True)
            log.debug("Unexpected Success in creation: %s" % str(r))
            self.assertTrue(False)
        except GLException, e:
            log.debug("GLException %s %s" % (str(e), e.message))
            self.assertEqual(e.error_code, 22)  # SubmissionFailFields
    def test_5_create_valid_submission(self):
        self.assertTrue(len(SubmissionTest.context_used["context_gus"]) > 1)

        submission_request = dict(
            helpers.get_dummy_submission(
                SubmissionTest.context_used["context_gus"], SubmissionTest.context_used["fields"]
            )
        )

        submission_request["receivers"] = [SubmissionTest.receiver_used["receiver_gus"]]
        submission_request["finalize"] = True

        try:
            r = yield submission.create_submission(submission_request, finalize=True)
            log.debug("Success in creation: %s" % str(r))
            self.assertTrue(True)
        except GLException, e:
            log.debug("GLException %s %s" % (str(e), e.reason))
            self.assertTrue(False)