Skip to content

Commit

Permalink
Add tests for contest curators
Browse files Browse the repository at this point in the history
  • Loading branch information
kiritofeng committed May 6, 2021
1 parent 7c49d4d commit 88288d3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
33 changes: 33 additions & 0 deletions judge/models/tests/test_contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def setUpTestData(self):
'normal_before_window': create_user(
username='normal_before_window',
),
'non_staff_author': create_user(
username='non_staff_author',
is_staff=False,
),
})

_now = timezone.now()
Expand All @@ -59,6 +63,16 @@ def setUpTestData(self):
''',
)

self.hidden_scoreboard_non_staff_author = create_contest(
key='non_staff_author',
start_time=_now - timezone.timedelta(days=1),
end_time=_now + timezone.timedelta(days=100),
is_visible=True,
scoreboard_visibility=Contest.SCOREBOARD_AFTER_CONTEST,
authors=('non_staff_author',),
curators=('staff_contest_edit_own',),
)

self.contest_hidden_scoreboard_contest = create_contest(
key='contest_scoreboard',
start_time=_now - timezone.timedelta(days=10),
Expand Down Expand Up @@ -275,6 +289,25 @@ def test_hidden_scoreboard_contest_methods(self):
}
self._test_object_methods_with_users(self.hidden_scoreboard_contest, data)

def test_contest_hidden_scoreboard_non_staff_author_contest_methods(self):
data = {
'staff_contest_edit_own': {
'can_see_own_scoreboard': self.assertTrue,
'can_see_full_scoreboard': self.assertTrue,
'is_accessible_by': self.assertTrue,
'is_editable_by': self.assertTrue,
'is_in_contest': self.assertFalse,
},
'non_staff_author': {
'can_see_own_scoreboard': self.assertTrue,
'can_see_full_scoreboard': self.assertTrue,
'is_accessible_by': self.assertTrue,
'is_editable_by': self.assertFalse,
'is_in_contest': self.assertFalse,
},
}
self._test_object_methods_with_users(self.hidden_scoreboard_non_staff_author, data)

def test_contest_hidden_scoreboard_contest_methods(self):
data = {
'normal_before_window': {
Expand Down
2 changes: 2 additions & 0 deletions judge/models/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ class CreateContest(CreateModel):
model = Contest
m2m_fields = {
'authors': (Profile, 'user__username'),
'curators': (Profile, 'user__username'),
'testers': (Profile, 'user__username'),
'problems': (Problem, 'code'),
'view_contest_scoreboard': (Profile, 'user__username'),
'rate_exclude': (Profile, 'user__username'),
Expand Down

0 comments on commit 88288d3

Please # to comment.