Skip to content

Commit

Permalink
Userlist test
Browse files Browse the repository at this point in the history
  • Loading branch information
loleg committed Mar 27, 2024
1 parent 7706e98 commit a6b9a5a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 12 additions & 4 deletions dribdat/public/api.py
Expand Up @@ -272,15 +272,23 @@ def project_info_json(project_id):
# ------ USERS ----------


def get_users_for_event(event=None):
if event is None: return []
userlist = []
for u in GetEventUsers(event):
# with_challenges=True, limit=-1, event=None
udata = u.data
udata['teams'] = u.joined_projects(True, -1, event)
userlist.append(udata)
return userlist


@blueprint.route('/event/<int:event_id>/participants.csv')
@admin_required
def event_participants_csv(event_id):
"""Download a CSV of event participants."""
event = Event.query.filter_by(id=event_id).first_or_404()
userlist = []
for u in GetEventUsers(event):
u['teams'] = u.joined_projects(True, -1, event)
userlist.append(u)
userlist = get_users_for_event(event)

Check warning on line 291 in dribdat/public/api.py

View check run for this annotation

Codecov / codecov/patch

dribdat/public/api.py#L291

Added line #L291 was not covered by tests
headers = {
'Content-Disposition': 'attachment; '
+ 'filename=user_list_%d.csv' % event.id
Expand Down
6 changes: 6 additions & 0 deletions tests/test_api.py
Expand Up @@ -60,6 +60,12 @@ def test_get_event_data(self, testapp):
ProjectActivity(project, 'star', user2)
assert project in user1.joined_projects()
assert project not in user1.joined_projects(False) # no challenges

# Test event API
userlist = get_users_for_event(event)
assert user1.username in [ u['username'] for u in userlist ]
assert user2.username in [ u['username'] for u in userlist ]


def test_get_platform_data(self):
"""More global data types."""
Expand Down

0 comments on commit a6b9a5a

Please sign in to comment.