Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added stub for "get_all_users" user service. #319

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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