-
Notifications
You must be signed in to change notification settings - Fork 6
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
And/refactor rocketchat #23
Conversation
Codecov Report
@@ Coverage Diff @@
## master #23 +/- ##
===========================================
+ Coverage 60.39% 93.66% +33.26%
===========================================
Files 5 6 +1
Lines 505 742 +237
===========================================
+ Hits 305 695 +390
+ Misses 200 47 -153
Continue to review full report at Codecov.
|
self.server_url = server_url | ||
self._login(user, password) | ||
|
||
def _login(self, user, password): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better if we name this method _login_admin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any user can do login in rocketchat , if you want to use this api in another context you could use with any user but any user can not use all the methods that depends on the user's configuration in rocketchat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, you're right, in fact what we are doing in this method is to get api tokens, so in that order of ideas the method name could be changed. But definitively this method is not exclusive for admins, is for users who have enough privileges to communicate with the API's
rocketc/api_rocket_chat.py
Outdated
self._login(user, password) | ||
|
||
def _login(self, user, password): | ||
"""""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
rocketc/api_rocket_chat.py
Outdated
LOG.info("Auth_token: %s, User_id: %s ", self.headers[ | ||
"X-Auth-Token"], self.headers["X-User-Id"]) | ||
|
||
def _request_rocket_chat(self, method, url_path, data=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
important to mention here that admin credentials are used to perform these requests
rocketc/api_rocket_chat.py
Outdated
LOG.info("Request rocketChat status code = %s", response.status_code) | ||
return response.json() | ||
|
||
def add_to_group(self, user_id, room_id): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better add_user_to_group? what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it
rocketc/api_rocket_chat.py
Outdated
LOG.info("Method Add to Group: %s with this data: %s", response, data) | ||
return response | ||
|
||
def change_role(self, user_id, role): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change_user_role
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it
rocketc/rocketc.py
Outdated
def _request_rocket_chat(self, method, url_path, data=None): | ||
return False | ||
|
||
def _update_user(self, user_id, user_data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, brief docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
rocketc/rocketc.py
Outdated
|
||
def _add_to_group(self, user_id, room_id): | ||
def _join_groups(self, user_id, user_data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the method name should be "_join_user_to_configuration_groups"? The desition of which groups the user should be added to is taken based on xblock configuration
rocketc/rocketc.py
Outdated
|
||
LOG.info("Login method: result create token: %s", data) | ||
|
||
return data | ||
|
||
def create_token(self, username): | ||
def _add_to_course_group(self, group_name, user_id): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_add_user_to_course_group?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
rocketc/rocketc.py
Outdated
team = api.get_user_team(course_id, username) | ||
print team | ||
LOG.info("Get Team response: %s", team) | ||
if team: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, here I see the user can have more than one team
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user only can be in one team, in this case the response is an array with zero or one element
rocketc/rocketc.py
Outdated
LOG.info("Add to team group response: %s", response) | ||
return response["success"] | ||
|
||
def _get_team(self, username, course_id): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_get_user_lms_team ??
And finally just correct tests :) |
846d491
to
0453057
Compare
f0edf19
to
35127af
Compare
Please bump version and merge @andrey-canon |
df32d2a
to
d8ddf2d
Compare
Description
Refactor
Reviewers