示例#1
0
    def setUp(self):
        """
        Initialize pages and install a course fixture.
        """
        super(HighLevelTabTest, self).setUp()

        # self.course_info['number'] must be shorter since we are accessing the wiki. See TNL-1751
        self.course_info['number'] = self.unique_id[0:6]

        self.course_home_page = CourseHomePage(self.browser, self.course_id)
        self.progress_page = ProgressPage(self.browser, self.course_id)
        self.courseware_page = CoursewarePage(self.browser, self.course_id)
        self.tab_nav = TabNavPage(self.browser)
        self.video = VideoPage(self.browser)

        # Install a course with sections/problems, tabs, updates, and handouts
        course_fix = CourseFixture(self.course_info['org'],
                                   self.course_info['number'],
                                   self.course_info['run'],
                                   self.course_info['display_name'])

        course_fix.add_update(
            CourseUpdateDesc(date='January 29, 2014',
                             content='Test course update1'))

        course_fix.add_handout('demoPDF.pdf')

        course_fix.add_children(
            XBlockFixtureDesc('static_tab',
                              'Test Static Tab',
                              data=r"static tab data with mathjax \(E=mc^2\)"),
            XBlockFixtureDesc('chapter', 'Test Section').add_children(
                XBlockFixtureDesc(
                    'sequential', 'Test Subsection').add_children(
                        XBlockFixtureDesc(
                            'problem',
                            'Test Problem 1',
                            data=load_data_str('multiple_choice.xml')),
                        XBlockFixtureDesc(
                            'problem',
                            'Test Problem 2',
                            data=load_data_str('formula_problem.xml')),
                        XBlockFixtureDesc('html', 'Test HTML'),
                    )),
            XBlockFixtureDesc('chapter', 'Test Section 2').add_children(
                XBlockFixtureDesc('sequential', 'Test Subsection 2'),
                XBlockFixtureDesc(
                    'sequential', 'Test Subsection 3').add_children(
                        XBlockFixtureDesc(
                            'problem',
                            'Test Problem A',
                            data=load_data_str('multiple_choice.xml'))),
            )).install()

        # Auto-auth register for the course
        AutoAuthPage(self.browser, course_id=self.course_id).visit()
示例#2
0
    def setUp(self):
        super(CertificateProgressPageTest, self).setUp()

        # set same course number as we have in fixture json
        self.course_info['number'] = "3355358979513794782079645765720179311111"

        test_certificate_config = {
            'id': 1,
            'name': 'Certificate name',
            'description': 'Certificate description',
            'course_title': 'Course title override',
            'signatories': [],
            'version': 1,
            'is_active': True
        }
        course_settings = {'certificates': test_certificate_config}

        self.course_fixture = CourseFixture(
            self.course_info["org"],
            self.course_info["number"],
            self.course_info["run"],
            self.course_info["display_name"],
            settings=course_settings
        )

        self.course_fixture.add_advanced_settings({
            "cert_html_view_enabled": {"value": "true"}
        })

        self.course_fixture.add_update(
            CourseUpdateDesc(date='January 29, 2014', content='Test course update1')
        )

        self.course_fixture.add_children(
            XBlockFixtureDesc('static_tab', 'Test Static Tab'),
            XBlockFixtureDesc('chapter', 'Test Section').add_children(
                XBlockFixtureDesc('sequential', 'Test Subsection', grader_type='Final Exam').add_children(
                    XBlockFixtureDesc('problem', 'Test Problem 1', data=load_data_str('multiple_choice.xml')),
                    XBlockFixtureDesc('html', 'Test HTML'),
                )
            ),
            XBlockFixtureDesc('chapter', 'Test Section 2').add_children(
                XBlockFixtureDesc('sequential', 'Test Subsection 2', grader_type='Midterm Exam').add_children(
                    XBlockFixtureDesc('problem', 'Test Problem 2', data=load_data_str('formula_problem.xml')),
                )
            )
        )

        self.course_fixture.install()
        self.user_id = "99"  # we have created a user with this id in fixture
        self.cert_fixture = CertificateConfigFixture(self.course_id, test_certificate_config)

        self.course_info_page = CourseInfoPage(self.browser, self.course_id)
        self.progress_page = ProgressPage(self.browser, self.course_id)
        self.course_nav = CourseNavPage(self.browser)
        self.tab_nav = TabNavPage(self.browser)
示例#3
0
 def setUp(self):
     super(TestLTIConusmer, self).setUp()
     self.courseware_page = CoursewarePage(self.browser, self.course_id)
     self.lti_iframe = LTIContentIframe(self.browser, self.course_id)
     self.tab_nav = TabNavPage(self.browser)
     self.progress_page = ProgressPage(self.browser, self.course_id)
     self.instructor_dashboard_page = InstructorDashboardPage(self.browser, self.course_id)
     self.grade_book_page = GradeBookPage(self.browser)
     # Install a course
     display_name = "Test Course" + self.unique_id
     self.course_fix = CourseFixture(
         self.course_info['org'], self.course_info['number'],
         self.course_info['run'], display_name=display_name
     )
    def setUp(self):
        super(CertificateProgressPageTest, self).setUp()

        # set same course number as we have in fixture json
        self.course_info['number'] = "3355358979513794782079645765720179311111"

        test_certificate_config = {
            'id': 1,
            'name': 'Certificate name',
            'description': 'Certificate description',
            'course_title': 'Course title override',
            'signatories': [],
            'version': 1,
            'is_active': True
        }
        course_settings = {'certificates': test_certificate_config}

        self.course_fixture = CourseFixture(
            self.course_info["org"],
            self.course_info["number"],
            self.course_info["run"],
            self.course_info["display_name"],
            settings=course_settings
        )

        self.course_fixture.add_advanced_settings({
            "cert_html_view_enabled": {"value": "true"},
            "certificates_show_before_end": {"value": "true"}
        })

        self.course_fixture.add_update(
            CourseUpdateDesc(date='January 29, 2014', content='Test course update1')
        )

        self.course_fixture.add_children(
            XBlockFixtureDesc('static_tab', 'Test Static Tab'),
            XBlockFixtureDesc('chapter', 'Test Section').add_children(
                XBlockFixtureDesc('sequential', 'Test Subsection', grader_type='Final Exam').add_children(
                    XBlockFixtureDesc('problem', 'Test Problem 1', data=load_data_str('multiple_choice.xml')),
                    XBlockFixtureDesc('html', 'Test HTML'),
                )
            ),
            XBlockFixtureDesc('chapter', 'Test Section 2').add_children(
                XBlockFixtureDesc('sequential', 'Test Subsection 2', grader_type='Midterm Exam').add_children(
                    XBlockFixtureDesc('problem', 'Test Problem 2', data=load_data_str('formula_problem.xml')),
                )
            )
        )

        self.course_fixture.install()
        self.user_id = "99"  # we have created a user with this id in fixture
        self.cert_fixture = CertificateConfigFixture(self.course_id, test_certificate_config)

        self.course_info_page = CourseInfoPage(self.browser, self.course_id)
        self.progress_page = ProgressPage(self.browser, self.course_id)
        self.courseware_page = CoursewarePage(self.browser, self.course_id)
        self.course_home_page = CourseHomePage(self.browser, self.course_id)
        self.tab_nav = TabNavPage(self.browser)
    def setUp(self):
        super(CertificateProgressPageTest, self).setUp()

        # set same course number as we have in fixture json
        self.course_info["number"] = "3355358979513794782079645765720179311111"

        test_certificate_config = {
            "id": 1,
            "name": "Certificate name",
            "description": "Certificate description",
            "course_title": "Course title override",
            "signatories": [],
            "version": 1,
            "is_active": True,
        }
        course_settings = {"certificates": test_certificate_config}

        self.course_fixture = CourseFixture(
            self.course_info["org"],
            self.course_info["number"],
            self.course_info["run"],
            self.course_info["display_name"],
            settings=course_settings,
        )

        self.course_fixture.add_advanced_settings({"cert_html_view_enabled": {"value": "true"}})

        self.course_fixture.add_update(CourseUpdateDesc(date="January 29, 2014", content="Test course update1"))

        self.course_fixture.add_children(
            XBlockFixtureDesc("static_tab", "Test Static Tab"),
            XBlockFixtureDesc("chapter", "Test Section").add_children(
                XBlockFixtureDesc("sequential", "Test Subsection", grader_type="Final Exam").add_children(
                    XBlockFixtureDesc("problem", "Test Problem 1", data=load_data_str("multiple_choice.xml")),
                    XBlockFixtureDesc("html", "Test HTML"),
                )
            ),
            XBlockFixtureDesc("chapter", "Test Section 2").add_children(
                XBlockFixtureDesc("sequential", "Test Subsection 2", grader_type="Midterm Exam").add_children(
                    XBlockFixtureDesc("problem", "Test Problem 2", data=load_data_str("formula_problem.xml"))
                )
            ),
        )

        self.course_fixture.install()
        self.user_id = "99"  # we have created a user with this id in fixture
        self.cert_fixture = CertificateConfigFixture(self.course_id, test_certificate_config)

        self.course_info_page = CourseInfoPage(self.browser, self.course_id)
        self.progress_page = ProgressPage(self.browser, self.course_id)
        self.course_nav = CourseNavPage(self.browser)
        self.tab_nav = TabNavPage(self.browser)
