Пример #1
0
 def test_success_submission(self):
     foo_digest = unique_digest()
     baz_digest = unique_digest()
     self.insert_submission("C",
                            {"foo.%l": foo_digest, "baz.txt": baz_digest})
     self.assertEqual(self.call(C_LANG, {"foo.%l", "bar.txt"}),
                      {"foo.%l": foo_digest})
Пример #2
0
 def test_language_agnostic(self):
     foo_digest = unique_digest()
     baz_digest = unique_digest()
     self.insert_submission(None,
                            {"foo.txt": foo_digest, "baz": baz_digest})
     self.assertEqual(self.call(None, {"foo.txt", "bar.zip"}),
                      {"foo.txt": foo_digest})
Пример #3
0
 def test_previous_submission_wrong_language(self):
     foo_digest = unique_digest()
     baz_digest = unique_digest()
     self.insert_submission("Py2",
                            {"foo.%l": foo_digest, "baz.txt": baz_digest})
     self.assertEqual(self.call(C_LANG, {"foo.%l", "bar.txt"}),
                      dict())
Пример #4
0
 def test_managers_can_use_only_primary_extension(self):
     input_digest = unique_digest()
     foo_digest = unique_digest()
     bar_digest = unique_digest()
     self.insert_user_test("C++", input_digest, dict(),
                           {"foo.cpp": foo_digest, "bar.cc": bar_digest})
     self.assertEqual(self.call(CPP_LANG, {"foo.%l", "bar.%l"},
                                cls=UserTest),
                      {"foo.%l": foo_digest})
Пример #5
0
 def add_testcase(self, dataset=None, **kwargs):
     """Add a testcase."""
     dataset = dataset if dataset is not None else self.add_dataset()
     args = {
         "dataset": dataset,
         "codename": unique_unicode_id(),
         "input": unique_digest(),
         "output": unique_digest(),
     }
     args.update(kwargs)
     testcase = Testcase(**args)
     self.session.add(testcase)
     return testcase
Пример #6
0
 def add_testcase(self, dataset=None, **kwargs):
     """Add a testcase."""
     dataset = dataset if dataset is not None else self.add_dataset()
     args = {
         "dataset": dataset,
         "codename": unique_unicode_id(),
         "input": unique_digest(),
         "output": unique_digest(),
     }
     args.update(kwargs)
     testcase = Testcase(**args)
     self.session.add(testcase)
     return testcase
Пример #7
0
 def test_previous_user_test_wrong_language(self):
     foo_digest = unique_digest()
     baz_digest = unique_digest()
     input_digest = unique_digest()
     spam_digest = unique_digest()
     eggs_digest = unique_digest()
     self.insert_user_test("Py2", input_digest,
                           {"foo.%l": foo_digest, "baz.txt": baz_digest},
                           {"spam.c": spam_digest, "eggs.h": eggs_digest})
     self.assertEqual(self.call(C_LANG, {"input",
                                           "foo.%l", "bar.txt",
                                           "spam.%l", "ham"},
                                cls=UserTest),
                      dict())
Пример #8
0
 def test_managers_extension_replacement(self):
     input_digest = unique_digest()
     foo_digest = unique_digest()
     bad_digest = unique_digest()
     # The *full* `.%l` of the codename has to be replaced with the
     # language's primary extension, including the `.`, even when the
     # extension doesn't begin with `.`. This also means that
     # splitting the filename to get the extension out of is most
     # likely a bad approach.
     self.insert_user_test("Pascal", input_digest, dict(),
                           {"foolib.pas": foo_digest,
                            "foo.lib.pas": bad_digest,
                            "foo.pas": bad_digest})
     self.assertEqual(self.call(PASCAL_LANG, {"foo.%l"}, cls=UserTest),
                      {"foo.%l": foo_digest})
Пример #9
0
 def test_success_user_test(self):
     input_digest = unique_digest()
     foo_digest = unique_digest()
     baz_digest = unique_digest()
     spam_digest = unique_digest()
     eggs_digest = unique_digest()
     self.insert_user_test("C", input_digest,
                           {"foo.%l": foo_digest, "baz.txt": baz_digest},
                           {"spam.c": spam_digest, "eggs.h": eggs_digest})
     self.assertEqual(self.call(C_LANG, {"input",
                                         "foo.%l", "bar.txt",
                                         "spam.%l", "ham"},
                                cls=UserTest),
                      {"input": input_digest,
                       "foo.%l": foo_digest,
                       "spam.%l": spam_digest})
