def test_update_usage_info_no_message(self, mocked_validation_messages):
     """
     Tests if validation message is not present when updating usage info.
     """
     self._add_user_partitions()
     self._create_content_experiment(cid=0, name_suffix='0')
     mocked_validation_messages.return_value = []
     group_configuration = GroupConfiguration.update_usage_info(self.store, self.course, self.course.user_partitions[0])
     self.assertEqual(group_configuration['usage'][0]['validation'], None)
 def test_update_usage_info_no_message(self, mocked_validation_messages):
     """
     Tests if validation message is not present when updating usage info.
     """
     self._add_user_partitions()
     self._create_content_experiment(cid=0, name_suffix='0')
     mocked_validation_messages.return_value = []
     group_configuration = GroupConfiguration.update_usage_info(
         self.store, self.course, self.course.user_partitions[0])
     self.assertEqual(group_configuration['usage'][0]['validation'], None)
Пример #3
0
    def verify_validation_update_usage_info(self, expected_result, mocked_message, mocked_validation_messages):
        """
        Helper method for testing validation information present after update_usage_info.
        """
        self._add_user_partitions()
        split_test = self._create_content_experiment(cid=0, name_suffix='0')[1]

        validation = StudioValidation(split_test.location)
        if mocked_message is not None:
            validation.add(mocked_message)
        mocked_validation_messages.return_value = validation

        group_configuration = GroupConfiguration.update_usage_info(
            self.store, self.course, self.course.user_partitions[0]
        )
        self.assertEqual(
            expected_result.to_json() if expected_result is not None else None,
            group_configuration['usage'][0]['validation']
        )
    def test_update_usage_info(self, mocked_validation_messages):
        """
        Tests if validation message is present when updating usage info.
        """
        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.update_usage_info(
            self.store, self.course, self.course.user_partitions[0])

        self.assertEqual(
            group_configuration['usage'][0]['validation'], {
                'message':
                u'This content experiment has issues that affect content visibility.',
                'type': 'warning'
            })
    def test_update_usage_info(self, mocked_validation_messages):
        """
        Tests if validation message is present when updating usage info.
        """
        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.update_usage_info(self.store, self.course, self.course.user_partitions[0])

        self.assertEqual(
            group_configuration['usage'][0]['validation'],
            {
                'message': u'This content experiment has issues that affect content visibility.',
                'type': 'warning'
            }
        )