示例#6
0
 def setUp(self):
     super(TestLTIConusmer, self).setUp()
     self.courseware_page = CoursewarePage(self.browser, self.course_id)
     self.lti_iframe = LTIContentIframe(self.browser, self.course_id)
     self.tab_nav = TabNavPage(self.browser)
     self.progress_page = ProgressPage(self.browser, self.course_id)
     self.instructor_dashboard_page = InstructorDashboardPage(self.browser, self.course_id)
     self.grade_book_page = GradeBookPage(self.browser)
     # Install a course
     display_name = "Test Course" + self.unique_id
     self.course_fix = CourseFixture(
         self.course_info['org'], self.course_info['number'],
         self.course_info['run'], display_name=display_name
     )
示例#7
0
    def setUp(self):
        """
        Initialize pages and install a course fixture.
        """
        super(HighLevelTabTest, self).setUp()

        # self.course_info['number'] must be shorter since we are accessing the wiki. See TNL-1751
        self.course_info['number'] = self.unique_id[0:6]

        self.course_home_page = CourseHomePage(self.browser, self.course_id)
        self.progress_page = ProgressPage(self.browser, self.course_id)
        self.courseware_page = CoursewarePage(self.browser, self.course_id)
        self.tab_nav = TabNavPage(self.browser)
        self.video = VideoPage(self.browser)

        # Install a course with sections/problems, tabs, updates, and handouts
        course_fix = CourseFixture(
            self.course_info['org'], self.course_info['number'],
            self.course_info['run'], self.course_info['display_name']
        )

        course_fix.add_update(
            CourseUpdateDesc(date='January 29, 2014', content='Test course update1')
        )

        course_fix.add_handout('demoPDF.pdf')

        course_fix.add_children(
            XBlockFixtureDesc('static_tab', 'Test Static Tab', data=r"static tab data with mathjax \(E=mc^2\)"),
            XBlockFixtureDesc('chapter', 'Test Section').add_children(
                XBlockFixtureDesc('sequential', 'Test Subsection').add_children(
                    XBlockFixtureDesc('problem', 'Test Problem 1', data=load_data_str('multiple_choice.xml')),
                    XBlockFixtureDesc('problem', 'Test Problem 2', data=load_data_str('formula_problem.xml')),
                    XBlockFixtureDesc('html', 'Test HTML'),
                )
            ),
            XBlockFixtureDesc('chapter', 'Test Section 2').add_children(
                XBlockFixtureDesc('sequential', 'Test Subsection 2'),
                XBlockFixtureDesc('sequential', 'Test Subsection 3').add_children(
                    XBlockFixtureDesc('problem', 'Test Problem A', data=load_data_str('multiple_choice.xml'))
                ),
            )
        ).install()

        # Auto-auth register for the course
        AutoAuthPage(self.browser, course_id=self.course_id).visit()
示例#8
0
 def test_visit_progress_page(self):
     """
     Produce a HAR for loading the Progress page.
     """
     progress_page = ProgressPage(self.browser, self.course_id)
     self._make_har_file(progress_page)
示例#9
0
class HighLevelTabTest(UniqueCourseTest):
    """
    Tests that verify each of the high-level tabs available within a course.
    """
    def setUp(self):
        """
        Initialize pages and install a course fixture.
        """
        super(HighLevelTabTest, self).setUp()

        # self.course_info['number'] must be shorter since we are accessing the wiki. See TNL-1751
        self.course_info['number'] = self.unique_id[0:6]

        self.course_home_page = CourseHomePage(self.browser, self.course_id)
        self.progress_page = ProgressPage(self.browser, self.course_id)
        self.courseware_page = CoursewarePage(self.browser, self.course_id)
        self.tab_nav = TabNavPage(self.browser)
        self.video = VideoPage(self.browser)

        # Install a course with sections/problems, tabs, updates, and handouts
        course_fix = CourseFixture(self.course_info['org'],
                                   self.course_info['number'],
                                   self.course_info['run'],
                                   self.course_info['display_name'])

        course_fix.add_update(
            CourseUpdateDesc(date='January 29, 2014',
                             content='Test course update1'))

        course_fix.add_handout('demoPDF.pdf')

        course_fix.add_children(
            XBlockFixtureDesc('static_tab',
                              'Test Static Tab',
                              data=r"static tab data with mathjax \(E=mc^2\)"),
            XBlockFixtureDesc('chapter', 'Test Section').add_children(
                XBlockFixtureDesc(
                    'sequential', 'Test Subsection').add_children(
                        XBlockFixtureDesc(
                            'problem',
                            'Test Problem 1',
                            data=load_data_str('multiple_choice.xml')),
                        XBlockFixtureDesc(
                            'problem',
                            'Test Problem 2',
                            data=load_data_str('formula_problem.xml')),
                        XBlockFixtureDesc('html', 'Test HTML'),
                    )),
            XBlockFixtureDesc('chapter', 'Test Section 2').add_children(
                XBlockFixtureDesc('sequential', 'Test Subsection 2'),
                XBlockFixtureDesc(
                    'sequential', 'Test Subsection 3').add_children(
                        XBlockFixtureDesc(
                            'problem',
                            'Test Problem A',
                            data=load_data_str('multiple_choice.xml'))),
            )).install()

        # Auto-auth register for the course
        AutoAuthPage(self.browser, course_id=self.course_id).visit()

    def test_progress(self):
        """
        Navigate to the progress page.
        """
        # Navigate to the progress page from the info page
        self.course_home_page.visit()
        self.tab_nav.go_to_tab('Progress')

        # We haven't answered any problems yet, so assume scores are zero
        # Only problems should have scores; so there should be 2 scores.
        CHAPTER = 'Test Section'
        SECTION = 'Test Subsection'
        EXPECTED_SCORES = [(0, 3), (0, 1)]

        actual_scores = self.progress_page.scores(CHAPTER, SECTION)
        self.assertEqual(actual_scores, EXPECTED_SCORES)

    def test_static_tab(self):
        """
        Navigate to a static tab (course content)
        """
        # From the course info page, navigate to the static tab
        self.course_home_page.visit()
        self.tab_nav.go_to_tab('Test Static Tab')
        self.assertTrue(self.tab_nav.is_on_tab('Test Static Tab'))

    def test_static_tab_with_mathjax(self):
        """
        Navigate to a static tab (course content)
        """
        # From the course info page, navigate to the static tab
        self.course_home_page.visit()
        self.tab_nav.go_to_tab('Test Static Tab')
        self.assertTrue(self.tab_nav.is_on_tab('Test Static Tab'))

        # Verify that Mathjax has rendered
        self.tab_nav.mathjax_has_rendered()

    def test_wiki_tab_first_time(self):
        """
        Navigate to the course wiki tab. When the wiki is accessed for
        the first time, it is created on the fly.
        """

        course_wiki = CourseWikiPage(self.browser, self.course_id)
        # From the course info page, navigate to the wiki tab
        self.course_home_page.visit()
        self.tab_nav.go_to_tab('Wiki')
        self.assertTrue(self.tab_nav.is_on_tab('Wiki'))

        # Assert that a default wiki is created
        expected_article_name = "{course_name}".format(
            course_name=self.course_info['display_name'])
        self.assertEqual(expected_article_name, course_wiki.article_name)

    def test_course_home_tab(self):
        """
        Navigate to the course home page using the tab.
        """
        self.course_home_page.visit()
        self.tab_nav.go_to_tab('Course')

        # Check that the tab lands on the course home page.
        self.assertTrue(self.course_home_page.is_browser_on_page())
