Remove transcript credential saving in VAL (#24066)
This commit is contained in:
@@ -15,11 +15,6 @@ from contentstore.tests.utils import CourseTestCase
|
||||
from contentstore.utils import reverse_course_url
|
||||
from contentstore.views.transcript_settings import TranscriptionProviderErrorType, validate_transcript_credentials
|
||||
from openedx.core.djangoapps.profile_images.tests.helpers import make_image_file
|
||||
from openedx.core.djangoapps.video_pipeline.config.waffle import (
|
||||
SAVE_CREDENTIALS_IN_VAL,
|
||||
waffle_flags
|
||||
)
|
||||
from openedx.core.djangoapps.waffle_utils.testutils import override_waffle_flag
|
||||
from student.roles import CourseStaffRole
|
||||
|
||||
|
||||
@@ -113,56 +108,6 @@ class TranscriptCredentialsTest(CourseTestCase):
|
||||
self.assertEqual(response.status_code, expected_status_code)
|
||||
self.assertEqual(response.content.decode('utf-8'), expected_response)
|
||||
|
||||
@override_waffle_flag(waffle_flags()[SAVE_CREDENTIALS_IN_VAL], True)
|
||||
@ddt.data(
|
||||
(
|
||||
{
|
||||
'provider': '3PlayMedia',
|
||||
'api_key': '11111',
|
||||
'api_secret_key': '44444'
|
||||
},
|
||||
{'error_type': TranscriptionProviderErrorType.INVALID_CREDENTIALS},
|
||||
400,
|
||||
'{\n "error": "The information you entered is incorrect."\n}'
|
||||
),
|
||||
(
|
||||
{
|
||||
'provider': 'Cielo24',
|
||||
'api_key': '12345',
|
||||
'username': 'test_user'
|
||||
},
|
||||
{'error_type': None},
|
||||
200,
|
||||
''
|
||||
),
|
||||
(
|
||||
{
|
||||
'provider': '3PlayMedia',
|
||||
'api_key': '12345',
|
||||
'api_secret_key': '44444'
|
||||
},
|
||||
{'error_type': None},
|
||||
200,
|
||||
''
|
||||
)
|
||||
)
|
||||
@ddt.unpack
|
||||
@patch('edxval.api.create_or_update_transcript_credentials')
|
||||
def test_val_transcript_credentials_handler(self, request_payload, update_credentials_response,
|
||||
expected_status_code, expected_response, api_patch):
|
||||
"""
|
||||
Test that credentials handler works fine with VAL api endpoint.
|
||||
"""
|
||||
api_patch.return_value = update_credentials_response
|
||||
transcript_credentials_url = self.get_url_for_course_key(self.course.id)
|
||||
response = self.client.post(
|
||||
transcript_credentials_url,
|
||||
data=json.dumps(request_payload),
|
||||
content_type='application/json'
|
||||
)
|
||||
self.assertEqual(response.status_code, expected_status_code)
|
||||
self.assertEqual(response.content.decode('utf-8'), expected_response)
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class TranscriptCredentialsValidationTest(TestCase):
|
||||
|
||||
@@ -11,6 +11,9 @@ from django.core.files.base import ContentFile
|
||||
from django.http import HttpResponse, HttpResponseNotFound
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.views.decorators.http import require_GET, require_http_methods, require_POST
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from contentstore.views.videos import TranscriptProvider
|
||||
from edxval.api import (
|
||||
create_or_update_video_transcript,
|
||||
delete_video_transcript,
|
||||
@@ -19,14 +22,7 @@ from edxval.api import (
|
||||
get_video_transcript_data,
|
||||
update_transcript_credentials_state_for_org
|
||||
)
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from contentstore.views.videos import TranscriptProvider
|
||||
from openedx.core.djangoapps.video_config.models import VideoTranscriptEnabledFlag
|
||||
from openedx.core.djangoapps.video_pipeline.config.waffle import (
|
||||
SAVE_CREDENTIALS_IN_VAL,
|
||||
waffle_flags
|
||||
)
|
||||
from openedx.core.djangoapps.video_pipeline.api import update_3rd_party_transcription_service_credentials
|
||||
from student.auth import has_studio_write_access
|
||||
from util.json_request import JsonResponse, expect_json
|
||||
@@ -114,12 +110,7 @@ def transcript_credentials_handler(request, course_key_string):
|
||||
else:
|
||||
# Send the validated credentials to edx-video-pipeline.
|
||||
credentials_payload = dict(validated_credentials, org=course_key.org, provider=provider)
|
||||
if waffle_flags()[SAVE_CREDENTIALS_IN_VAL].is_enabled(course_key):
|
||||
from edxval.api import create_or_update_transcript_credentials
|
||||
response = create_or_update_transcript_credentials(**credentials_payload)
|
||||
error_response, is_updated = response, not response.get('error_type')
|
||||
else:
|
||||
error_response, is_updated = update_3rd_party_transcription_service_credentials(**credentials_payload)
|
||||
error_response, is_updated = update_3rd_party_transcription_service_credentials(**credentials_payload)
|
||||
# Send appropriate response based on whether credentials were updated or not.
|
||||
if is_updated:
|
||||
# Cache credentials state in edx-val.
|
||||
|
||||
Reference in New Issue
Block a user