def _test_create_site(self, course_code, course_title, course_short_title,
                          term, expected_course_code):
        """
        Common logic for testing site creation.
        """
        index_page = IndexPageObject(self.driver)
        create_new_ci = CreateCoursePageObject(self.driver)
        canvas_course = CanvasCoursePage(self.driver)
        canvas_settings = CourseSettingsPage(self.driver)

        # Go to Course Site Creator Tool
        self.driver.get(self.TOOL_URL)
        self.acct_admin_dashboard_page.select_create_canvas_site_link()

        # Switch to active frame
        canvas_course.focus_on_tool_frame()

        # Click on to Create new course link from Index page
        index_page.get_new_course_link()

        # Fill form with test data from settings and submit form
        create_new_ci.add_new_course_instance(course_code, course_title,
                                              course_short_title, term)

        # Verify confirmation modal window, if course for term and
        # course code was previously created, click Ok in modal window
        # before checking for success message
        if (create_new_ci.confirm_modal_visible()):
            # Click OK in modal window
            create_new_ci.click_confirmation_modal()

        # Verify course creation was successful
        self.assertTrue(create_new_ci.success_message_visible())

        # Click on the site link, which opens up in a new window
        create_new_ci.go_to_new_canvas_course()

        # Verify that Canvas site has been created
        self.assertTrue(canvas_course.is_loaded())

        # Verify the right Canvas course has been created
        # Click to go to Canvas Site Settings Page
        canvas_course.open_course_settings()
        self.assertTrue(canvas_settings.is_loaded())

        # Get the course code on the Canvas Site
        settings_course_code = canvas_settings.get_course_code()

        # Compare the expected_course_code with actual course code created
        # If a course has course title, the course code is the short title.
        self.assertEqual(
            settings_course_code, expected_course_code,
            "Error: the course code on newly created Canvas site "
            "does not match expected course code")
예제 #2
0
    def _load_bulk_create_tool(self):
        """
        Common code: This method loads up the bulk create tool.
        """
        self.index_page = IndexPageObject(self.driver)
        self.course_selection_page = CourseSelectionPageObject(self.driver)

        # Switch frame after loading up bulk create tool
        self.index_page.focus_on_tool_frame()

        self.assertTrue(self.index_page.is_loaded())
        self.index_page.select_term(self.test_data['term'])
        self.index_page.select_course_group(self.test_data['course_group'])
        self.index_page.create_canvas_sites()
        self.course_selection_page.select_template(self.test_data['template'])
예제 #3
0
    def setUp(self):

        super(AccountAdminBaseTestCase, self).setUp()

        self.test_data = settings.SELENIUM_CONFIG['canvas_site_creator'][
            'test_data']
        self.test_data_course_with_registrar_code_display = settings.SELENIUM_CONFIG[
            'canvas_site_creator']['test_data'][
                'course_with_registrar_code_display']
        self.test_data_course_without_registrar_code_display = settings.SELENIUM_CONFIG[
            'canvas_site_creator']['test_data'][
                'course_without_registrar_code_display']
        self.main_page = IndexPageObject(self.driver)

        # initialize
        if not self.acct_admin_dashboard_page.is_loaded():
            self.acct_admin_dashboard_page.get(self.TOOL_URL)

        # navigate to the create canvas site card on dashboard
        self.acct_admin_dashboard_page.select_create_canvas_site_link()

        # check if page is loaded (which will also set the focus on the tool)
        self.assertTrue(self.main_page.is_loaded())
    def test_roles_access(self, user_id, given_access):
        """
        This test masquerades as various roles from the test data spreadsheet
        and verifies that user in said role should or should not be granted
        access to the Course Bulk Creator.
        """

        masquerade_page = CanvasMasqueradePageObject(self.driver,
                                                     self.CANVAS_BASE_URL)
        index_page = IndexPageObject(self.driver)

        # Masquerade as a user defined in the Test_Data/Roles Access spreadsheet
        masquerade_page.masquerade_as(user_id)

        # Once masqueraded as user, go back to Account Admin Console
        self.driver.get(self.TOOL_URL)

        if given_access == 'no':
            print "Verifying user %s is denied access to course bulk create " \
                  "tool" % user_id
            self.assertFalse(index_page.is_authorized(),
                             'User {} unexpectedly authorized'.format(user_id))

        elif given_access == 'yes':
            print "Verifying user %s is granted access to course bulk create " \
                  "tool" % user_id

            # Clicks into Canvas Site Create tool
            self.acct_admin_dashboard_page.select_create_canvas_site_link()

            # Verifies that the user can click into the bulk create tool
            self.assertTrue(index_page.is_loaded())

        else:
            raise ValueError('given_access column for user {} must be either '
                             '\'yes\' or \'no\''.format(user_id))