From 124cb02f9da0350239ed4e6f9ed97936cd9a5ab7 Mon Sep 17 00:00:00 2001 From: Raymond Zhou <56318341+rayzhou-bit@users.noreply.github.com> Date: Wed, 22 Jan 2025 07:43:16 -0500 Subject: [PATCH] optimizer studio url tests (#36130) --- .../contentstore/tests/test_tasks.py | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/cms/djangoapps/contentstore/tests/test_tasks.py b/cms/djangoapps/contentstore/tests/test_tasks.py index f9e9e138cf23..8cc59d856fce 100644 --- a/cms/djangoapps/contentstore/tests/test_tasks.py +++ b/cms/djangoapps/contentstore/tests/test_tasks.py @@ -28,6 +28,7 @@ rerun_course, _convert_to_standard_url, _check_broken_links, + _is_studio_url, _scan_course_for_links ) from cms.djangoapps.contentstore.tests.test_libraries import LibraryTestCase @@ -288,11 +289,23 @@ def test_hash_tags_stripped_from_url_lists(self): def test_urls_out_count_equals_urls_in_count_when_no_hashtags(self): raise NotImplementedError - def test_http_and_https_recognized_as_studio_url_schemes(self): - raise NotImplementedError + def test_http_url_not_recognized_as_studio_url_scheme(self): + self.assertFalse(_is_studio_url(f'http://www.google.com')) - def test_file_not_recognized_as_studio_url_scheme(self): - raise NotImplementedError + def test_https_url_not_recognized_as_studio_url_scheme(self): + self.assertFalse(_is_studio_url(f'https://www.google.com')) + + def test_http_with_studio_base_url_recognized_as_studio_url_scheme(self): + self.assertTrue(_is_studio_url(f'http://{settings.CMS_BASE}/testurl')) + + def test_https_with_studio_base_url_recognized_as_studio_url_scheme(self): + self.assertTrue(_is_studio_url(f'https://{settings.CMS_BASE}/testurl')) + + def test_container_url_without_url_base_is_recognized_as_studio_url_scheme(self): + self.assertTrue(_is_studio_url(f'container/test')) + + def test_slash_url_without_url_base_is_recognized_as_studio_url_scheme(self): + self.assertTrue(_is_studio_url(f'/static/test')) @pytest.mark.parametrize("url, course_key, post_substitution_url", ["/static/anything_goes_here?raw", "1", "2"])