Commit a7e1f9ca by Kelketek

Merge pull request #7301 from open-craft/course-import-page-fix

Replace broken logic in import template with working logic in view.
parents 41cab6d4 8c920b46
...@@ -304,6 +304,7 @@ def _import_handler(request, courselike_key, root_name, successful_url, context_ ...@@ -304,6 +304,7 @@ def _import_handler(request, courselike_key, root_name, successful_url, context_
context_name: courselike_module, context_name: courselike_module,
'successful_import_redirect_url': successful_url, 'successful_import_redirect_url': successful_url,
'import_status_url': status_url, 'import_status_url': status_url,
'library': isinstance(courselike_key, LibraryLocator)
}) })
else: else:
return HttpResponseNotFound() return HttpResponseNotFound()
......
...@@ -4,10 +4,6 @@ ...@@ -4,10 +4,6 @@
<%! <%!
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
import json import json
try:
library = True
except NameError:
library = False
%> %>
<%block name="title"> <%block name="title">
%if library: %if library:
......
...@@ -10,6 +10,19 @@ from .course_page import CoursePage ...@@ -10,6 +10,19 @@ from .course_page import CoursePage
from . import BASE_URL from . import BASE_URL
class TemplateCheckMixin(object):
"""
Mixin for verifying that a template is loading the correct text.
"""
@property
def header_text(self):
"""
Get the header text of the page.
"""
# There are prefixes like 'Tools' and '>', but the text itself is not in a span.
return self.q(css='h1.page-header')[0].text.split('\n')[-1]
class ExportMixin(object): class ExportMixin(object):
""" """
Export page Mixin. Export page Mixin.
...@@ -86,13 +99,13 @@ class LibraryLoader(object): ...@@ -86,13 +99,13 @@ class LibraryLoader(object):
return "/".join([BASE_URL, self.url_path, unicode(self.locator)]) return "/".join([BASE_URL, self.url_path, unicode(self.locator)])
class ExportCoursePage(ExportMixin, CoursePage): class ExportCoursePage(ExportMixin, TemplateCheckMixin, CoursePage):
""" """
Export page for Courses Export page for Courses
""" """
class ExportLibraryPage(ExportMixin, LibraryLoader, LibraryPage): class ExportLibraryPage(ExportMixin, TemplateCheckMixin, LibraryLoader, LibraryPage):
""" """
Export page for Libraries Export page for Libraries
""" """
...@@ -226,13 +239,13 @@ class ImportMixin(object): ...@@ -226,13 +239,13 @@ class ImportMixin(object):
return self.q(css='.action.action-primary')[0].get_attribute('href') return self.q(css='.action.action-primary')[0].get_attribute('href')
class ImportCoursePage(ImportMixin, CoursePage): class ImportCoursePage(ImportMixin, TemplateCheckMixin, CoursePage):
""" """
Import page for Courses Import page for Courses
""" """
class ImportLibraryPage(ImportMixin, LibraryLoader, LibraryPage): class ImportLibraryPage(ImportMixin, TemplateCheckMixin, LibraryLoader, LibraryPage):
""" """
Import page for Libraries Import page for Libraries
""" """
...@@ -41,6 +41,15 @@ class TestCourseExport(ExportTestMixin, StudioCourseTest): ...@@ -41,6 +41,15 @@ class TestCourseExport(ExportTestMixin, StudioCourseTest):
) )
self.export_page.visit() self.export_page.visit()
def test_header(self):
"""
Scenario: I should see the correct text when exporting a course.
Given that I have a course to export from
When I visit the export page
The correct header should be shown
"""
self.assertEqual(self.export_page.header_text, 'Course Export')
class TestLibraryExport(ExportTestMixin, StudioLibraryTest): class TestLibraryExport(ExportTestMixin, StudioLibraryTest):
""" """
...@@ -54,6 +63,15 @@ class TestLibraryExport(ExportTestMixin, StudioLibraryTest): ...@@ -54,6 +63,15 @@ class TestLibraryExport(ExportTestMixin, StudioLibraryTest):
self.export_page = ExportLibraryPage(self.browser, self.library_key) self.export_page = ExportLibraryPage(self.browser, self.library_key)
self.export_page.visit() self.export_page.visit()
def test_header(self):
"""
Scenario: I should see the correct text when exporting a library.
Given that I have a library to export from
When I visit the export page
The correct header should be shown
"""
self.assertEqual(self.export_page.header_text, 'Library Export')
# pylint: disable=no-member # pylint: disable=no-member
class BadExportMixin(object): class BadExportMixin(object):
...@@ -243,6 +261,15 @@ class TestCourseImport(ImportTestMixin, StudioCourseTest): ...@@ -243,6 +261,15 @@ class TestCourseImport(ImportTestMixin, StudioCourseTest):
# There's a section named 'Section' in the tarball. # There's a section named 'Section' in the tarball.
self.landing_page.section("Section") self.landing_page.section("Section")
def test_header(self):
"""
Scenario: I should see the correct text when importing a course.
Given that I have a course to import to
When I visit the import page
The correct header should be shown
"""
self.assertEqual(self.import_page.header_text, 'Course Import')
class TestLibraryImport(ImportTestMixin, StudioLibraryTest): class TestLibraryImport(ImportTestMixin, StudioLibraryTest):
""" """
...@@ -276,3 +303,12 @@ class TestLibraryImport(ImportTestMixin, StudioLibraryTest): ...@@ -276,3 +303,12 @@ class TestLibraryImport(ImportTestMixin, StudioLibraryTest):
self.landing_page.wait_until_ready() self.landing_page.wait_until_ready()
# There are three blocks in the tarball. # There are three blocks in the tarball.
self.assertEqual(len(self.landing_page.xblocks), 3) self.assertEqual(len(self.landing_page.xblocks), 3)
def test_header(self):
"""
Scenario: I should see the correct text when importing a library.
Given that I have a library to import to
When I visit the import page
The correct header should be shown
"""
self.assertEqual(self.import_page.header_text, 'Library Import')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment