Skip to content

Commit

Permalink
Merge pull request #11 from eduNEXT/and/fixing_create_group
Browse files Browse the repository at this point in the history
And/fixing create group
  • Loading branch information
andrey-canon authored Apr 13, 2018
2 parents 60d6a7a + 008818b commit 72ac7c3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
7 changes: 3 additions & 4 deletions rocketc/rocketc.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ def add_to_course_group(self, group_name, user_id):
if rocket_chat_group['success']:
self._add_to_group(user_id, rocket_chat_group['group']['_id'])
else:
rocket_chat_group = self._create_group(group_name)
self._add_to_group(user_id, rocket_chat_group['group']['_id'])
rocket_chat_group = self._create_group(group_name, self.user_data["username"])

self.group = self._search_rocket_chat_group( # pylint: disable=attribute-defined-outside-init
group_name)
Expand All @@ -287,12 +286,12 @@ def _add_to_group(self, user_id, room_id):
data = {"roomId": room_id, "userId": user_id}
return self._request_rocket_chat("post", url_path, data)

def _create_group(self, name):
def _create_group(self, name, username=""):
"""
This method creates a group with a specific name.
"""
url_path = "groups.create"
data = {"name": name}
data = {"name": name, "members": [username]}
return self._request_rocket_chat("post", url_path, data)

def _request_rocket_chat(self, method, url_path, data=None):
Expand Down
8 changes: 5 additions & 3 deletions rocketc/tests/test_rocketChat.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,20 @@ def test_create_group(self, mock_request):
success = {'success': True}

name = "test_name"
username = "test_user_name"

mock_request.return_value = success
url_path = "groups.create"

data = {'name': name}
data = {'name': name, "members":[username]}

response = self.block._create_group(name)
response = self.block._create_group(name, username)
self.assertEquals(response, success)
mock_request.assert_called_with(method, url_path, data)

@patch('rocketc.rocketc.RocketChatXBlock.user_data')
@patch('rocketc.rocketc.RocketChatXBlock._add_to_group')
def test_add_to_course_group(self, mock_add_to_group):
def test_add_to_course_group(self, mock_add_to_group, mock_user):
"""Test for the add course group method"""
group_name = "test_group"
user_id = "test_user_id"
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.2.1
current_version = 0.2.2
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from setuptools import setup

__version__ = '0.2.1'
__version__ = '0.2.2'


def package_data(pkg, roots):
Expand Down

0 comments on commit 72ac7c3

Please sign in to comment.