示例#10
0
class HighLevelTabTest(UniqueCourseTest):
    """
    Tests that verify each of the high-level tabs available within a course.
    """

    def setUp(self):
        """
        Initialize pages and install a course fixture.
        """
        super(HighLevelTabTest, self).setUp()

        # self.course_info['number'] must be shorter since we are accessing the wiki. See TNL-1751
        self.course_info['number'] = self.unique_id[0:6]

        self.course_home_page = CourseHomePage(self.browser, self.course_id)
        self.progress_page = ProgressPage(self.browser, self.course_id)
        self.courseware_page = CoursewarePage(self.browser, self.course_id)
        self.tab_nav = TabNavPage(self.browser)
        self.video = VideoPage(self.browser)

        # Install a course with sections/problems, tabs, updates, and handouts
        course_fix = CourseFixture(
            self.course_info['org'], self.course_info['number'],
            self.course_info['run'], self.course_info['display_name']
        )

        course_fix.add_update(
            CourseUpdateDesc(date='January 29, 2014', content='Test course update1')
        )

        course_fix.add_handout('demoPDF.pdf')

        course_fix.add_children(
            XBlockFixtureDesc('static_tab', 'Test Static Tab', data=r"static tab data with mathjax \(E=mc^2\)"),
            XBlockFixtureDesc('chapter', 'Test Section').add_children(
                XBlockFixtureDesc('sequential', 'Test Subsection').add_children(
                    XBlockFixtureDesc('problem', 'Test Problem 1', data=load_data_str('multiple_choice.xml')),
                    XBlockFixtureDesc('problem', 'Test Problem 2', data=load_data_str('formula_problem.xml')),
                    XBlockFixtureDesc('html', 'Test HTML'),
                )
            ),
            XBlockFixtureDesc('chapter', 'Test Section 2').add_children(
                XBlockFixtureDesc('sequential', 'Test Subsection 2'),
                XBlockFixtureDesc('sequential', 'Test Subsection 3').add_children(
                    XBlockFixtureDesc('problem', 'Test Problem A', data=load_data_str('multiple_choice.xml'))
                ),
            )
        ).install()

        # Auto-auth register for the course
        AutoAuthPage(self.browser, course_id=self.course_id).visit()

    def test_progress(self):
        """
        Navigate to the progress page.
        """
        # Navigate to the progress page from the info page
        self.course_home_page.visit()
        self.tab_nav.go_to_tab('Progress')

        # We haven't answered any problems yet, so assume scores are zero
        # Only problems should have scores; so there should be 2 scores.
        CHAPTER = 'Test Section'
        SECTION = 'Test Subsection'
        EXPECTED_SCORES = [(0, 3), (0, 1)]

        actual_scores = self.progress_page.scores(CHAPTER, SECTION)
        self.assertEqual(actual_scores, EXPECTED_SCORES)

    def test_static_tab(self):
        """
        Navigate to a static tab (course content)
        """
        # From the course info page, navigate to the static tab
        self.course_home_page.visit()
        self.tab_nav.go_to_tab('Test Static Tab')
        self.assertTrue(self.tab_nav.is_on_tab('Test Static Tab'))

    def test_static_tab_with_mathjax(self):
        """
        Navigate to a static tab (course content)
        """
        # From the course info page, navigate to the static tab
        self.course_home_page.visit()
        self.tab_nav.go_to_tab('Test Static Tab')
        self.assertTrue(self.tab_nav.is_on_tab('Test Static Tab'))

        # Verify that Mathjax has rendered
        self.tab_nav.mathjax_has_rendered()

    def test_wiki_tab_first_time(self):
        """
        Navigate to the course wiki tab. When the wiki is accessed for
        the first time, it is created on the fly.
        """

        course_wiki = CourseWikiPage(self.browser, self.course_id)
        # From the course info page, navigate to the wiki tab
        self.course_home_page.visit()
        self.tab_nav.go_to_tab('Wiki')
        self.assertTrue(self.tab_nav.is_on_tab('Wiki'))

        # Assert that a default wiki is created
        expected_article_name = "{course_name}".format(
            course_name=self.course_info['display_name']
        )
        self.assertEqual(expected_article_name, course_wiki.article_name)

    def test_course_home_tab(self):
        """
        Navigate to the course home page using the tab.
        """
        self.course_home_page.visit()
        self.tab_nav.go_to_tab('Course')

        # Check that the tab lands on the course home page.
        self.assertTrue(self.course_home_page.is_browser_on_page())
示例#11
0
class TestLTIConusmer(UniqueCourseTest):
    """
    Base class for tests of LTI xblock in the LMS.
    """

    USERNAME = "******"
    EMAIL = "*****@*****.**"
    host = os.environ.get('BOK_CHOY_HOSTNAME', '127.0.0.1')

    def setUp(self):
        super(TestLTIConusmer, self).setUp()
        self.courseware_page = CoursewarePage(self.browser, self.course_id)
        self.lti_iframe = LTIContentIframe(self.browser, self.course_id)
        self.tab_nav = TabNavPage(self.browser)
        self.progress_page = ProgressPage(self.browser, self.course_id)
        self.instructor_dashboard_page = InstructorDashboardPage(
            self.browser, self.course_id)
        self.grade_book_page = GradeBookPage(self.browser)
        # Install a course
        display_name = "Test Course" + self.unique_id
        self.course_fix = CourseFixture(self.course_info['org'],
                                        self.course_info['number'],
                                        self.course_info['run'],
                                        display_name=display_name)

    def test_lti_no_launch_url_is_not_rendered(self):
        """
        Scenario: LTI component in LMS with no launch_url is not rendered
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with no_launch_url fields:
            Then I view the LTI and error is shown
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {'launch_url': '', 'open_in_a_new_page': False}
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True,
                  self.course_id)
        self.courseware_page.visit()
        self.assertTrue(self.courseware_page.is_error_message_present())
        self.assertFalse(self.courseware_page.is_iframe_present())
        self.assertFalse(self.courseware_page.is_launch_url_present())

    def test_incorrect_lti_id_is_rendered_incorrectly(self):
        """
        Scenario: LTI component in LMS with incorrect lti_id is rendered incorrectly
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with incorrect_lti_id fields:
            Then I view the LTI but incorrect_signature warning is rendered
        """
        metadata_advance_settings = "test_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id':
            'incorrect_lti_id',
            'launch_url':
            'http://{}:{}/{}'.format(self.host, '8765',
                                     'correct_lti_endpoint'),
            'open_in_a_new_page':
            False
        }
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True,
                  self.course_id)
        self.courseware_page.visit()
        self.assertTrue(self.courseware_page.is_iframe_present())
        self.assertFalse(self.courseware_page.is_launch_url_present())
        self.assertFalse(self.courseware_page.is_error_message_present())
        self.courseware_page.go_to_lti_container()
        self.assertEqual("Wrong LTI signature", self.lti_iframe.lti_content)

    def test_incorrect_lti_credentials_is_rendered_incorrectly(self):
        """
        Scenario: LTI component in LMS with icorrect LTI credentials is rendered incorrectly
        Given the course has incorrect LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            I view the LTI but incorrect_signature warning is rendered
        """
        metadata_advance_settings = "test_lti_id:test_client_key:incorrect_lti_secret_key"
        metadata_lti_xblock = {
            'lti_id':
            'correct_lti_id',
            'launch_url':
            'http://{}:{}/{}'.format(self.host, '8765',
                                     'correct_lti_endpoint'),
            'open_in_a_new_page':
            False
        }
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True,
                  self.course_id)
        self.courseware_page.visit()
        self.assertTrue(self.courseware_page.is_iframe_present())
        self.assertFalse(self.courseware_page.is_launch_url_present())
        self.assertFalse(self.courseware_page.is_error_message_present())
        self.courseware_page.go_to_lti_container()
        self.assertEqual("Wrong LTI signature", self.lti_iframe.lti_content)

    def test_lti_is_rendered_in_iframe_correctly(self):
        """
        Scenario: LTI component in LMS is correctly rendered in iframe
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            I view the LTI and it is rendered in iframe correctly
        """

        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id':
            'correct_lti_id',
            'launch_url':
            'http://{}:{}/{}'.format(self.host, '8765',
                                     'correct_lti_endpoint'),
            'open_in_a_new_page':
            False
        }

        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True,
                  self.course_id)
        self.courseware_page.visit()
        self.assertTrue(self.courseware_page.is_iframe_present())
        self.assertFalse(self.courseware_page.is_launch_url_present())
        self.assertFalse(self.courseware_page.is_error_message_present())
        self.courseware_page.go_to_lti_container()
        self.assertEqual("This is LTI tool. Success.",
                         self.lti_iframe.lti_content)

    def test_lti_graded_component_for_staff(self):
        """
        Scenario: Graded LTI component in LMS is correctly works for staff
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            verify scores on progress and grade book pages.
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id':
            'correct_lti_id',
            'launch_url':
            'http://{}:{}/{}'.format(self.host, '8765',
                                     'correct_lti_endpoint'),
            'open_in_a_new_page':
            False,
            'weight':
            10,
            'graded':
            True,
            'has_score':
            True
        }
        expected_scores = [(5, 10)]
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True,
                  self.course_id)
        self.courseware_page.visit()
        self.courseware_page.go_to_lti_container()
        self.lti_iframe.submit_lti_answer('#submit-button')
        self.assertIn("LTI consumer (edX) responded with XML content",
                      self.lti_iframe.lti_content)
        self.lti_iframe.switch_to_default()
        self.tab_nav.go_to_tab('Progress')
        actual_scores = self.progress_page.scores("Test Chapter",
                                                  "Test Section")
        self.assertEqual(actual_scores, expected_scores)
        self.assertEqual(['Overall Score', 'Overall Score\n1%'],
                         self.progress_page.graph_overall_score())
        self.tab_nav.go_to_tab('Instructor')
        student_admin_section = self.instructor_dashboard_page.select_student_admin(
            StudentAdminPage)
        student_admin_section.click_grade_book_link()
        self.assertEqual(
            "50",
            self.grade_book_page.get_value_in_the_grade_book(
                'Homework 1 - Test Section', 1))
        self.assertEqual(
            "1", self.grade_book_page.get_value_in_the_grade_book('Total', 1))

    def test_lti_switch_role_works_correctly(self):
        """
        Scenario: Graded LTI component in LMS role's masquerading correctly works
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            switch role from instructor to learner and verify that it works correctly
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id':
            'correct_lti_id',
            'launch_url':
            'http://{}:{}/{}'.format(self.host, '8765',
                                     'correct_lti_endpoint'),
            'open_in_a_new_page':
            False,
            'has_score':
            True
        }
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True,
                  self.course_id)
        self.courseware_page.visit()
        self.assertTrue(self.courseware_page.is_iframe_present())
        self.assertFalse(self.courseware_page.is_launch_url_present())
        self.assertFalse(self.courseware_page.is_error_message_present())
        self.courseware_page.go_to_lti_container()
        self.assertEqual("This is LTI tool. Success.",
                         self.lti_iframe.lti_content)
        self.assertEqual("Role: Instructor", self.lti_iframe.get_user_role)
        self.lti_iframe.switch_to_default()
        select_option_by_text(self.courseware_page.get_role_selector,
                              'Learner')
        self.courseware_page.wait_for_ajax()
        self.assertTrue(self.courseware_page.is_iframe_present())
        self.assertFalse(self.courseware_page.is_launch_url_present())
        self.assertFalse(self.courseware_page.is_error_message_present())
        self.courseware_page.go_to_lti_container()
        self.assertEqual("This is LTI tool. Success.",
                         self.lti_iframe.lti_content)
        self.assertEqual("Role: Student", self.lti_iframe.get_user_role)

    def test_lti_graded_component_for_learner(self):
        """
        Scenario: Graded LTI component in LMS is correctly works for learners
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            verify scores on progress
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id':
            'correct_lti_id',
            'launch_url':
            'http://{}:{}/{}'.format(self.host, '8765',
                                     'correct_lti_endpoint'),
            'open_in_a_new_page':
            False,
            'weight':
            10,
            'graded':
            True,
            'has_score':
            True
        }
        expected_scores = [(5, 10)]
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, False,
                  self.course_id)
        self.courseware_page.visit()
        self.courseware_page.go_to_lti_container()
        self.lti_iframe.submit_lti_answer('#submit-button')
        self.assertIn("LTI consumer (edX) responded with XML content",
                      self.lti_iframe.lti_content)
        self.lti_iframe.switch_to_default()
        self.tab_nav.go_to_tab('Progress')
        actual_scores = self.progress_page.scores("Test Chapter",
                                                  "Test Section")
        self.assertEqual(actual_scores, expected_scores)
        self.assertEqual(['Overall Score', 'Overall Score\n1%'],
                         self.progress_page.graph_overall_score())

    def test_lti_v2_callback_graded_component(self):
        """
        Scenario: Graded LTI component in LMS is correctly works with LTI2v0 PUT callback
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            verify scores on progress and grade book pages.
            verify feedback in LTI component.
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id':
            'correct_lti_id',
            'launch_url':
            'http://{}:{}/{}'.format(self.host, '8765',
                                     'correct_lti_endpoint'),
            'open_in_a_new_page':
            False,
            'weight':
            10,
            'graded':
            True,
            'has_score':
            True
        }
        expected_scores = [(8, 10)]
        problem_score = '(8.0 / 10.0 points)'
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True,
                  self.course_id)
        self.courseware_page.visit()
        self.courseware_page.go_to_lti_container()
        self.lti_iframe.submit_lti_answer("#submit-lti2-button")
        self.assertIn("LTI consumer (edX) responded with HTTP 200",
                      self.lti_iframe.lti_content)
        self.lti_iframe.switch_to_default()
        self.tab_nav.go_to_tab('Progress')
        actual_scores = self.progress_page.scores("Test Chapter",
                                                  "Test Section")
        self.assertEqual(actual_scores, expected_scores)
        self.assertEqual(['Overall Score', 'Overall Score\n1%'],
                         self.progress_page.graph_overall_score())
        self.tab_nav.go_to_tab('Instructor')
        student_admin_section = self.instructor_dashboard_page.select_student_admin(
            StudentAdminPage)
        student_admin_section.click_grade_book_link()
        self.assertEqual(
            "80",
            self.grade_book_page.get_value_in_the_grade_book(
                'Homework 1 - Test Section', 1))
        self.assertEqual(
            "1", self.grade_book_page.get_value_in_the_grade_book('Total', 1))
        self.tab_nav.go_to_tab('Course')
        self.assertEqual(
            problem_score,
            self.courseware_page.get_elem_text('.problem-progress'))
        self.assertEqual(
            "This is awesome.",
            self.courseware_page.get_elem_text('.problem-feedback'))

    def test_lti_delete_callback_graded_component(self):
        """
        Scenario: Graded LTI component in LMS is correctly works with LTI2v0 PUT delete callback
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            Verify LTI provider deletes my grade on progress and grade book page
            verify LTI provider deletes feedback from LTI Component
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id':
            'correct_lti_id',
            'launch_url':
            'http://{}:{}/{}'.format(self.host, '8765',
                                     'correct_lti_endpoint'),
            'open_in_a_new_page':
            False,
            'weight':
            10,
            'graded':
            True,
            'has_score':
            True
        }
        expected_scores = [(0, 10)]
        problem_score = '(8.0 / 10.0 points)'
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True,
                  self.course_id)
        self.courseware_page.visit()
        self.courseware_page.go_to_lti_container()
        self.lti_iframe.submit_lti_answer("#submit-lti2-button")
        self.assertIn("LTI consumer (edX) responded with HTTP 200",
                      self.lti_iframe.lti_content)
        self.lti_iframe.switch_to_default()
        self.courseware_page.visit()
        self.assertEqual(
            problem_score,
            self.courseware_page.get_elem_text('.problem-progress'))
        self.assertEqual(
            "This is awesome.",
            self.courseware_page.get_elem_text('.problem-feedback'))
        self.courseware_page.go_to_lti_container()
        self.lti_iframe.submit_lti_answer("#submit-lti-delete-button")
        self.courseware_page.visit()
        self.assertEqual(
            "(10.0 points possible)",
            self.courseware_page.get_elem_text('.problem-progress'))
        self.assertFalse(
            self.courseware_page.is_lti_component_present('.problem-feedback'))
        self.tab_nav.go_to_tab('Progress')
        actual_scores = self.progress_page.scores("Test Chapter",
                                                  "Test Section")
        self.assertEqual(actual_scores, expected_scores)
        self.assertEqual(['Overall Score', 'Overall Score\n0%'],
                         self.progress_page.graph_overall_score())
        self.tab_nav.go_to_tab('Instructor')
        student_admin_section = self.instructor_dashboard_page.select_student_admin(
            StudentAdminPage)
        student_admin_section.click_grade_book_link()
        self.assertEqual(
            "0",
            self.grade_book_page.get_value_in_the_grade_book(
                'Homework 1 - Test Section', 1))
        self.assertEqual(
            "0", self.grade_book_page.get_value_in_the_grade_book('Total', 1))

    def test_lti_hide_launch_shows_no_button(self):
        """
        Scenario: LTI component that set to hide_launch and open_in_a_new_page shows no button
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            verify LTI component don't show launch button with text "LTI (External resource)"
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id':
            'correct_lti_id',
            'launch_url':
            'http://{}:{}/{}'.format(self.host, '8765',
                                     'correct_lti_endpoint'),
            'open_in_a_new_page':
            False,
            'hide_launch':
            True
        }
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True,
                  self.course_id)
        self.courseware_page.visit()
        self.assertFalse(
            self.courseware_page.is_lti_component_present(
                '.link_lti_new_window'))
        self.assertEqual("LTI (External resource)",
                         self.courseware_page.get_elem_text('.problem-header'))

    def test_lti_hide_launch_shows_no_iframe(self):
        """
        Scenario: LTI component that set to hide_launch and not open_in_a_new_page shows no iframe
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            verify LTI component don't show LTI iframe with text "LTI (External resource)"
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id':
            'correct_lti_id',
            'launch_url':
            'http://{}:{}/{}'.format(self.host, '8765',
                                     'correct_lti_endpoint'),
            'open_in_a_new_page':
            True,
            'hide_launch':
            True
        }
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True,
                  self.course_id)
        self.courseware_page.visit()
        self.assertFalse(
            self.courseware_page.is_lti_component_present('.ltiLaunchFrame'))
        self.assertEqual("LTI (External resource)",
                         self.courseware_page.get_elem_text('.problem-header'))

    def test_lti_button_text_correctly_displayed(self):
        """
        Scenario: LTI component button text is correctly displayed
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            verify LTI component button with text "Launch Application"
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id':
            'correct_lti_id',
            'launch_url':
            'http://{}:{}/{}'.format(self.host, '8765',
                                     'correct_lti_endpoint'),
            'button_text':
            'Launch Application'
        }
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True,
                  self.course_id)
        self.courseware_page.visit()
        self.assertEqual(
            "Launch Application",
            self.courseware_page.get_elem_text('.link_lti_new_window'))

    def test_lti_component_description_correctly_displayed(self):
        """
        Scenario: LTI component description is correctly displayed
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            LTI component description with text "Application description"
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id':
            'correct_lti_id',
            'launch_url':
            'http://{}:{}/{}'.format(self.host, '8765',
                                     'correct_lti_endpoint'),
            'description':
            'Application description'
        }
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True,
                  self.course_id)
        self.courseware_page.visit()
        self.assertEqual(
            "Application description",
            self.courseware_page.get_elem_text('.lti-description'))

    def set_advance_settings(self, metadata_advance_settings):

        # Set value against advanced modules in advanced settings
        self.course_fix.add_advanced_settings({
            "advanced_modules": {
                "value": ["lti_consumer"]
            },
            'lti_passports': {
                "value": [metadata_advance_settings]
            }
        })

    def create_lti_xblock(self, metadata_lti_xblock):
        self.course_fix.add_children(
            XBlockFixtureDesc(
                category='chapter', display_name='Test Chapter').add_children(
                    XBlockFixtureDesc(category='sequential',
                                      display_name='Test Section',
                                      grader_type='Homework',
                                      graded=True).add_children(
                                          XBlockFixtureDesc(
                                              category='lti',
                                              display_name='LTI',
                                              metadata=metadata_lti_xblock).
                                          add_children()))).install()
