Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lti-xblock-consumer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenJupyter
lti-xblock-consumer
Commits
606f1caa
Commit
606f1caa
authored
7 years ago
by
noraiz-anwar
Browse files
Options
Downloads
Patches
Plain Diff
make system tolerant of ascii strings with unicode characters
parent
36c49977
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lti_consumer/outcomes.py
+1
-1
1 addition, 1 deletion
lti_consumer/outcomes.py
lti_consumer/tests/unit/test_outcomes.py
+40
-0
40 additions, 0 deletions
lti_consumer/tests/unit/test_outcomes.py
with
41 additions
and
1 deletion
lti_consumer/outcomes.py
+
1
−
1
View file @
606f1caa
...
...
@@ -40,7 +40,7 @@ def parse_grade_xml_body(body):
"""
lti_spec_namespace
=
"
http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0
"
namespaces
=
{
'
def
'
:
lti_spec_namespace
}
data
=
body
.
strip
()
.
encode
(
'
utf-8
'
)
data
=
body
.
strip
()
try
:
parser
=
etree
.
XMLParser
(
ns_clean
=
True
,
recover
=
True
,
encoding
=
'
utf-8
'
)
# pylint: disable=no-member
...
...
This diff is collapsed.
Click to expand it.
lti_consumer/tests/unit/test_outcomes.py
+
40
−
0
View file @
606f1caa
# -*- coding: utf-8 -*-
"""
Unit tests for lti_consumer.outcomes module
"""
...
...
@@ -288,6 +289,45 @@ class TestParseGradeXmlBody(unittest.TestCase):
with
self
.
assertRaises
(
LtiError
):
__
,
__
,
__
,
__
=
parse_grade_xml_body
(
'
<xml>
'
)
def
test_string_with_unicode_chars
(
self
):
"""
Test that system is tolerant to data which has unicode chars in
strings which are not specified as unicode.
"""
request_body_template
=
textwrap
.
dedent
(
"""
<?xml version=
"
1.0
"
encoding=
"
UTF-8
"
?>
<imsx_POXEnvelopeRequest xmlns=
"
http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0
"
>
<imsx_POXHeader>
<imsx_POXRequestHeaderInfo>
<imsx_version>V1.0</imsx_version>
<imsx_messageIdentifier>ţéšţ_message_id</imsx_messageIdentifier>
</imsx_POXRequestHeaderInfo>
</imsx_POXHeader>
<imsx_POXBody>
<ţéšţ_action>
<resultRecord>
<sourcedGUID>
<sourcedId>ţéšţ_sourced_id</sourcedId>
</sourcedGUID>
<result>
<resultScore>
<language>en-us</language>
<textString>1.0</textString>
</resultScore>
</result>
</resultRecord>
</ţéšţ_action>
</imsx_POXBody>
</imsx_POXEnvelopeRequest>
"""
)
msg_id
,
sourced_id
,
score
,
action
=
parse_grade_xml_body
(
request_body_template
)
self
.
assertEqual
(
msg_id
,
u
'
ţéšţ_message_id
'
)
self
.
assertEqual
(
sourced_id
,
u
'
ţéšţ_sourced_id
'
)
self
.
assertEqual
(
score
,
1.0
)
self
.
assertEqual
(
action
,
u
'
ţéšţ_action
'
)
class
TestOutcomeService
(
TestLtiConsumerXBlock
):
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment