Merge branch 'release'
This commit is contained in:
@@ -558,7 +558,9 @@ class TextbookTabs(TextbookTabsBase):
|
||||
yield SingleTextbookTab(
|
||||
name=textbook.title,
|
||||
tab_id='textbook/{0}'.format(index),
|
||||
link_func=lambda course, reverse_func: reverse_func('book', args=[course.id.to_deprecated_string(), index]),
|
||||
link_func=lambda course, reverse_func, index=index: reverse_func(
|
||||
'book', args=[course.id.to_deprecated_string(), index]
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -578,7 +580,9 @@ class PDFTextbookTabs(TextbookTabsBase):
|
||||
yield SingleTextbookTab(
|
||||
name=textbook['tab_title'],
|
||||
tab_id='pdftextbook/{0}'.format(index),
|
||||
link_func=lambda course, reverse_func: reverse_func('pdf_book', args=[course.id.to_deprecated_string(), index]),
|
||||
link_func=lambda course, reverse_func, index=index: reverse_func(
|
||||
'pdf_book', args=[course.id.to_deprecated_string(), index]
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -598,7 +602,9 @@ class HtmlTextbookTabs(TextbookTabsBase):
|
||||
yield SingleTextbookTab(
|
||||
name=textbook['tab_title'],
|
||||
tab_id='htmltextbook/{0}'.format(index),
|
||||
link_func=lambda course, reverse_func: reverse_func('html_book', args=[course.id.to_deprecated_string(), index]),
|
||||
link_func=lambda course, reverse_func, index=index: reverse_func(
|
||||
'html_book', args=[course.id.to_deprecated_string(), index]
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -137,6 +137,7 @@ class CourseFixture(XBlockContainerFixture):
|
||||
self._updates = []
|
||||
self._handouts = []
|
||||
self._assets = []
|
||||
self._textbooks = []
|
||||
self._advanced_settings = {}
|
||||
self._course_key = None
|
||||
|
||||
@@ -165,6 +166,12 @@ class CourseFixture(XBlockContainerFixture):
|
||||
"""
|
||||
self._assets.extend(asset_name)
|
||||
|
||||
def add_textbook(self, book_title, chapters):
|
||||
"""
|
||||
Add textbook to the list of textbooks to be added when the install method is called.
|
||||
"""
|
||||
self._textbooks.append({"chapters": chapters, "tab_title": book_title})
|
||||
|
||||
def add_advanced_settings(self, settings):
|
||||
"""
|
||||
Adds advanced settings to be set on the course when the install method is called.
|
||||
@@ -181,6 +188,7 @@ class CourseFixture(XBlockContainerFixture):
|
||||
self._create_course()
|
||||
self._install_course_updates()
|
||||
self._install_course_handouts()
|
||||
self._install_course_textbooks()
|
||||
self._configure_course()
|
||||
self._upload_assets()
|
||||
self._add_advanced_settings()
|
||||
@@ -352,6 +360,21 @@ class CourseFixture(XBlockContainerFixture):
|
||||
raise FixtureError('Could not upload {asset_name} with {url}. Status code: {code}'.format(
|
||||
asset_name=asset_name, url=url, code=upload_response.status_code))
|
||||
|
||||
def _install_course_textbooks(self):
|
||||
"""
|
||||
Add textbooks to the course, if any are configured.
|
||||
"""
|
||||
url = STUDIO_BASE_URL + '/textbooks/' + self._course_key
|
||||
|
||||
for book in self._textbooks:
|
||||
payload = json.dumps(book)
|
||||
response = self.session.post(url, headers=self.headers, data=payload)
|
||||
|
||||
if not response.ok:
|
||||
raise FixtureError(
|
||||
"Could not add book to course: {0} with {1}. Status was {2}".format(
|
||||
book, url, response.status_code))
|
||||
|
||||
def _add_advanced_settings(self):
|
||||
"""
|
||||
Add advanced settings.
|
||||
|
||||
@@ -497,6 +497,46 @@ class HighLevelTabTest(UniqueCourseTest):
|
||||
self.assertIn(expected, actual_items)
|
||||
|
||||
|
||||
class PDFTextBooksTabTest(UniqueCourseTest):
|
||||
"""
|
||||
Tests that verify each of the textbook tabs available within a course.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Initialize pages and install a course fixture.
|
||||
"""
|
||||
super(PDFTextBooksTabTest, self).setUp()
|
||||
|
||||
self.course_info_page = CourseInfoPage(self.browser, self.course_id)
|
||||
self.tab_nav = TabNavPage(self.browser)
|
||||
|
||||
# Install a course with TextBooks
|
||||
course_fix = CourseFixture(
|
||||
self.course_info['org'], self.course_info['number'],
|
||||
self.course_info['run'], self.course_info['display_name']
|
||||
)
|
||||
|
||||
# Add PDF textbooks to course fixture.
|
||||
for i in range(1, 3):
|
||||
course_fix.add_textbook("PDF Book {}".format(i), [{"title": "Chapter Of Book {}".format(i), "url": ""}])
|
||||
|
||||
course_fix.install()
|
||||
|
||||
# Auto-auth register for the course
|
||||
AutoAuthPage(self.browser, course_id=self.course_id).visit()
|
||||
|
||||
def test_verify_textbook_tabs(self):
|
||||
"""
|
||||
Test multiple pdf textbooks loads correctly in lms.
|
||||
"""
|
||||
self.course_info_page.visit()
|
||||
|
||||
# Verify each PDF textbook tab by visiting, it will fail if correct tab is not loaded.
|
||||
for i in range(1, 3):
|
||||
self.tab_nav.go_to_tab("PDF Book {}".format(i))
|
||||
|
||||
|
||||
class VideoTest(UniqueCourseTest):
|
||||
"""
|
||||
Navigate to a video in the courseware and play it.
|
||||
|
||||
Reference in New Issue
Block a user