class CertificateProgressPageTest(UniqueCourseTest):
    """
    Tests for verifying Certificate info on Progress tab of course page.
    """
    def setUp(self):
        super(CertificateProgressPageTest, self).setUp()

        # set same course number as we have in fixture json
        self.course_info['number'] = "3355358979513794782079645765720179311111"

        test_certificate_config = {
            'id': 1,
            'name': 'Certificate name',
            'description': 'Certificate description',
            'course_title': 'Course title override',
            'signatories': [],
            'version': 1,
            'is_active': True
        }
        course_settings = {'certificates': test_certificate_config}

        self.course_fixture = CourseFixture(self.course_info["org"],
                                            self.course_info["number"],
                                            self.course_info["run"],
                                            self.course_info["display_name"],
                                            settings=course_settings)

        self.course_fixture.add_advanced_settings({
            "cert_html_view_enabled": {
                "value": "true"
            },
            "certificates_show_before_end": {
                "value": "true"
            }
        })

        self.course_fixture.add_update(
            CourseUpdateDesc(date='January 29, 2014',
                             content='Test course update1'))

        self.course_fixture.add_children(
            XBlockFixtureDesc('static_tab', 'Test Static Tab'),
            XBlockFixtureDesc('chapter', 'Test Section').add_children(
                XBlockFixtureDesc(
                    'sequential', 'Test Subsection',
                    grader_type='Final Exam').add_children(
                        XBlockFixtureDesc(
                            'problem',
                            'Test Problem 1',
                            data=load_data_str('multiple_choice.xml')),
                        XBlockFixtureDesc('html', 'Test HTML'),
                    )),
            XBlockFixtureDesc('chapter', 'Test Section 2').add_children(
                XBlockFixtureDesc(
                    'sequential',
                    'Test Subsection 2',
                    grader_type='Midterm Exam').add_children(
                        XBlockFixtureDesc(
                            'problem',
                            'Test Problem 2',
                            data=load_data_str('formula_problem.xml')), )))

        self.course_fixture.install()
        self.user_id = "99"  # we have created a user with this id in fixture
        self.cert_fixture = CertificateConfigFixture(self.course_id,
                                                     test_certificate_config)

        self.progress_page = ProgressPage(self.browser, self.course_id)
        self.courseware_page = CoursewarePage(self.browser, self.course_id)
        self.course_home_page = CourseHomePage(self.browser, self.course_id)
        self.tab_nav = TabNavPage(self.browser)

    def log_in_as_unique_user(self):
        """
        Log in as a valid lms user.
        """
        AutoAuthPage(self.browser,
                     username="******",
                     email="*****@*****.**",
                     password="******",
                     course_id=self.course_id).visit()

    def test_progress_page_has_view_certificate_button(self):
        """
        Scenario: View Certificate option should be present on Course Progress menu if the user is
        awarded a certificate.
        And there should be no padding around the box containing certificate info. (See SOL-1196 for details on this)

        As a Student
        Given there is a course with certificate configuration
        And I have passed the course and certificate is generated
        When I go on the Progress tab for the course
        Then I should see a 'View Certificate' button
        And their should be no padding around Certificate info box.
        """
        self.cert_fixture.install()
        self.log_in_as_unique_user()

        self.complete_course_problems()

        self.course_home_page.visit()
        self.tab_nav.go_to_tab('Progress')

        self.assertTrue(
            self.progress_page.q(css='.auto-cert-message').first.visible)

        actual_padding = get_element_padding(self.progress_page,
                                             '.wrapper-msg.wrapper-auto-cert')
        actual_padding = [
            int(padding) for padding in actual_padding.itervalues()
        ]
        expected_padding = [0, 0, 0, 0]

        # Verify that their is no padding around the box containing certificate info.
        self.assertEqual(actual_padding, expected_padding)

    def complete_course_problems(self):
        """
        Complete Course Problems.

        Problems were added in the setUp
        """
        self.course_home_page.visit()

        # Navigate to Test Subsection in Test Section Section
        self.course_home_page.outline.go_to_section('Test Section',
                                                    'Test Subsection')

        # Navigate to Test Problem 1
        self.courseware_page.nav.go_to_vertical('Test Problem 1')

        # Select correct value for from select menu
        self.courseware_page.q(
            css='select option[value="{}"]'.format('blue')).first.click()

        # Select correct radio button for the answer
        self.courseware_page.q(
            css='fieldset div.field:nth-child(4) input').nth(0).click()

        # Select correct radio buttons for the answer
        self.courseware_page.q(
            css='fieldset div.field:nth-child(2) input').nth(1).click()
        self.courseware_page.q(
            css='fieldset div.field:nth-child(4) input').nth(1).click()

        # Submit the answer
        self.courseware_page.q(css='button.submit').click()
        self.courseware_page.wait_for_ajax()

        # Navigate to the 'Test Subsection 2' of 'Test Section 2'
        self.course_home_page.visit()
        self.course_home_page.outline.go_to_section('Test Section 2',
                                                    'Test Subsection 2')

        # Navigate to Test Problem 2
        self.courseware_page.nav.go_to_vertical('Test Problem 2')

        # Fill in the answer of the problem
        self.courseware_page.q(
            css='input[id^=input_][id$=_2_1]').fill('A*x^2 + sqrt(y)')

        # Submit the answer
        self.courseware_page.q(css='button.submit').click()
        self.courseware_page.wait_for_ajax()