Пример #10
0
 def get_manager(cls, dataset=None, **kwargs):
     """Create a manager."""
     dataset = dataset if dataset is not None else cls.get_dataset()
     args = {
         "dataset": dataset,
         "filename": unique_unicode_id(),
         "digest": unique_digest(),
     }
     args.update(kwargs)
     manager = Manager(**args)
     return manager
Пример #11
0
 def get_manager(cls, dataset=None, **kwargs):
     """Create a manager."""
     dataset = dataset if dataset is not None else cls.get_dataset()
     args = {
         "dataset": dataset,
         "filename": unique_unicode_id(),
         "digest": unique_digest(),
     }
     args.update(kwargs)
     manager = Manager(**args)
     return manager
Пример #12
0
 def add_statement(self, task=None, **kwargs):
     """Create a statement and add it to the session"""
     task = task if task is not None else self.add_task()
     args = {
         "task": task,
         "digest": unique_digest(),
         "language": unique_unicode_id(),
     }
     args.update(kwargs)
     statement = Statement(**args)
     self.session.add(statement)
     return statement
Пример #13
0
 def get_manager(dataset=None, **kwargs):
     """Create a manager."""
     if dataset is None:
         dataset = DatabaseMixin.get_dataset()
     args = {
         "dataset": dataset,
         "filename": unique_unicode_id(),
         "digest": unique_digest(),
     }
     args.update(kwargs)
     manager = Manager(**args)
     return manager
Пример #14
0
 def add_statement(self, task=None, **kwargs):
     """Create a statement and add it to the session"""
     task = task if task is not None else self.add_task()
     args = {
         "task": task,
         "digest": unique_digest(),
         "language": unique_unicode_id(),
     }
     args.update(kwargs)
     statement = Statement(**args)
     self.session.add(statement)
     return statement
Пример #15
0
 def add_file(self, submission=None, **kwargs):
     """Create a file and add it to the session"""
     if submission is None:
         submission = self.add_sbubmission()
     args = {
         "submission": submission,
         "filename": unique_unicode_id(),
         "digest": unique_digest(),
     }
     args.update(kwargs)
     file = File(**args)
     self.session.add(file)
     return file
Пример #16
0
 def add_user_test_manager(self, user_test=None, **kwargs):
     """Create a user test manager and add it to the session"""
     if user_test is None:
         user_test = self.add_user_test()
     args = {
         "user_test": user_test,
         "filename": unique_unicode_id(),
         "digest": unique_digest(),
     }
     args.update(kwargs)
     user_test_manager = UserTestManager(**args)
     self.session.add(user_test_manager)
     return user_test_manager
Пример #17
0
 def add_user_test_manager(self, user_test=None, **kwargs):
     """Create a user test manager and add it to the session"""
     if user_test is None:
         user_test = self.add_user_test()
     args = {
         "user_test": user_test,
         "filename": unique_unicode_id(),
         "digest": unique_digest(),
     }
     args.update(kwargs)
     user_test_manager = UserTestManager(**args)
     self.session.add(user_test_manager)
     return user_test_manager
Пример #18
0
 def add_file(self, submission=None, **kwargs):
     """Create a file and add it to the session"""
     if submission is None:
         submission = self.add_submission()
     args = {
         "submission": submission,
         "filename": unique_unicode_id(),
         "digest": unique_digest(),
     }
     args.update(kwargs)
     file_ = File(**args)
     self.session.add(file_)
     return file_
Пример #19
0
 def add_executable(self, submission_result=None, **kwargs):
     """Create an executable and add it to the session"""
     submission_result = submission_result \
         if submission_result is not None \
         else self.add_submission_result()
     args = {
         "submission_result": submission_result,
         "digest": unique_digest(),
         "filename": unique_unicode_id(),
     }
     args.update(kwargs)
     executable = Executable(**args)
     self.session.add(executable)
     return executable
Пример #20
0
 def add_executable(self, submission_result=None, **kwargs):
     """Create an executable and add it to the session"""
     submission_result = submission_result \
         if submission_result is not None \
         else self.add_submission_result()
     args = {
         "submission_result": submission_result,
         "digest": unique_digest(),
         "filename": unique_unicode_id(),
     }
     args.update(kwargs)
     executable = Executable(**args)
     self.session.add(executable)
     return executable
Пример #21
0
 def add_user_test(self, task=None, participation=None, **kwargs):
     """Add a user test."""
     task = task if task is not None else self.add_task()
     participation = participation \
         if participation is not None \
         else self.add_participation(contest=task.contest)
     assert task.contest == participation.contest
     args = {
         "task": task,
         "participation": participation,
         "input": unique_digest(),
         "timestamp": (task.contest.start + timedelta(0, unique_long_id())),
     }
     args.update(kwargs)
     user_test = UserTest(**args)
     self.session.add(user_test)
     return user_test