From 30d219fe717025ecff5f2f502328aaf3544202a8 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 9 Oct 2025 14:47:36 -0400 Subject: [PATCH] test: Switch the contentstore tests to use APIs Since we're trying to drop the underlying page, switch to the equivalent API views for these contentstore tests. --- .../contentstore/tests/test_contentstore.py | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index 8b6aa6d2bb..7862d60f95 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -16,11 +16,11 @@ from unittest import SkipTest, mock from uuid import uuid4 import ddt -import lxml.html from django.conf import settings from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.test import TestCase from django.test.utils import override_settings +from django.urls import reverse from edx_toggles.toggles.testutils import override_waffle_switch, override_waffle_flag from edxval.api import create_video, get_videos_for_course from fs.osfs import OSFS @@ -1388,17 +1388,6 @@ class ContentStoreTest(ContentStoreTestCase): resp = self.client.ajax_post('/course/', self.course_data) self.assertEqual(resp.status_code, 403) - @override_waffle_flag(toggles.LEGACY_STUDIO_HOME, True) - def test_course_index_view_with_no_courses(self): - """Test viewing the index page with no courses""" - resp = self.client.get_html('/home/') - self.assertContains( - resp, - f'

{settings.STUDIO_SHORT_NAME} Home

', - status_code=200, - html=True - ) - def test_course_factory(self): """Test that the course factory works correctly.""" course = CourseFactory.create() @@ -1879,17 +1868,21 @@ class RerunCourseTest(ContentStoreTestCase): """ Asserts that the given course key is NOT in the unsucceeded course action section of the html. """ - with override_waffle_flag(toggles.LEGACY_STUDIO_HOME, True): - course_listing = lxml.html.fromstring(self.client.get_html('/home/').content) - self.assertEqual(len(self.get_unsucceeded_course_action_elements(course_listing, course_key)), 0) + response = self.client.get(reverse('cms.djangoapps.contentstore:v2:courses')) + assert str(course_key) not in [ + course["course_key"] + for course in response.json()["results"]["in_process_course_actions"] + ] def assertInUnsucceededCourseActions(self, course_key): """ Asserts that the given course key is in the unsucceeded course action section of the html. """ - with override_waffle_flag(toggles.LEGACY_STUDIO_HOME, True): - course_listing = lxml.html.fromstring(self.client.get_html('/home/').content) - self.assertEqual(len(self.get_unsucceeded_course_action_elements(course_listing, course_key)), 1) + response = self.client.get(reverse('cms.djangoapps.contentstore:v2:courses')) + assert str(course_key) in [ + course["course_key"] + for course in response.json()["results"]["in_process_course_actions"] + ] def verify_rerun_course(self, source_course_key, destination_course_key, destination_display_name): """