Example #1
0
    def test_validate_three_play_media_config_with_3pm_streaming(
            self, get_3pm_transcripts_list_mock):
        """
        Test 3PlayMedia configuration validation (streaming enabled case).
        """
        # Arrange:
        success_message = _('Success')
        test_feedback = {'status': Status.success, 'message': success_message}
        test_transcripts_list = [{"test_transcript"}]
        get_3pm_transcripts_list_mock.return_value = test_feedback, test_transcripts_list
        request_mock = arrange_request_mock(
            '{"api_key": "test_apikey", "file_id": "test_fileid", "streaming_enabled": "1"}'  # JSON string
        )
        # Act:
        result_response = self.xblock.validate_three_play_media_config(
            request_mock)
        result = result_response.body  # pylint: disable=no-member

        # Assert:
        self.assertEqual(
            result,
            json.dumps({
                'isValid': True,
                'message': success_message
            },
                       separators=(',', ':')))
        get_3pm_transcripts_list_mock.assert_called_once_with(
            "test_fileid", "test_apikey")  # Python string
Example #2
0
    def test_validate_three_play_media_config_partially_configured(self):
        """
        Test 3PlayMedia configuration validation (improperly configured case).
        """
        # Arrange:
        invalid_message = _('Check provided 3PlayMedia configuration')
        request_mock = arrange_request_mock(
            '{"file_id": "test_fileid", "streaming_enabled": "1"}'  # "api_key" not provided
        )
        # Act:
        result_response = self.xblock.validate_three_play_media_config(request_mock)
        result = result_response.body  # pylint: disable=no-member

        # Assert:
        self.assertEqual(
            result,
            json.dumps({'isValid': False, 'message': invalid_message}, separators=(',', ':'))
        )
Example #3
0
    def test_validate_three_play_media_config_without_streaming(self):
        """
        Test 3PlayMedia configuration validation (streaming disabled case).
        """
        # Arrange:
        success_message = _('Success')
        request_mock = arrange_request_mock(
            '{"api_key": "test_apikey", "file_id": "test_fileid", "streaming_enabled": "0"}'  # JSON string
        )
        # Act:
        result_response = self.xblock.validate_three_play_media_config(request_mock)
        result = result_response.body  # pylint: disable=no-member

        # Assert:
        self.assertEqual(
            result,
            json.dumps({'isValid': True, 'message': success_message}, separators=(',', ':'))
        )
Example #4
0
    def test_validate_three_play_media_config_initial_case(self):
        """
        Test 3PlayMedia configuration validation (initial case).
        """
        # Arrange:
        success_message = _("Initialization")
        request_mock = arrange_request_mock(
            '{"streaming_enabled": "0"}'  # JSON string
        )
        # Act:
        result_response = self.xblock.validate_three_play_media_config(request_mock)
        result = result_response.body  # pylint: disable=no-member

        # Assert:
        self.assertEqual(
            result,
            json.dumps({'isValid': True, 'message': success_message}, separators=(',', ':'))
        )