Skip to content

Commit

Permalink
Added stub for "get_all_users" user service.
Browse files Browse the repository at this point in the history
This is for SGA issue 115:

[issue 115](mitodl/edx-sga#115)
  • Loading branch information
ShawnMilo committed Aug 27, 2015
1 parent f0f0c09 commit 1846855
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions xblock/reference/user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ def get_current_user(self):
"""
raise NotImplementedError()

def get_all_users(self, **kwargs):
"""
This is default, example implementation. Anything real needs to override
This is expected to return a list instance of XBlockUser instances.
**kwargs is intended to be used for filtering options, such as by course.
"""
raise NotImplementedError()


class XBlockUser(object):
"""
Expand Down
14 changes: 14 additions & 0 deletions xblock/test/test_user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ def __init__(self, user):
def get_current_user(self):
return self.user

def get_all_users(self):
return [self.user]


def test_dummy_user_service_current_user():
"""
Expand All @@ -34,6 +37,17 @@ def test_dummy_user_service_current_user():
assert_is_instance(current_user.opt_attrs, collections.Mapping)


def test_dummy_user_service_all_users():
"""
Tests that get_all_users() works on a dummy user service.
"""
user = XBlockUser(full_name="tester")
user_service = SingleUserService(user)
all_users = user_service.get_all_users()
assert_is_instance(all_users, list)
assert_equals(user, all_users[0])


def test_dummy_user_service_exception():
"""
Tests NotImplemented error raised by UserService when not instantiated with kwarg get_current_user
Expand Down

0 comments on commit 1846855

Please sign in to comment.