Adds a split_test_module XModule, that can choose one of its children
to display, based on a get_condition_for_user API added to the runtime.
To test, add something like this to an xml course, or make equivalent
tweaks in mongo.
<vertical url_name="split_test_vert">
<split_test url_name="split1" experiment_id="0" condition_id_to_child='{"0": "i4x://MITx/6.00x/html/split_test_cond0", "1": "i4x://MITx/6.00x/html/split_test_cond1"}'>
<html url_name="split_test_cond0">condition 0</html>
<html url_name="split_test_cond1">condition 1</html>
</split_test>
</vertical>
Also needs an experiment configured in the course policy json: e.g.
"user_partitions": [{"id": 0,
"name": "Experiment 0",
"description": "Unicorns?",
"version": 1,
"groups": [{"id": 0,
"name": "group 0",
"version": 1},
{"id": 1,
"name": "group 1",
"version": 1}]}]
(This particular snippet will work inside a course with org MITx
and course name 6.00x)
Co-Author: Sarina Canelake <sarina@edx.org>
Co-Author: Julia Hansbrough <julia@edx.org>
Co-Author: Diana Huang <diana@edx.org>
Co-Author: Calen Pennington <cale@edx.org>
[LMS-2095]
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""
|
|
Test the user service
|
|
"""
|
|
from django.test import TestCase
|
|
|
|
from student.tests.factories import UserFactory
|
|
from user_api import user_service
|
|
|
|
|
|
class TestUserService(TestCase):
|
|
"""
|
|
Test the user service
|
|
"""
|
|
def setUp(self):
|
|
self.user = UserFactory.create()
|
|
self.course_id = 'test_org/test_course_number/test_run'
|
|
self.test_key = 'test_key'
|
|
|
|
def test_get_set_course_tag(self):
|
|
# get a tag that doesn't exist
|
|
tag = user_service.get_course_tag(self.user, self.course_id, self.test_key)
|
|
self.assertIsNone(tag)
|
|
|
|
# test setting a new key
|
|
test_value = 'value'
|
|
user_service.set_course_tag(self.user, self.course_id, self.test_key, test_value)
|
|
tag = user_service.get_course_tag(self.user, self.course_id, self.test_key)
|
|
self.assertEqual(tag, test_value)
|
|
|
|
#test overwriting an existing key
|
|
test_value = 'value2'
|
|
user_service.set_course_tag(self.user, self.course_id, self.test_key, test_value)
|
|
tag = user_service.get_course_tag(self.user, self.course_id, self.test_key)
|
|
self.assertEqual(tag, test_value)
|