Beispiel #1
0
    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)
    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)
 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)
    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'])
 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)
    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'
            })
    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)
    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',
            '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,
            }],
        }, {
            'id': 1,
            'name': 'Name 1',
            'description': 'Description 1',
            '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)
    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'
            }
        )
Beispiel #10
0
    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)