Fixed multiple textbooks links to only last uploaded textbook.

TNL-1304
This commit is contained in:
Waheed Ahmed
2015-02-02 19:25:24 +05:00
parent 6ce7f96f16
commit e868db2e4d
4 changed files with 126 additions and 5 deletions

View File

@@ -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.

View File

@@ -496,6 +496,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.