Skip to content

Commit

Permalink
Test for parsing of Stanford subtitle URL.
Browse files Browse the repository at this point in the history
  • Loading branch information
pitchers committed Jan 20, 2016
1 parent d13ad72 commit 41d9467
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test_edx_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,35 @@ def mock_get_page_contents_as_json(u, h):
expected = '0\n00:00:00,123 --> 00:00:00,456\nsubtitle content\n\n'
actual = edx_dl.edx_get_subtitle(url, headers, mock_get_page_contents, mock_get_page_contents_as_json)
assert expected == actual


def test_extract_subtitle_urls():
text = """
<li class="video-tracks video-download-button">
<a href="/courses/Engineering/QMSE02./Winter2016/xblock/i4x:;_;_Engineering;_QMSE02.;_video;_1a4c7ff41e484a15927987b745a5c779/handler/transcript/download">Download transcript</a>
<div class="a11y-menu-container">
<a class="a11y-menu-button" href="#" title=".srt" role="button" aria-disabled="false">.srt</a>
<ol class="a11y-menu-list" role="menu">
<li class="a11y-menu-item active">
<a class="a11y-menu-item-link" href="#srt" title="SubRip (.srt) file" data-value="srt" role="menuitem" aria-disabled="false">
SubRip (.srt) file
</a>
</li>
<li class="a11y-menu-item">
<a class="a11y-menu-item-link" href="#txt" title="Text (.txt) file" data-value="txt" role="menuitem" aria-disabled="false">
Text (.txt) file
</a>
</li>
</ol>
</div>
</li>
"""

page_extractor = parsing.CurrentEdXPageExtractor()
expected = (None, 'https://base.url/courses/Engineering/QMSE02./Winter2016/xblock/i4x:;_;_Engineering;_QMSE02.;_video;_1a4c7ff41e484a15927987b745a5c779/handler/transcript/download')
actual = page_extractor.extract_subtitle_urls(text, "https://base.url")
print("actual", actual)
assert expected == actual

0 comments on commit 41d9467

Please sign in to comment.