Namespacing all YouTube URLs on edX backend

Up to now, the backend defined 2 variables which stored YouTube related URLs:

1
2
# URL to test YouTube availability
YOUTUBE_TEST_URL = 'https://gdata.youtube.com/feeds/api/videos/'

and

1
2
3
4
5
6
# Current youtube api for requesting transcripts.
# for example: http://video.google.com/timedtext?lang=en&v=j_jEn79vS3g.
YOUTUBE_API = {
    'url': "http://video.google.com/timedtext",
    'params': {'lang': 'en', 'v': 'set_youtube_id_of_11_symbols_here'}
}

This was done in cms/envs/common.py file (lines 428, 532).

I wanted to introduce a new URL which is responsible for YouTube API on the front-end. To do this, I have created a YOUTUBE namespace, and added a third URL to the back-end:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
YOUTUBE = {
    # YouTube JavaScript API
    'API': 'www.youtube.com/iframe_api',

    # URL to test YouTube availability
    'TEST_URL': 'gdata.youtube.com/feeds/api/videos/',

    # Current youtube api for requesting transcripts.
    # For example: http://video.google.com/timedtext?lang=en&v=j_jEn79vS3g.
    'TEXT_API': {
        'url': 'video.google.com/timedtext',
        'params': {
            'lang': 'en',
            'v': 'set_youtube_id_of_11_symbols_here',
        },
    },
}

The pull request has just been merged in to edx-platform master.

This PR opens up a possibility to mock the YouTube API in acceptance tests.