class CertificateProgressPageTest(UniqueCourseTest):
    """
    Tests for verifying Certificate info on Progress tab of course page.
    """

    def setUp(self):
        super(CertificateProgressPageTest, self).setUp()

        # set same course number as we have in fixture json
        self.course_info["number"] = "3355358979513794782079645765720179311111"

        test_certificate_config = {
            "id": 1,
            "name": "Certificate name",
            "description": "Certificate description",
            "course_title": "Course title override",
            "signatories": [],
            "version": 1,
            "is_active": True,
        }
        course_settings = {"certificates": test_certificate_config}

        self.course_fixture = CourseFixture(
            self.course_info["org"],
            self.course_info["number"],
            self.course_info["run"],
            self.course_info["display_name"],
            settings=course_settings,
        )

        self.course_fixture.add_advanced_settings({"cert_html_view_enabled": {"value": "true"}})

        self.course_fixture.add_update(CourseUpdateDesc(date="January 29, 2014", content="Test course update1"))

        self.course_fixture.add_children(
            XBlockFixtureDesc("static_tab", "Test Static Tab"),
            XBlockFixtureDesc("chapter", "Test Section").add_children(
                XBlockFixtureDesc("sequential", "Test Subsection", grader_type="Final Exam").add_children(
                    XBlockFixtureDesc("problem", "Test Problem 1", data=load_data_str("multiple_choice.xml")),
                    XBlockFixtureDesc("html", "Test HTML"),
                )
            ),
            XBlockFixtureDesc("chapter", "Test Section 2").add_children(
                XBlockFixtureDesc("sequential", "Test Subsection 2", grader_type="Midterm Exam").add_children(
                    XBlockFixtureDesc("problem", "Test Problem 2", data=load_data_str("formula_problem.xml"))
                )
            ),
        )

        self.course_fixture.install()
        self.user_id = "99"  # we have created a user with this id in fixture
        self.cert_fixture = CertificateConfigFixture(self.course_id, test_certificate_config)

        self.course_info_page = CourseInfoPage(self.browser, self.course_id)
        self.progress_page = ProgressPage(self.browser, self.course_id)
        self.course_nav = CourseNavPage(self.browser)
        self.tab_nav = TabNavPage(self.browser)

    def log_in_as_unique_user(self):
        """
        Log in as a valid lms user.
        """
        AutoAuthPage(
            self.browser,
            username="******",
            email="*****@*****.**",
            password="******",
            course_id=self.course_id,
        ).visit()

    def test_progress_page_has_view_certificate_button(self):
        """
        Scenario: View Certificate option should be present on Course Progress menu if the user is
        awarded a certificate.
        And their should be no padding around the box containing certificate info. (See SOL-1196 for details on this)

        As a Student
        Given there is a course with certificate configuration
        And I have passed the course and certificate is generated
        When I go on the Progress tab for the course
        Then I should see a 'View Certificate' button
        And their should be no padding around Certificate info box.
        """
        self.cert_fixture.install()
        self.log_in_as_unique_user()

        self.complete_course_problems()

        self.course_info_page.visit()
        self.tab_nav.go_to_tab("Progress")

        self.assertTrue(self.progress_page.q(css=".auto-cert-message").first.visible)

        actual_padding = get_element_padding(self.progress_page, ".wrapper-msg.wrapper-auto-cert")
        actual_padding = [int(padding) for padding in actual_padding.itervalues()]
        expected_padding = [0, 0, 0, 0]

        # Verify that their is no padding around the box containing certificate info.
        self.assertEqual(actual_padding, expected_padding)

    def complete_course_problems(self):
        """
        Complete Course Problems.

        Problems were added in the setUp
        """
        self.course_info_page.visit()
        self.tab_nav.go_to_tab("Course")

        # Navigate to Test Subsection in Test Section Section
        self.course_nav.go_to_section("Test Section", "Test Subsection")

        # Navigate to Test Problem 1
        self.course_nav.go_to_vertical("Test Problem 1")

        # Select correct value for from select menu
        self.course_nav.q(css='select option[value="{}"]'.format("blue")).first.click()

        # Select correct radio button for the answer
        self.course_nav.q(css="fieldset div.field:nth-child(3) input").nth(0).click()

        # Select correct radio buttons for the answer
        self.course_nav.q(css="fieldset div.field:nth-child(1) input").nth(1).click()
        self.course_nav.q(css="fieldset div.field:nth-child(3) input").nth(1).click()

        # Submit the answer
        self.course_nav.q(css="button.check.Check").click()
        self.course_nav.wait_for_ajax()

        # Navigate to the 'Test Subsection 2' of 'Test Section 2'
        self.course_nav.go_to_section("Test Section 2", "Test Subsection 2")

        # Navigate to Test Problem 2
        self.course_nav.go_to_vertical("Test Problem 2")

        # Fill in the answer of the problem
        self.course_nav.q(css="input[id^=input_][id$=_2_1]").fill("A*x^2 + sqrt(y)")

        # Submit the answer
        self.course_nav.q(css="button.check.Check").click()
        self.course_nav.wait_for_ajax()
