本文整理汇总了Python中contentstore.views.course.GroupConfiguration.add_usage_info方法的典型用法代码示例。如果您正苦于以下问题:Python GroupConfiguration.add_usage_info方法的具体用法?Python GroupConfiguration.add_usage_info怎么用?Python GroupConfiguration.add_usage_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类contentstore.views.course.GroupConfiguration
的用法示例。
在下文中一共展示了GroupConfiguration.add_usage_info方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_can_use_one_configuration_in_multiple_experiments
# 需要导入模块: from contentstore.views.course import GroupConfiguration [as 别名]
# 或者: from contentstore.views.course.GroupConfiguration import add_usage_info [as 别名]
def test_can_use_one_configuration_in_multiple_experiments(self):
"""
Test if multiple experiments are present in usage info when they use same
group configuration.
"""
self._add_user_partitions()
vertical, __ = self._create_content_experiment(cid=0, name_suffix='0')
vertical1, __ = self._create_content_experiment(cid=0, name_suffix='1')
actual = GroupConfiguration.add_usage_info(self.course, self.store)
expected = [{
'id': 0,
'name': 'Name 0',
'description': 'Description 0',
'version': 1,
'groups': [
{'id': 0, 'name': 'Group A', 'version': 1},
{'id': 1, 'name': 'Group B', 'version': 1},
{'id': 2, 'name': 'Group C', 'version': 1},
],
'usage': [{
'url': '/container/{}'.format(vertical.location),
'label': 'Test Unit 0 / Test Content Experiment 0',
'validation': None,
}, {
'url': '/container/{}'.format(vertical1.location),
'label': 'Test Unit 1 / Test Content Experiment 1',
'validation': None,
}],
}]
self.assertEqual(actual, expected)
示例2: test_can_use_one_configuration_in_multiple_experiments
# 需要导入模块: from contentstore.views.course import GroupConfiguration [as 别名]
# 或者: from contentstore.views.course.GroupConfiguration import add_usage_info [as 别名]
def test_can_use_one_configuration_in_multiple_experiments(self):
"""
Test if multiple experiments are present in usage info when they use same
group configuration.
"""
self._add_user_partitions()
self._create_content_experiment(cid=0, name_suffix='0')
self._create_content_experiment(cid=0, name_suffix='1')
actual = GroupConfiguration.add_usage_info(self.course, self.store)
expected = [{
u'id': 0,
u'name': u'Name 0',
u'description': u'Description 0',
u'version': 1,
u'groups': [
{u'id': 0, u'name': u'Group A', u'version': 1},
{u'id': 1, u'name': u'Group B', u'version': 1},
{u'id': 2, u'name': u'Group C', u'version': 1},
],
u'usage': [{
'url': '/unit/i4x://MITx/999/vertical/Test_Unit_0',
'label': 'Test Unit 0 / Test Content Experiment 0',
}, {
'url': '/unit/i4x://MITx/999/vertical/Test_Unit_1',
'label': 'Test Unit 1 / Test Content Experiment 1',
}],
}]
self.assertEqual(actual, expected)
示例3: verify_validation_add_usage_info
# 需要导入模块: from contentstore.views.course import GroupConfiguration [as 别名]
# 或者: from contentstore.views.course.GroupConfiguration import add_usage_info [as 别名]
def verify_validation_add_usage_info(self, expected_result, mocked_message, mocked_validation_messages):
"""
Helper method for testing validation information present after add_usage_info.
"""
self._add_user_partitions()
split_test = self._create_content_experiment(cid=0, name_suffix='0')[1]
validation = StudioValidation(split_test.location)
validation.add(mocked_message)
mocked_validation_messages.return_value = validation
group_configuration = GroupConfiguration.add_usage_info(self.course, self.store)[0]
self.assertEqual(expected_result.to_json(), group_configuration['usage'][0]['validation'])
示例4: test_group_configuration_not_used
# 需要导入模块: from contentstore.views.course import GroupConfiguration [as 别名]
# 或者: from contentstore.views.course.GroupConfiguration import add_usage_info [as 别名]
def test_group_configuration_not_used(self):
"""
Test that right data structure will be created if group configuration is not used.
"""
self._add_user_partitions()
actual = GroupConfiguration.add_usage_info(self.course, self.store)
expected = [{
'id': 0,
'name': 'Name 0',
'description': 'Description 0',
'version': 1,
'groups': [
{'id': 0, 'name': 'Group A', 'version': 1},
{'id': 1, 'name': 'Group B', 'version': 1},
{'id': 2, 'name': 'Group C', 'version': 1},
],
'usage': [],
}]
self.assertEqual(actual, expected)
示例5: test_can_get_correct_usage_info
# 需要导入模块: from contentstore.views.course import GroupConfiguration [as 别名]
# 或者: from contentstore.views.course.GroupConfiguration import add_usage_info [as 别名]
def test_can_get_correct_usage_info(self):
"""
Test if group configurations json updated successfully with usage information.
"""
self._add_user_partitions(count=2)
vertical, __ = self._create_content_experiment(cid=0, name_suffix='0')
self._create_content_experiment(name_suffix='1')
actual = GroupConfiguration.add_usage_info(self.course, self.store)
expected = [{
'id': 0,
'name': 'Name 0',
'scheme': 'random',
'description': 'Description 0',
'version': UserPartition.VERSION,
'groups': [
{'id': 0, 'name': 'Group A', 'version': 1},
{'id': 1, 'name': 'Group B', 'version': 1},
{'id': 2, 'name': 'Group C', 'version': 1},
],
'usage': [{
'url': '/container/{}'.format(vertical.location),
'label': 'Test Unit 0 / Test Content Experiment 0',
'validation': None,
}],
}, {
'id': 1,
'name': 'Name 1',
'scheme': 'random',
'description': 'Description 1',
'version': UserPartition.VERSION,
'groups': [
{'id': 0, 'name': 'Group A', 'version': 1},
{'id': 1, 'name': 'Group B', 'version': 1},
{'id': 2, 'name': 'Group C', 'version': 1},
],
'usage': [],
}]
self.assertEqual(actual, expected)
示例6: test_warning_message_present
# 需要导入模块: from contentstore.views.course import GroupConfiguration [as 别名]
# 或者: from contentstore.views.course.GroupConfiguration import add_usage_info [as 别名]
def test_warning_message_present(self, mocked_validation_messages):
"""
Tests if validation message is present.
"""
self._add_user_partitions()
split_test = self._create_content_experiment(cid=0, name_suffix='0')[1]
mocked_validation_messages.return_value = [
ValidationMessage(
split_test,
u"Validation message",
ValidationMessageType.warning
)
]
group_configuration = GroupConfiguration.add_usage_info(self.course, self.store)[0]
self.assertEqual(
group_configuration['usage'][0]['validation'],
{
'message': u'This content experiment has issues that affect content visibility.',
'type': 'warning'
}
)
示例7: test_can_get_correct_usage_info
# 需要导入模块: from contentstore.views.course import GroupConfiguration [as 别名]
# 或者: from contentstore.views.course.GroupConfiguration import add_usage_info [as 别名]
def test_can_get_correct_usage_info(self):
"""
Test if group configurations json updated successfully with usage information.
"""
self._add_user_partitions(count=2)
self._create_content_experiment(cid=0, name_suffix='0')
self._create_content_experiment(name_suffix='1')
actual = GroupConfiguration.add_usage_info(self.course, self.store)
expected = [{
u'id': 0,
u'name': u'Name 0',
u'description': u'Description 0',
u'version': 1,
u'groups': [
{u'id': 0, u'name': u'Group A', u'version': 1},
{u'id': 1, u'name': u'Group B', u'version': 1},
{u'id': 2, u'name': u'Group C', u'version': 1},
],
u'usage': [{
'url': '/unit/i4x://MITx/999/vertical/Test_Unit_0',
'label': 'Test Unit 0 / Test Content Experiment 0',
}],
}, {
u'id': 1,
u'name': u'Name 1',
u'description': u'Description 1',
u'version': 1,
u'groups': [
{u'id': 0, u'name': u'Group A', u'version': 1},
{u'id': 1, u'name': u'Group B', u'version': 1},
{u'id': 2, u'name': u'Group C', u'version': 1},
],
u'usage': [],
}]
self.assertEqual(actual, expected)