|
3 | 3 | """
|
4 | 4 |
|
5 | 5 |
|
6 |
| -import json |
7 |
| - |
8 | 6 | import ddt
|
9 | 7 | from django.conf import settings
|
10 | 8 | from django.urls import reverse
|
11 | 9 |
|
12 |
| -from cms.djangoapps.contentstore.management.commands.utils import get_course_versions |
13 | 10 | from common.djangoapps.student.tests.factories import AdminFactory, UserFactory
|
14 | 11 | from openedx.features.announcements.models import Announcement
|
15 |
| -from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order |
16 | 12 | from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order
|
17 |
| -from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order |
18 | 13 |
|
19 |
| -from .views import COURSE_KEY_ERROR_MESSAGES, MAINTENANCE_VIEWS |
| 14 | +from .views import MAINTENANCE_VIEWS |
20 | 15 |
|
21 | 16 | # This list contains URLs of all maintenance app views.
|
22 | 17 | MAINTENANCE_URLS = [reverse(view['url']) for view in MAINTENANCE_VIEWS.values()]
|
@@ -122,118 +117,6 @@ def test_non_global_staff_access(self, url):
|
122 | 117 | )
|
123 | 118 |
|
124 | 119 |
|
125 |
| -@ddt.ddt |
126 |
| -class TestForcePublish(MaintenanceViewTestCase): |
127 |
| - """ |
128 |
| - Tests for the force publish view. |
129 |
| - """ |
130 |
| - |
131 |
| - def setUp(self): |
132 |
| - super().setUp() |
133 |
| - self.view_url = reverse('maintenance:force_publish_course') |
134 |
| - |
135 |
| - def setup_test_course(self): |
136 |
| - """ |
137 |
| - Creates the course and add some changes to it. |
138 |
| -
|
139 |
| - Returns: |
140 |
| - course: a course object |
141 |
| - """ |
142 |
| - course = CourseFactory.create() |
143 |
| - # Add some changes to course |
144 |
| - chapter = BlockFactory.create(category='chapter', parent_location=course.location) |
145 |
| - self.store.create_child( |
146 |
| - self.user.id, |
147 |
| - chapter.location, |
148 |
| - 'html', |
149 |
| - block_id='html_component' |
150 |
| - ) |
151 |
| - # verify that course has changes. |
152 |
| - self.assertTrue(self.store.has_changes(self.store.get_item(course.location))) |
153 |
| - return course |
154 |
| - |
155 |
| - @ddt.data( |
156 |
| - ('', COURSE_KEY_ERROR_MESSAGES['empty_course_key']), |
157 |
| - ('edx', COURSE_KEY_ERROR_MESSAGES['invalid_course_key']), |
158 |
| - ('course-v1:e+d+X', COURSE_KEY_ERROR_MESSAGES['course_key_not_found']), |
159 |
| - ) |
160 |
| - @ddt.unpack |
161 |
| - def test_invalid_course_key_messages(self, course_key, error_message): |
162 |
| - """ |
163 |
| - Test all error messages for invalid course keys. |
164 |
| - """ |
165 |
| - # validate that course key contains error message |
166 |
| - self.verify_error_message( |
167 |
| - data={'course-id': course_key}, |
168 |
| - error_message=error_message |
169 |
| - ) |
170 |
| - |
171 |
| - def test_already_published(self): |
172 |
| - """ |
173 |
| - Test that when a course is forcefully publish, we get a 'course is already published' message. |
174 |
| - """ |
175 |
| - course = self.setup_test_course() |
176 |
| - |
177 |
| - # publish the course |
178 |
| - source_store = modulestore()._get_modulestore_for_courselike(course.id) # pylint: disable=protected-access |
179 |
| - source_store.force_publish_course(course.id, self.user.id, commit=True) |
180 |
| - |
181 |
| - # now course is published, we should get `already published course` error. |
182 |
| - self.verify_error_message( |
183 |
| - data={'course-id': str(course.id)}, |
184 |
| - error_message='Course is already in published state.' |
185 |
| - ) |
186 |
| - |
187 |
| - def verify_versions_are_different(self, course): |
188 |
| - """ |
189 |
| - Verify draft and published versions point to different locations. |
190 |
| -
|
191 |
| - Arguments: |
192 |
| - course (object): a course object. |
193 |
| - """ |
194 |
| - # get draft and publish branch versions |
195 |
| - versions = get_course_versions(str(course.id)) |
196 |
| - |
197 |
| - # verify that draft and publish point to different versions |
198 |
| - self.assertNotEqual(versions['draft-branch'], versions['published-branch']) |
199 |
| - |
200 |
| - def get_force_publish_course_response(self, course): |
201 |
| - """ |
202 |
| - Get force publish the course response. |
203 |
| -
|
204 |
| - Arguments: |
205 |
| - course (object): a course object. |
206 |
| -
|
207 |
| - Returns: |
208 |
| - response : response from force publish post view. |
209 |
| - """ |
210 |
| - # Verify versions point to different locations initially |
211 |
| - self.verify_versions_are_different(course) |
212 |
| - |
213 |
| - # force publish course view |
214 |
| - data = { |
215 |
| - 'course-id': str(course.id) |
216 |
| - } |
217 |
| - response = self.client.post(self.view_url, data=data, HTTP_X_REQUESTED_WITH='XMLHttpRequest') |
218 |
| - response_data = json.loads(response.content.decode('utf-8')) |
219 |
| - return response_data |
220 |
| - |
221 |
| - def test_force_publish_dry_run(self): |
222 |
| - """ |
223 |
| - Test that dry run does not publishes the course but shows possible outcome if force published is executed. |
224 |
| - """ |
225 |
| - course = self.setup_test_course() |
226 |
| - response = self.get_force_publish_course_response(course) |
227 |
| - |
228 |
| - self.assertIn('current_versions', response) |
229 |
| - |
230 |
| - # verify that course still has changes as we just dry ran force publish course. |
231 |
| - self.assertTrue(self.store.has_changes(self.store.get_item(course.location))) |
232 |
| - |
233 |
| - # verify that both branch versions are still different |
234 |
| - self.verify_versions_are_different(course) |
235 |
| - |
236 |
| - |
237 | 120 | @ddt.ddt
|
238 | 121 | class TestAnnouncementsViews(MaintenanceViewTestCase):
|
239 | 122 | """
|
|
0 commit comments