示例#14
0
class TestLTIConusmer(UniqueCourseTest):
    """
    Base class for tests of LTI xblock in the LMS.
    """

    USERNAME = "******"
    EMAIL = "*****@*****.**"
    host = os.environ.get('BOK_CHOY_HOSTNAME', '127.0.0.1')

    def setUp(self):
        super(TestLTIConusmer, self).setUp()
        self.courseware_page = CoursewarePage(self.browser, self.course_id)
        self.lti_iframe = LTIContentIframe(self.browser, self.course_id)
        self.tab_nav = TabNavPage(self.browser)
        self.progress_page = ProgressPage(self.browser, self.course_id)
        self.instructor_dashboard_page = InstructorDashboardPage(self.browser, self.course_id)
        self.grade_book_page = GradeBookPage(self.browser)
        # Install a course
        display_name = "Test Course" + self.unique_id
        self.course_fix = CourseFixture(
            self.course_info['org'], self.course_info['number'],
            self.course_info['run'], display_name=display_name
        )

    def test_lti_no_launch_url_is_not_rendered(self):
        """
        Scenario: LTI component in LMS with no launch_url is not rendered
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with no_launch_url fields:
            Then I view the LTI and error is shown
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'launch_url': '',
            'open_in_a_new_page': False
        }
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True, self.course_id)
        self.courseware_page.visit()
        self.assertTrue(self.courseware_page.is_error_message_present())
        self.assertFalse(self.courseware_page.is_iframe_present())
        self.assertFalse(self.courseware_page.is_launch_url_present())

    def test_incorrect_lti_id_is_rendered_incorrectly(self):
        """
        Scenario: LTI component in LMS with incorrect lti_id is rendered incorrectly
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with incorrect_lti_id fields:
            Then I view the LTI but incorrect_signature warning is rendered
        """
        metadata_advance_settings = "test_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id': 'incorrect_lti_id',
            'launch_url': 'http://{}:{}/{}'.format(self.host, '8765', 'correct_lti_endpoint'),
            'open_in_a_new_page': False
        }
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True, self.course_id)
        self.courseware_page.visit()
        self.assertTrue(self.courseware_page.is_iframe_present())
        self.assertFalse(self.courseware_page.is_launch_url_present())
        self.assertFalse(self.courseware_page.is_error_message_present())
        self.courseware_page.go_to_lti_container()
        self.assertEqual("Wrong LTI signature", self.lti_iframe.lti_content)

    def test_incorrect_lti_credentials_is_rendered_incorrectly(self):
        """
        Scenario: LTI component in LMS with icorrect LTI credentials is rendered incorrectly
        Given the course has incorrect LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            I view the LTI but incorrect_signature warning is rendered
        """
        metadata_advance_settings = "test_lti_id:test_client_key:incorrect_lti_secret_key"
        metadata_lti_xblock = {
            'lti_id': 'correct_lti_id',
            'launch_url': 'http://{}:{}/{}'.format(self.host, '8765', 'correct_lti_endpoint'),
            'open_in_a_new_page': False
        }
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True, self.course_id)
        self.courseware_page.visit()
        self.assertTrue(self.courseware_page.is_iframe_present())
        self.assertFalse(self.courseware_page.is_launch_url_present())
        self.assertFalse(self.courseware_page.is_error_message_present())
        self.courseware_page.go_to_lti_container()
        self.assertEqual("Wrong LTI signature", self.lti_iframe.lti_content)

    def test_lti_is_rendered_in_iframe_correctly(self):
        """
        Scenario: LTI component in LMS is correctly rendered in iframe
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            I view the LTI and it is rendered in iframe correctly
        """

        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id': 'correct_lti_id',
            'launch_url': 'http://{}:{}/{}'.format(self.host, '8765', 'correct_lti_endpoint'),
            'open_in_a_new_page': False
        }

        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True, self.course_id)
        self.courseware_page.visit()
        self.assertTrue(self.courseware_page.is_iframe_present())
        self.assertFalse(self.courseware_page.is_launch_url_present())
        self.assertFalse(self.courseware_page.is_error_message_present())
        self.courseware_page.go_to_lti_container()
        self.assertEqual("This is LTI tool. Success.", self.lti_iframe.lti_content)

    def test_lti_graded_component_for_staff(self):
        """
        Scenario: Graded LTI component in LMS is correctly works for staff
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            verify scores on progress and grade book pages.
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id': 'correct_lti_id',
            'launch_url': 'http://{}:{}/{}'.format(self.host, '8765', 'correct_lti_endpoint'),
            'open_in_a_new_page': False,
            'weight': 10,
            'graded': True,
            'has_score': True
        }
        expected_scores = [(5, 10)]
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True, self.course_id)
        self.courseware_page.visit()
        self.courseware_page.go_to_lti_container()
        self.lti_iframe.submit_lti_answer('#submit-button')
        self.assertIn("LTI consumer (edX) responded with XML content", self.lti_iframe.lti_content)
        self.lti_iframe.switch_to_default()
        self.tab_nav.go_to_tab('Progress')
        actual_scores = self.progress_page.scores("Test Chapter", "Test Section")
        self.assertEqual(actual_scores, expected_scores)
        self.assertEqual(['Overall Score', 'Overall Score\n1%'], self.progress_page.graph_overall_score())
        self.tab_nav.go_to_tab('Instructor')
        student_admin_section = self.instructor_dashboard_page.select_student_admin(StudentAdminPage)
        student_admin_section.click_grade_book_link()
        self.assertEqual("50", self.grade_book_page.get_value_in_the_grade_book('Homework 1 - Test Section', 1))
        self.assertEqual("1", self.grade_book_page.get_value_in_the_grade_book('Total', 1))

    def test_lti_switch_role_works_correctly(self):
        """
        Scenario: Graded LTI component in LMS role's masquerading correctly works
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            switch role from instructor to learner and verify that it works correctly
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id': 'correct_lti_id',
            'launch_url': 'http://{}:{}/{}'.format(self.host, '8765', 'correct_lti_endpoint'),
            'open_in_a_new_page': False,
            'has_score': True
        }
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True, self.course_id)
        self.courseware_page.visit()
        self.assertTrue(self.courseware_page.is_iframe_present())
        self.assertFalse(self.courseware_page.is_launch_url_present())
        self.assertFalse(self.courseware_page.is_error_message_present())
        self.courseware_page.go_to_lti_container()
        self.assertEqual("This is LTI tool. Success.", self.lti_iframe.lti_content)
        self.assertEqual("Role: Instructor", self.lti_iframe.get_user_role)
        self.lti_iframe.switch_to_default()
        select_option_by_text(self.courseware_page.get_role_selector, 'Learner')
        self.courseware_page.wait_for_ajax()
        self.assertTrue(self.courseware_page.is_iframe_present())
        self.assertFalse(self.courseware_page.is_launch_url_present())
        self.assertFalse(self.courseware_page.is_error_message_present())
        self.courseware_page.go_to_lti_container()
        self.assertEqual("This is LTI tool. Success.", self.lti_iframe.lti_content)
        self.assertEqual("Role: Student", self.lti_iframe.get_user_role)

    def test_lti_graded_component_for_learner(self):
        """
        Scenario: Graded LTI component in LMS is correctly works for learners
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            verify scores on progress
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id': 'correct_lti_id',
            'launch_url': 'http://{}:{}/{}'.format(self.host, '8765', 'correct_lti_endpoint'),
            'open_in_a_new_page': False,
            'weight': 10,
            'graded': True,
            'has_score': True
        }
        expected_scores = [(5, 10)]
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, False, self.course_id)
        self.courseware_page.visit()
        self.courseware_page.go_to_lti_container()
        self.lti_iframe.submit_lti_answer('#submit-button')
        self.assertIn("LTI consumer (edX) responded with XML content", self.lti_iframe.lti_content)
        self.lti_iframe.switch_to_default()
        self.tab_nav.go_to_tab('Progress')
        actual_scores = self.progress_page.scores("Test Chapter", "Test Section")
        self.assertEqual(actual_scores, expected_scores)
        self.assertEqual(['Overall Score', 'Overall Score\n1%'], self.progress_page.graph_overall_score())

    def test_lti_v2_callback_graded_component(self):
        """
        Scenario: Graded LTI component in LMS is correctly works with LTI2v0 PUT callback
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            verify scores on progress and grade book pages.
            verify feedback in LTI component.
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id': 'correct_lti_id',
            'launch_url': 'http://{}:{}/{}'.format(self.host, '8765', 'correct_lti_endpoint'),
            'open_in_a_new_page': False,
            'weight': 10,
            'graded': True,
            'has_score': True
        }
        expected_scores = [(8, 10)]
        problem_score = '(8.0 / 10.0 points)'
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True, self.course_id)
        self.courseware_page.visit()
        self.courseware_page.go_to_lti_container()
        self.lti_iframe.submit_lti_answer("#submit-lti2-button")
        self.assertIn("LTI consumer (edX) responded with HTTP 200", self.lti_iframe.lti_content)
        self.lti_iframe.switch_to_default()
        self.tab_nav.go_to_tab('Progress')
        actual_scores = self.progress_page.scores("Test Chapter", "Test Section")
        self.assertEqual(actual_scores, expected_scores)
        self.assertEqual(['Overall Score', 'Overall Score\n1%'], self.progress_page.graph_overall_score())
        self.tab_nav.go_to_tab('Instructor')
        student_admin_section = self.instructor_dashboard_page.select_student_admin(StudentAdminPage)
        student_admin_section.click_grade_book_link()
        self.assertEqual("80", self.grade_book_page.get_value_in_the_grade_book('Homework 1 - Test Section', 1))
        self.assertEqual("1", self.grade_book_page.get_value_in_the_grade_book('Total', 1))
        self.tab_nav.go_to_tab('Course')
        self.assertEqual(problem_score, self.courseware_page.get_elem_text('.problem-progress'))
        self.assertEqual("This is awesome.", self.courseware_page.get_elem_text('.problem-feedback'))

    def test_lti_delete_callback_graded_component(self):
        """
        Scenario: Graded LTI component in LMS is correctly works with LTI2v0 PUT delete callback
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            Verify LTI provider deletes my grade on progress and grade book page
            verify LTI provider deletes feedback from LTI Component
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id': 'correct_lti_id',
            'launch_url': 'http://{}:{}/{}'.format(self.host, '8765', 'correct_lti_endpoint'),
            'open_in_a_new_page': False,
            'weight': 10,
            'graded': True,
            'has_score': True
        }
        expected_scores = [(0, 10)]
        problem_score = '(8.0 / 10.0 points)'
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True, self.course_id)
        self.courseware_page.visit()
        self.courseware_page.go_to_lti_container()
        self.lti_iframe.submit_lti_answer("#submit-lti2-button")
        self.assertIn("LTI consumer (edX) responded with HTTP 200", self.lti_iframe.lti_content)
        self.lti_iframe.switch_to_default()
        self.courseware_page.visit()
        self.assertEqual(problem_score, self.courseware_page.get_elem_text('.problem-progress'))
        self.assertEqual("This is awesome.", self.courseware_page.get_elem_text('.problem-feedback'))
        self.courseware_page.go_to_lti_container()
        self.lti_iframe.submit_lti_answer("#submit-lti-delete-button")
        self.courseware_page.visit()
        self.assertEqual("(10.0 points possible)", self.courseware_page.get_elem_text('.problem-progress'))
        self.assertFalse(self.courseware_page.is_lti_component_present('.problem-feedback'))
        self.tab_nav.go_to_tab('Progress')
        actual_scores = self.progress_page.scores("Test Chapter", "Test Section")
        self.assertEqual(actual_scores, expected_scores)
        self.assertEqual(['Overall Score', 'Overall Score\n0%'], self.progress_page.graph_overall_score())
        self.tab_nav.go_to_tab('Instructor')
        student_admin_section = self.instructor_dashboard_page.select_student_admin(StudentAdminPage)
        student_admin_section.click_grade_book_link()
        self.assertEqual("0", self.grade_book_page.get_value_in_the_grade_book('Homework 1 - Test Section', 1))
        self.assertEqual("0", self.grade_book_page.get_value_in_the_grade_book('Total', 1))

    def test_lti_hide_launch_shows_no_button(self):
        """
        Scenario: LTI component that set to hide_launch and open_in_a_new_page shows no button
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            verify LTI component don't show launch button with text "LTI (External resource)"
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id': 'correct_lti_id',
            'launch_url': 'http://{}:{}/{}'.format(self.host, '8765', 'correct_lti_endpoint'),
            'open_in_a_new_page': False,
            'hide_launch': True
        }
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True, self.course_id)
        self.courseware_page.visit()
        self.assertFalse(self.courseware_page.is_lti_component_present('.link_lti_new_window'))
        self.assertEqual("LTI (External resource)", self.courseware_page.get_elem_text('.problem-header'))

    def test_lti_hide_launch_shows_no_iframe(self):
        """
        Scenario: LTI component that set to hide_launch and not open_in_a_new_page shows no iframe
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            verify LTI component don't show LTI iframe with text "LTI (External resource)"
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id': 'correct_lti_id',
            'launch_url': 'http://{}:{}/{}'.format(self.host, '8765', 'correct_lti_endpoint'),
            'open_in_a_new_page': True,
            'hide_launch': True
        }
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True, self.course_id)
        self.courseware_page.visit()
        self.assertFalse(self.courseware_page.is_lti_component_present('.ltiLaunchFrame'))
        self.assertEqual("LTI (External resource)", self.courseware_page.get_elem_text('.problem-header'))

    def test_lti_button_text_correctly_displayed(self):
        """
        Scenario: LTI component button text is correctly displayed
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            verify LTI component button with text "Launch Application"
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id': 'correct_lti_id',
            'launch_url': 'http://{}:{}/{}'.format(self.host, '8765', 'correct_lti_endpoint'),
            'button_text': 'Launch Application'
        }
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True, self.course_id)
        self.courseware_page.visit()
        self.assertEqual("Launch Application", self.courseware_page.get_elem_text('.link_lti_new_window'))

    def test_lti_component_description_correctly_displayed(self):
        """
        Scenario: LTI component description is correctly displayed
        Given the course has correct LTI credentials with registered Instructor
            the course has an LTI component with correct fields:
            LTI component description with text "Application description"
        """
        metadata_advance_settings = "correct_lti_id:test_client_key:test_client_secret"
        metadata_lti_xblock = {
            'lti_id': 'correct_lti_id',
            'launch_url': 'http://{}:{}/{}'.format(self.host, '8765', 'correct_lti_endpoint'),
            'description': 'Application description'
        }
        self.set_advance_settings(metadata_advance_settings)
        self.create_lti_xblock(metadata_lti_xblock)
        auto_auth(self.browser, self.USERNAME, self.EMAIL, True, self.course_id)
        self.courseware_page.visit()
        self.assertEqual("Application description", self.courseware_page.get_elem_text('.lti-description'))

    def set_advance_settings(self, metadata_advance_settings):

        # Set value against advanced modules in advanced settings
        self.course_fix.add_advanced_settings({
            "advanced_modules": {"value": ["lti_consumer"]},
            'lti_passports': {"value": [metadata_advance_settings]}
        })

    def create_lti_xblock(self, metadata_lti_xblock):
        self.course_fix.add_children(
            XBlockFixtureDesc(category='chapter', display_name='Test Chapter').add_children(
                XBlockFixtureDesc(
                    category='sequential', display_name='Test Section', grader_type='Homework', graded=True
                ).add_children(
                    XBlockFixtureDesc(category='lti', display_name='LTI', metadata=metadata_lti_xblock).add_children(
                    )
                )
            )
        ).install()
class CertificateProgressPageTest(UniqueCourseTest):
    """
    Tests for verifying Certificate info on Progress tab of course page.
    """

    def setUp(self):
        super(CertificateProgressPageTest, self).setUp()

        # set same course number as we have in fixture json
        self.course_info['number'] = "3355358979513794782079645765720179311111"

        test_certificate_config = {
            'id': 1,
            'name': 'Certificate name',
            'description': 'Certificate description',
            'course_title': 'Course title override',
            'signatories': [],
            'version': 1,
            'is_active': True
        }
        course_settings = {'certificates': test_certificate_config}

        self.course_fixture = CourseFixture(
            self.course_info["org"],
            self.course_info["number"],
            self.course_info["run"],
            self.course_info["display_name"],
            settings=course_settings
        )

        self.course_fixture.add_advanced_settings({
            "cert_html_view_enabled": {"value": "true"},
            "certificates_show_before_end": {"value": "true"}
        })

        self.course_fixture.add_update(
            CourseUpdateDesc(date='January 29, 2014', content='Test course update1')
        )

        self.course_fixture.add_children(
            XBlockFixtureDesc('static_tab', 'Test Static Tab'),
            XBlockFixtureDesc('chapter', 'Test Section').add_children(
                XBlockFixtureDesc('sequential', 'Test Subsection', grader_type='Final Exam').add_children(
                    XBlockFixtureDesc('problem', 'Test Problem 1', data=load_data_str('multiple_choice.xml')),
                    XBlockFixtureDesc('html', 'Test HTML'),
                )
            ),
            XBlockFixtureDesc('chapter', 'Test Section 2').add_children(
                XBlockFixtureDesc('sequential', 'Test Subsection 2', grader_type='Midterm Exam').add_children(
                    XBlockFixtureDesc('problem', 'Test Problem 2', data=load_data_str('formula_problem.xml')),
                )
            )
        )

        self.course_fixture.install()
        self.user_id = "99"  # we have created a user with this id in fixture
        self.cert_fixture = CertificateConfigFixture(self.course_id, test_certificate_config)

        self.progress_page = ProgressPage(self.browser, self.course_id)
        self.courseware_page = CoursewarePage(self.browser, self.course_id)
        self.course_home_page = CourseHomePage(self.browser, self.course_id)
        self.tab_nav = TabNavPage(self.browser)

    def log_in_as_unique_user(self):
        """
        Log in as a valid lms user.
        """
        AutoAuthPage(
            self.browser,
            username="******",
            email="*****@*****.**",
            password="******",
            course_id=self.course_id
        ).visit()

    def test_progress_page_has_view_certificate_button(self):
        """
        Scenario: View Certificate option should be present on Course Progress menu if the user is
        awarded a certificate.
        And there should be no padding around the box containing certificate info. (See SOL-1196 for details on this)

        As a Student
        Given there is a course with certificate configuration
        And I have passed the course and certificate is generated
        When I go on the Progress tab for the course
        Then I should see a 'View Certificate' button
        And their should be no padding around Certificate info box.
        """
        self.cert_fixture.install()
        self.log_in_as_unique_user()

        self.complete_course_problems()

        self.course_home_page.visit()
        self.tab_nav.go_to_tab('Progress')

        self.assertTrue(self.progress_page.q(css='.auto-cert-message').first.visible)

        actual_padding = get_element_padding(self.progress_page, '.wrapper-msg.wrapper-auto-cert')
        actual_padding = [int(padding) for padding in actual_padding.itervalues()]
        expected_padding = [0, 0, 0, 0]

        # Verify that their is no padding around the box containing certificate info.
        self.assertEqual(actual_padding, expected_padding)

    def complete_course_problems(self):
        """
        Complete Course Problems.

        Problems were added in the setUp
        """
        self.course_home_page.visit()

        # Navigate to Test Subsection in Test Section Section
        self.course_home_page.outline.go_to_section('Test Section', 'Test Subsection')

        # Navigate to Test Problem 1
        self.courseware_page.nav.go_to_vertical('Test Problem 1')

        # Select correct value for from select menu
        self.courseware_page.q(css='select option[value="{}"]'.format('blue')).first.click()

        # Select correct radio button for the answer
        self.courseware_page.q(css='fieldset div.field:nth-child(4) input').nth(0).click()

        # Select correct radio buttons for the answer
        self.courseware_page.q(css='fieldset div.field:nth-child(2) input').nth(1).click()
        self.courseware_page.q(css='fieldset div.field:nth-child(4) input').nth(1).click()

        # Submit the answer
        self.courseware_page.q(css='button.submit').click()
        self.courseware_page.wait_for_ajax()

        # Navigate to the 'Test Subsection 2' of 'Test Section 2'
        self.course_home_page.visit()
        self.course_home_page.outline.go_to_section('Test Section 2', 'Test Subsection 2')

        # Navigate to Test Problem 2
        self.courseware_page.nav.go_to_vertical('Test Problem 2')

        # Fill in the answer of the problem
        self.courseware_page.q(css='input[id^=input_][id$=_2_1]').fill('A*x^2 + sqrt(y)')

        # Submit the answer
        self.courseware_page.q(css='button.submit').click()
        self.courseware_page.wait_for_ajax()