Skip to content

Commit

Permalink
Merge pull request #145 from ucfopen/develop
Browse files Browse the repository at this point in the history
Release v0.8.2
  • Loading branch information
Jesse McBride authored Jan 24, 2018
2 parents 8fcd0c8 + 5abbad6 commit 4a9c328
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 44 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [0.8.2] - 2018-01-24

### Bugfixes

- Fixed an issue where editing and deleting user logins would use incorrect IDs.

## [0.8.1] - 2018-01-23

### General
Expand Down
2 changes: 1 addition & 1 deletion canvasapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

__all__ = ["Canvas"]

__version__ = '0.8.1'
__version__ = '0.8.2'
4 changes: 2 additions & 2 deletions canvasapi/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def delete(self):
"""
response = self._requester.request(
'DELETE',
'users/{}/logins/{}'.format(self.id, self.unique_id)
'users/{}/logins/{}'.format(self.user_id, self.id)
)
return Login(self._requester, response.json())

Expand All @@ -38,7 +38,7 @@ def edit(self, **kwargs):
"""
response = self._requester.request(
'PUT',
'accounts/{}/logins/{}'.format(self.id, self.unique_id),
'accounts/{}/logins/{}'.format(self.account_id, self.id),
_kwargs=combine_kwargs(**kwargs)
)
return Login(self._requester, response.json())
9 changes: 0 additions & 9 deletions tests/fixtures/account.json
Original file line number Diff line number Diff line change
Expand Up @@ -739,15 +739,6 @@
],
"status_code": 200
},
"create_user_login": {
"method": "POST",
"endpoint": "accounts/1/logins",
"data": {
"id": 123,
"unique_id": 112233
},
"status_code": 200
},
"get_department_level_participation_data_with_given_term": {
"method": "GET",
"endpoint": "accounts/1/analytics/terms/1/activity",
Expand Down
43 changes: 23 additions & 20 deletions tests/fixtures/login.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"method": "POST",
"endpoint": "accounts/1/logins",
"data": {
"id": 123,
"unique_id": 112233
"account_id": 1,
"id": 101,
"unique_id": "[email protected]",
"user_id": 1
},
"status_code": 200
},
Expand All @@ -14,50 +16,51 @@
"data": [
{
"account_id": 1,
"id": 2,
"sis_user_id": null,
"id": 101,
"unique_id": "[email protected]",
"user_id": 2,
"authentication_provider_id": 1,
"authentication_provider_type": "facebook"
"user_id": 1
}
],
"headers": {
"Link": "<http://example.com/api/v1/accounts/1/logins/?page=2&per_page=2>; rel=\"next\""
"Link": "<http://example.com/api/v1/accounts/1/logins/?page=2&per_page=1>; rel=\"next\""
},
"status_code": 200
},
"list_user_logins_2": {
"method": "GET",
"endpoint": "accounts/1/logins/?page=2&per_page=2",
"endpoint": "accounts/1/logins/?page=2&per_page=1",
"data": [
{
"account_id": 2,
"id": 3,
"account_id": 1,
"id": 102,
"sis_user_id": null,
"unique_id": "belieber@example.com",
"user_id": 3,
"authentication_provider_id": 2,
"unique_id": "facebook@example.com",
"user_id": 1,
"authentication_provider_id": 1,
"authentication_provider_type": "facebook"
}
],
"status_code": 200
},
"edit_user_login": {
"method": "PUT",
"endpoint": "accounts/123/logins/112233",
"endpoint": "accounts/1/logins/101",
"data": {
"id": 123,
"unique_id": 112233
"account_id": 1,
"id": 101,
"unique_id": "[email protected]",
"user_id": 1
},
"status_code": 200
},
"delete_user_login": {
"method": "DELETE",
"endpoint": "users/123/logins/112233",
"endpoint": "users/1/logins/101",
"data": {
"id": 123,
"unique_id": 112233
"account_id": 1,
"id": 101,
"unique_id": "[email protected]",
"user_id": 1
}
}
}
15 changes: 10 additions & 5 deletions tests/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,23 +450,28 @@ def test_list_user_logins(self, m):

# create_user_login()
def test_create_user_login(self, m):
register_uris({'account': ['create_user_login']}, m)
register_uris({'login': ['create_user_login']}, m)

response = self.account.create_user_login(user={'id': 123}, login={'unique_id': 112233})
unique_id = '[email protected]'

response = self.account.create_user_login(
user={'id': 1},
login={'unique_id': unique_id}
)

self.assertIsInstance(response, Login)
self.assertTrue(hasattr(response, 'id'))
self.assertTrue(hasattr(response, 'unique_id'))
self.assertEqual(response.id, 123)
self.assertEqual(response.unique_id, 112233)
self.assertEqual(response.id, 101)
self.assertEqual(response.unique_id, unique_id)

def test_create_user_login_fail_on_user_id(self, m):
with self.assertRaises(RequiredFieldMissing):
self.account.create_user_login(user={}, login={})

def test_create_user_login_fail_on_login_unique_id(self, m):
with self.assertRaises(RequiredFieldMissing):
self.account.create_user_login(user={'id': 123}, login={})
self.account.create_user_login(user={'id': 1}, login={})

# get_department_level_participation_data_with_given_term()
def test_get_department_level_participation_data_with_given_term(self, m):
Expand Down
15 changes: 8 additions & 7 deletions tests/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ def setUp(self):

with requests_mock.Mocker() as m:
register_uris({
'account': ['get_by_id', 'create_user_login']
'account': ['get_by_id'],
'login': ['create_user_login']
}, m)

self.account = self.canvas.get_account(1)
self.login = self.account.create_user_login(
user={"id": 123},
login={"unique_id": 112233}
user={'id': 1},
login={'unique_id': '[email protected]'}
)

# delete()
Expand All @@ -34,16 +35,16 @@ def test_delete_user_login(self, m):

self.assertIsInstance(deleted_user_login, Login)
self.assertTrue(hasattr(deleted_user_login, 'unique_id'))
self.assertEqual(deleted_user_login.unique_id, 112233)
self.assertEqual(deleted_user_login.unique_id, '[email protected]')

# edit()
def test_edit_user_login(self, m):
register_uris({'login': ['edit_user_login']}, m)

unique_id = 112233
unique_id = '[email protected]'
edited_user_login = self.login.edit(
user={"id": 123},
login={"unique_id": unique_id},
user={'id': 1},
login={'unique_id': unique_id},
)

self.assertIsInstance(edited_user_login, Login)
Expand Down

0 comments on commit 4a9c328

Please sign in to comment.