From c0fda4712b724d592f9864ff0904f704d960eab9 Mon Sep 17 00:00:00 2001 From: andrey Date: Fri, 13 Apr 2018 17:00:48 -0500 Subject: [PATCH 1/3] Fixing create_group errors --- rocketc/rocketc.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rocketc/rocketc.py b/rocketc/rocketc.py index baffc11e..19000281 100644 --- a/rocketc/rocketc.py +++ b/rocketc/rocketc.py @@ -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) @@ -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): From 502d2dbe80fb539fdb3e7f0f0c26df75ce6eb024 Mon Sep 17 00:00:00 2001 From: andrey Date: Fri, 13 Apr 2018 17:09:40 -0500 Subject: [PATCH 2/3] Fixing test --- rocketc/rocketc.py | 2 +- rocketc/tests/test_rocketChat.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/rocketc/rocketc.py b/rocketc/rocketc.py index 19000281..03d07e61 100644 --- a/rocketc/rocketc.py +++ b/rocketc/rocketc.py @@ -286,7 +286,7 @@ 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, username): + def _create_group(self, name, username=""): """ This method creates a group with a specific name. """ diff --git a/rocketc/tests/test_rocketChat.py b/rocketc/tests/test_rocketChat.py index 41cc4ebe..5eb7c26e 100644 --- a/rocketc/tests/test_rocketChat.py +++ b/rocketc/tests/test_rocketChat.py @@ -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" From 008818bde9d809000495659a7d29e8c6a2c02fb2 Mon Sep 17 00:00:00 2001 From: andrey Date: Fri, 13 Apr 2018 17:23:21 -0500 Subject: [PATCH 3/3] =?UTF-8?q?Bump=20version:=200.2.1=20=E2=86=92=200.2.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.cfg | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 0dd70562..744bbaa2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.1 +current_version = 0.2.2 commit = True tag = True diff --git a/setup.py b/setup.py index 47dd71c6..323fdd57 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup -__version__ = '0.2.1' +__version__ = '0.2.2' def package_data(pkg, roots):