Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
jdabtieu committed Jan 4, 2025
1 parent 8d61dec commit 6cb3dad
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions src/tests/test_contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,13 @@ def test_contest_rejudge(client, database):
os.remove('test_upload.txt')
assert result.status_code == 302

edit_dict = {
'name': 'dynamic',
'description': 'dynamic is fun',
'category': 'web',
'file': ('fake_empty_file', ''),
}

# WA --> First AC
result = client.post('/contest/testingcontest/problem/dynamic', data={
'flag': 'ctf{wrong}'
Expand All @@ -557,12 +564,9 @@ def test_contest_rejudge(client, database):
assert b'None' in result.data

result = client.post('/contest/testingcontest/problem/dynamic/edit', data={
'name': 'dynamic',
'description': 'dynamic is fun',
'category': 'web',
**edit_dict,
'flag': 'ctf{wrong}',
'rejudge': True,
'file': ('fake_empty_file', ''),
'rejudge': True
}, follow_redirects=True)
assert result.status_code == 200
assert b'successfully' in result.data
Expand All @@ -577,11 +581,8 @@ def test_contest_rejudge(client, database):

# Without rejudge
result = client.post('/contest/testingcontest/problem/dynamic/edit', data={
'name': 'dynamic',
'description': 'dynamic is fun',
'category': 'web',
'flag': 'ctf{verywrong}',
'file': ('fake_empty_file', ''),
**edit_dict,
'flag': 'ctf{verywrong}'
}, follow_redirects=True)
assert result.status_code == 200

Expand All @@ -591,12 +592,9 @@ def test_contest_rejudge(client, database):

# First AC --> WA
result = client.post('/contest/testingcontest/problem/dynamic/edit', data={
'name': 'dynamic',
'description': 'dynamic is fun',
'category': 'web',
**edit_dict,
'flag': 'ctf{hello}',
'rejudge': True,
'file': ('fake_empty_file', ''),
'rejudge': True
}, follow_redirects=True)
assert result.status_code == 200
assert b'successfully' in result.data
Expand All @@ -616,12 +614,9 @@ def test_contest_rejudge(client, database):
assert b'None' not in result2.data

result = client.post('/contest/testingcontest/problem/dynamic/edit', data={
'name': 'dynamic',
'description': 'dynamic is fun',
'category': 'web',
**edit_dict,
'flag': 'ctf{wrong}',
'rejudge': True,
'file': ('fake_empty_file', ''),
'rejudge': True
}, follow_redirects=True)
assert result.status_code == 200
assert b'successfully' in result.data
Expand All @@ -631,6 +626,21 @@ def test_contest_rejudge(client, database):
assert b'None' not in result.data
assert result.data[result.data.index(b'table'):].replace(b'458', b'1') == result2.data[result2.data.index(b'table'):] # Check points and last AC

client.post('/contest/testingcontest/problem/dynamic/edit', data={
**edit_dict,
'flag': 'ctf{different}',
'rejudge': True
}, follow_redirects=True)
result = client.post('/contest/testingcontest/problem/dynamic', data={
'flag': 'ctf{different}'
}, follow_redirects=True)
assert result.status_code == 200
assert b'Congratulations' in result.data

result = client.get('/contest/testingcontest/scoreboard')
assert b'None' not in result.data
assert result.data[result.data.index(b'table'):].replace(b'458', b'1') == result2.data[result2.data.index(b'table'):] # Check points and last AC

result = client.post('/contest/testingcontest/problem/static/edit', data={
'name': 'static',
'description': 'static is fun',
Expand Down

0 comments on commit 6cb3dad

Please sign in to comment.