def test_fail_missing_source_with_language(self): # We allow submissions with missing files, as long as we can identify # the language. self.assertFalse(add_submission( self.contest.id, self.user.username, self.task.name, _TS, {"source2": self.get_path(_FILENAME_2)})) self.assertSubmissionNotInDb(_TS)
def test_fail_language_only_in_one(self): self.assertFalse(add_submission( self.contest.id, self.user.username, self.task.name, _TS, { "source1.%l": self.get_path(_FILENAME_1), "source2.%l": self.get_path(_FILENAME_2), })) self.assertSubmissionNotInDb(_TS)
def test_fail_no_language_inferrable_missing_extension(self): # Task requires a language, but the file we provide does not have # an extension defining the language. self.assertFalse(add_submission( self.contest.id, self.user.username, self.task.name, _TS, {"source.%l": self.get_path(_FILENAME_2)})) self.assertSubmissionNotInDb(_TS)
def test_fail_no_language_inferrable_missing_source(self): # Task requires a language, but we don't provide any file that # indicate it. self.assertFalse( add_submission(self.contest.id, self.user.username, self.task.name, _TS, {})) self.assertSubmissionNotInDb(_TS)
def test_fail_no_language_inferrable_missing_extension(self): # Task requires a language, but the file we provide does not have # an extension defining the language. self.assertFalse( add_submission(self.contest.id, self.user.username, self.task.name, _TS, {"source.%l": self.get_path(_FILENAME_2)})) self.assertSubmissionNotInDb(_TS)
def test_fail_file_not_found(self): # We provide a path, but the file does not exist. self.assertFalse( add_submission( self.contest.id, self.user.username, self.task.name, _TS, {"source.%l": self.get_path("source_not_existing.c")})) self.assertSubmissionNotInDb(_TS)
def test_fail_file_not_in_submission_format(self): # We provide a file, but for the wrong filename. self.assertFalse( add_submission(self.contest.id, self.user.username, self.task.name, _TS, {"wrong_source.%l": self.get_path(_FILENAME_1)})) self.assertSubmissionNotInDb(_TS)
def test_fail_missing_source_with_language(self): # We allow submissions with missing files, as long as we can identify # the language. self.assertFalse( add_submission(self.contest.id, self.user.username, self.task.name, _TS, {"source2": self.get_path(_FILENAME_2)})) self.assertSubmissionNotInDb(_TS)
def test_fail_inconsistent_language(self): # Language for the two files is different. self.assertFalse(add_submission( self.contest.id, self.user.username, self.task.name, _TS, { "source1.%l": self.get_path(_FILENAME_1), "source2.%l": self.get_path(_FILENAME_3), })) self.assertSubmissionNotInDb(_TS)
def test_success_missing_source_without_language(self): # We allow submissions with missing files, as long as we can identify # the language. self.assertTrue(add_submission( self.contest.id, self.user.username, self.task.name, _TS, {"source1.%l": self.get_path(_FILENAME_1)})) self.assertSubmissionInDb(_TS, self.task, _LANGUAGE_1, {"source1.%l": _DIGEST_1})
def test_success_missing_source_without_language(self): # We allow submissions with missing files, as long as we can identify # the language. self.assertTrue( add_submission(self.contest.id, self.user.username, self.task.name, _TS, {"source1.%l": self.get_path(_FILENAME_1)})) self.assertSubmissionInDb(_TS, self.task, _LANGUAGE_1, {"source1.%l": _DIGEST_1})
def test_success_many(self): self.assertTrue(add_submission( self.contest.id, self.user.username, self.task.name, _TS, { "source1.%l": self.get_path(_FILENAME_1), "source2": self.get_path(_FILENAME_2), })) self.assertSubmissionInDb(_TS, self.task, _LANGUAGE_1, { "source1.%l": _DIGEST_1, "source2": _DIGEST_2, })
def test_fail_no_contest(self): # We pass a non-existing contest id. self.assertFalse(add_submission( self.contest.id + 100, self.user.username, self.task.name, _TS, {})) self.assertSubmissionNotInDb(_TS)
def test_fail_task_not_in_contest(self): # We pass a contest that does not contain the task. self.assertFalse(add_submission( self.other_contest.id, self.user.username, self.task.name, _TS, {})) self.assertSubmissionNotInDb(_TS)
def test_fail_no_language_inferrable_missing_source(self): # Task requires a language, but we don't provide any file that # indicate it. self.assertFalse(add_submission( self.contest.id, self.user.username, self.task.name, _TS, {})) self.assertSubmissionNotInDb(_TS)
def test_fail_file_not_found(self): # We provide a path, but the file does not exist. self.assertFalse(add_submission( self.contest.id, self.user.username, self.task.name, _TS, {"source.%l": self.get_path("source_not_existing.c")})) self.assertSubmissionNotInDb(_TS)
def test_fail_task_not_in_contest(self): # We pass a contest that does not contain the task. self.assertFalse( add_submission(self.other_contest.id, self.user.username, self.task.name, _TS, {})) self.assertSubmissionNotInDb(_TS)
def test_fail_no_contest(self): # We pass a non-existing contest id. self.assertFalse( add_submission(self.contest.id + 100, self.user.username, self.task.name, _TS, {})) self.assertSubmissionNotInDb(_TS)
def test_fail_no_user(self): # We pass a non-existing username. self.assertFalse( add_submission(self.contest.id, self.user.username + "_wrong", self.task.name, _TS, {})) self.assertSubmissionNotInDb(_TS)
def test_success_no_source(self): # Here we don't provide any file, but language is not required. self.assertTrue(add_submission( self.contest.id, self.user.username, self.task.name, _TS, {})) self.assertSubmissionInDb(_TS, self.task, None, {})
def test_fail_no_user(self): # We pass a non-existing username. self.assertFalse(add_submission( self.contest.id, self.user.username + "_wrong", self.task.name, _TS, {})) self.assertSubmissionNotInDb(_TS)
def test_success_no_language(self): self.assertTrue( add_submission(self.contest.id, self.user.username, self.task.name, _TS, {"source": self.get_path(_FILENAME_2)})) self.assertSubmissionInDb(_TS, self.task, None, {"source": _DIGEST_2})
def test_fail_file_not_in_submission_format(self): # We provide a file, but for the wrong filename. self.assertFalse(add_submission( self.contest.id, self.user.username, self.task.name, _TS, {"wrong_source.%l": self.get_path(_FILENAME_1)})) self.assertSubmissionNotInDb(_TS)
def test_success_no_source(self): # Here we don't provide any file, but language is not required. self.assertTrue( add_submission(self.contest.id, self.user.username, self.task.name, _TS, {})) self.assertSubmissionInDb(_TS, self.task, None, {})
def test_success_no_language(self): self.assertTrue(add_submission( self.contest.id, self.user.username, self.task.name, _TS, {"source": self.get_path(_FILENAME_2)})) self.assertSubmissionInDb(_TS, self.task, None, {"source": _DIGEST_2})