-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #682 from ccnmtl/pylti1.3
Add basic LTI 1.3 support - #636
- Loading branch information
Showing
10 changed files
with
189 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,62 +26,62 @@ def setUp(self): | |
def test_create_user(self): | ||
user = self.backend.create_user(self.request, self.lti, '12345') | ||
self.assertFalse(user.has_usable_password()) | ||
self.assertEquals(user.email, '[email protected]') | ||
self.assertEquals(user.get_full_name(), 'Foo Baz') | ||
self.assertEqual(user.email, '[email protected]') | ||
self.assertEqual(user.get_full_name(), 'Foo Baz') | ||
|
||
def test_create_user_no_full_name(self): | ||
self.request.session.pop('lis_person_name_full') | ||
user = self.backend.create_user(self.request, self.lti, '12345') | ||
self.assertEquals(user.get_full_name(), 'student') | ||
self.assertEqual(user.get_full_name(), 'student') | ||
|
||
def test_create_user_empty_full_name(self): | ||
self.request.session['lis_person_name_full'] = '' | ||
user = self.backend.create_user(self.request, self.lti, '12345') | ||
self.assertEquals(user.get_full_name(), 'student') | ||
self.assertEqual(user.get_full_name(), 'student') | ||
|
||
def test_create_user_long_name(self): | ||
self.request.session['lis_person_name_full'] = ( | ||
'Pneumonoultramicroscopicsilicovolcanoconiosis ' | ||
'Supercalifragilisticexpialidocious') | ||
user = self.backend.create_user(self.request, self.lti, '12345') | ||
self.assertEquals( | ||
self.assertEqual( | ||
user.get_full_name(), | ||
'Pneumonoultramicroscopicsilico Supercalifragilisticexpialidoc') | ||
|
||
def test_find_or_create_user1(self): | ||
# via email | ||
user = UserFactory(email='[email protected]') | ||
self.assertEquals( | ||
self.assertEqual( | ||
self.backend.find_or_create_user(self.request, self.lti), user) | ||
|
||
def test_find_or_create_user2(self): | ||
# via lms username | ||
username = 'uni123' | ||
self.request.session['custom_canvas_user_login_id'] = username | ||
user = UserFactory(username=username) | ||
self.assertEquals( | ||
self.assertEqual( | ||
self.backend.find_or_create_user(self.request, self.lti), user) | ||
|
||
def test_find_or_create_user3(self): | ||
# via hashed username | ||
self.request.session['oauth_consumer_key'] = '1234567890' | ||
username = self.backend.get_hashed_username(self.request, self.lti) | ||
user = UserFactory(username=username) | ||
self.assertEquals( | ||
self.assertEqual( | ||
self.backend.find_or_create_user(self.request, self.lti), user) | ||
|
||
def test_find_or_create_user4(self): | ||
# new user | ||
self.request.session['oauth_consumer_key'] = '1234567890' | ||
user = self.backend.find_or_create_user(self.request, self.lti) | ||
self.assertFalse(user.has_usable_password()) | ||
self.assertEquals(user.email, '[email protected]') | ||
self.assertEquals(user.get_full_name(), 'Foo Baz') | ||
self.assertEqual(user.email, '[email protected]') | ||
self.assertEqual(user.get_full_name(), 'Foo Baz') | ||
|
||
username = self.backend.get_hashed_username(self.request, self.lti) | ||
self.assertEquals(user.username, username) | ||
self.assertEqual(user.username, username) | ||
|
||
def test_get_user(self): | ||
user = UserFactory() | ||
self.assertIsNone(self.backend.get_user(1234)) | ||
self.assertEquals(self.backend.get_user(user.id), user) | ||
self.assertEqual(self.backend.get_user(user.id), user) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,27 +28,27 @@ def setUp(self): | |
self.emptyRequest.session.save() | ||
|
||
def test_init(self): | ||
self.assertEquals(self.lti.request_type, 'initial') | ||
self.assertEquals(self.lti.role_type, 'any') | ||
self.assertEqual(self.lti.request_type, 'initial') | ||
self.assertEqual(self.lti.role_type, 'any') | ||
|
||
def test_consumer_user_id(self): | ||
self.request.session['oauth_consumer_key'] = '1234567890' | ||
self.assertEquals( | ||
self.assertEqual( | ||
self.lti.consumer_user_id(self.request), '1234567890-student') | ||
|
||
def test_user_email(self): | ||
self.assertIsNone(self.lti.user_email(self.emptyRequest)) | ||
self.assertEquals(self.lti.user_email(self.request), '[email protected]') | ||
self.assertEqual(self.lti.user_email(self.request), '[email protected]') | ||
|
||
def test_user_fullname(self): | ||
self.assertEquals(self.lti.user_fullname(self.emptyRequest), '') | ||
self.assertEqual(self.lti.user_fullname(self.emptyRequest), '') | ||
|
||
self.assertEquals(self.lti.user_fullname(self.request), 'Foo Bar Baz') | ||
self.assertEqual(self.lti.user_fullname(self.request), 'Foo Bar Baz') | ||
|
||
def test_user_roles(self): | ||
self.assertEquals(self.lti.user_roles(self.emptyRequest), []) | ||
self.assertEqual(self.lti.user_roles(self.emptyRequest), []) | ||
|
||
self.assertEquals(self.lti.user_roles(self.request), [ | ||
self.assertEqual(self.lti.user_roles(self.request), [ | ||
u'urn:lti:instrole:ims/lis/instructor', | ||
u'urn:lti:instrole:ims/lis/staff']) | ||
|
||
|
@@ -57,7 +57,7 @@ def test_user_roles(self): | |
|
||
def test_consumers(self): | ||
with self.settings(PYLTI_CONFIG={'consumers': CONSUMERS}): | ||
self.assertEquals(self.lti.consumers(), CONSUMERS) | ||
self.assertEqual(self.lti.consumers(), CONSUMERS) | ||
|
||
def test_params(self): | ||
factory = RequestFactory() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,9 +115,9 @@ def test_launch_invalid_user(self): | |
request = generate_lti_request() | ||
|
||
response = LTIRoutingView().dispatch(request) | ||
self.assertEquals(response.status_code, 302) | ||
self.assertEqual(response.status_code, 302) | ||
|
||
self.assertEquals(response.url, reverse('lti-fail-auth')) | ||
self.assertEqual(response.url, reverse('lti-fail-auth')) | ||
self.assertFalse(request.session.get(LTI_SESSION_KEY, False)) | ||
|
||
def test_launch_invalid_course(self): | ||
|
@@ -127,8 +127,8 @@ def test_launch_invalid_course(self): | |
request = generate_lti_request() | ||
|
||
response = LTIRoutingView().dispatch(request) | ||
self.assertEquals(response.status_code, 302) | ||
self.assertEquals(response.url, reverse('lti-course-config')) | ||
self.assertEqual(response.status_code, 302) | ||
self.assertEqual(response.url, reverse('lti-course-config')) | ||
self.assertTrue(request.session.get(LTI_SESSION_KEY, False)) | ||
|
||
def test_launch(self): | ||
|
@@ -143,17 +143,17 @@ def test_launch(self): | |
view.request = request | ||
|
||
response = view.dispatch(request) | ||
self.assertEquals(response.status_code, 302) | ||
self.assertEqual(response.status_code, 302) | ||
|
||
landing = 'http://testserver/?lti_version=LTI-1p0&' | ||
self.assertEquals( | ||
self.assertEqual( | ||
response.url, landing.format(ctx.lms_course_context)) | ||
|
||
self.assertIsNotNone(request.session[LTI_SESSION_KEY]) | ||
user = request.user | ||
self.assertFalse(user.has_usable_password()) | ||
self.assertEquals(user.email, '[email protected]') | ||
self.assertEquals(user.get_full_name(), 'Foo Baz') | ||
self.assertEqual(user.email, '[email protected]') | ||
self.assertEqual(user.get_full_name(), 'Foo Baz') | ||
self.assertTrue(user in ctx.group.user_set.all()) | ||
self.assertTrue(user in ctx.faculty_group.user_set.all()) | ||
|
||
|
@@ -170,16 +170,16 @@ def test_launch_custom_landing_page(self): | |
|
||
response = view.dispatch(request) | ||
landing = 'http://testserver/lti/landing/{}/?lti_version=LTI-1p0&' | ||
self.assertEquals(response.status_code, 302) | ||
self.assertEqual(response.status_code, 302) | ||
self.assertTrue( | ||
response.url, | ||
landing.format(ctx.lms_course_context)) | ||
|
||
self.assertIsNotNone(request.session[LTI_SESSION_KEY]) | ||
user = request.user | ||
self.assertFalse(user.has_usable_password()) | ||
self.assertEquals(user.email, '[email protected]') | ||
self.assertEquals(user.get_full_name(), 'Foo Baz') | ||
self.assertEqual(user.email, '[email protected]') | ||
self.assertEqual(user.get_full_name(), 'Foo Baz') | ||
self.assertTrue(user in ctx.group.user_set.all()) | ||
self.assertTrue(user in ctx.faculty_group.user_set.all()) | ||
|
||
|
@@ -194,17 +194,17 @@ def test_embed(self): | |
view.request = request | ||
|
||
response = view.dispatch(request) | ||
self.assertEquals(response.status_code, 302) | ||
self.assertEquals( | ||
self.assertEqual(response.status_code, 302) | ||
self.assertEqual( | ||
response.url, | ||
'http://testserver/asset/embed/?return_url=/asset/' | ||
'<i_version=LTI-1p0&') | ||
|
||
self.assertIsNotNone(request.session[LTI_SESSION_KEY]) | ||
user = request.user | ||
self.assertFalse(user.has_usable_password()) | ||
self.assertEquals(user.email, '[email protected]') | ||
self.assertEquals(user.get_full_name(), 'Foo Baz') | ||
self.assertEqual(user.email, '[email protected]') | ||
self.assertEqual(user.get_full_name(), 'Foo Baz') | ||
self.assertTrue(user in ctx.group.user_set.all()) | ||
self.assertTrue(user in ctx.faculty_group.user_set.all()) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.