Skip to content

Commit

Permalink
fix functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
underscore-j committed Sep 13, 2024
1 parent 26e0000 commit b17584f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cms/grading/scoretypes/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ def __init__(self, parameters, public_testcases):
if hasattr(self, "score_column_headers"):
self.public_score_header, self.private_score_header = \
self.score_column_headers()
else:
# HTML templates require these to be set; otherwise, the server crashes.
# As we only ever use SubtaskGroup, it is not clear whether this makes sense:
self.public_score_header = "Sample Score"
self.private_score_header = "Actual Score"
except Exception as e:
raise ValueError(
"Unable to instantiate score type (probably due to invalid "
Expand Down
4 changes: 3 additions & 1 deletion cmstestsuite/RunFunctionalTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ def main():
write_test_case_list(
[(test, lang) for test, lang, _ in failures],
FAILED_TEST_FILENAME)
except TestException:
except TestException as e:
print("\n\n===== FAILURE =====")
print(e)
if os.path.exists("./log/cms/last.log"):
print("\n\n===== START OF LOG DUMP =====\n\n")
with open("./log/cms/last.log", "rt", encoding="utf-8") as f:
Expand Down
16 changes: 16 additions & 0 deletions cmstestsuite/functionaltestframework.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ def add_contest(self, **kwargs):
page)
if match is not None:
contest_id = int(match.groups()[0])

#Query for group ID of the 'default' group
r = self.admin_req('contest/%s/users' % contest_id)
g = re.search(r'<select name="group_id">\s+<option value="null" selected>Select a group</option>\s+<option value="([0-9]+)">\s+default\s+</option>\s+</select>', r.text)
if g:
kwargs["main_group_id"] = int(g.group(1))
else:
raise TestException("Unable to find any group.")
self.admin_req('contest/%s' % contest_id, args=kwargs)
return contest_id
else:
Expand Down Expand Up @@ -288,6 +296,14 @@ def add_user(self, **kwargs):
else:
raise TestException("Unable to create user.")

#Query for group ID of the 'default' group
r = self.admin_req('contest/%s/users' % kwargs["contest_id"])
g = re.search(r'<select name="group_id">\s+<option value="null" selected>Select a group</option>\s+<option value="([0-9]+)">\s+default\s+</option>\s+</select>', r.text)
if g:
kwargs["group_id"] = int(g.group(1))
else:
raise TestException("Unable to find any group.")

kwargs["user_id"] = user_id
r = self.admin_req('contest/%s/users/add' % kwargs["contest_id"],
args=kwargs)
Expand Down

0 comments on commit b17584f

Please sign in to comment.