Commit b3e7516a by Syed Hassan Raza

Handle Unicode for Incoming Keys

parent 7b36645e
......@@ -55,7 +55,9 @@ class VideoStudentViewHandlers(object):
if dispatch == 'save_user_state':
for key in data:
if hasattr(self, key) and key in accepted_keys:
if type(key) == str:
key = unicode(key, "UTF8")
if hasattr(self, key.encode('utf8')) and key in accepted_keys:
if key in conversions:
value = conversions[key](data[key])
else:
......
......@@ -131,6 +131,7 @@ class TestVideo(BaseTestXmodule):
{'speed': 2.0},
{'saved_video_position': "00:00:10"},
{'transcript_language': 'uk'},
{'demoo�': 'sample'}
]
for sample in data:
response = self.clients[self.users[0].username].post(
......@@ -152,6 +153,10 @@ class TestVideo(BaseTestXmodule):
self.item_descriptor.handle_ajax('save_user_state', {'transcript_language': "uk"})
self.assertEqual(self.item_descriptor.transcript_language, 'uk')
response = self.item_descriptor.handle_ajax('save_user_state', {'demoo�': "sample"})
self.assertEqual(json.loads(response)['success'], True)
def tearDown(self):
_clear_assets(self.item_descriptor.location)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment