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")
Ejemplo n.º 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'])
Ejemplo n.º 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 _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'])
    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))
    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())
class BulkCreateTests(BulkCreateBaseTestCase):

    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'])

    def test_course_selection(self):
        """
        Tests that a user accessing the bulk create tool can access the landing
        page, make selections from the dropdowns, proceed to the course
        selection page, and select courses and a template to enable course
        creation.
        """
        # Load up the tool as predefined
        self._load_bulk_create_tool()

        # Create button should be enabled and show text 'Create All'
        self.assertTrue(
            self.course_selection_page.is_create_all_button_enabled()
        )

        # select two courses from the datatable
        # we are not actually creating courses here, if we do
        # we'll need to change this
        self.course_selection_page.select_course(0)
        self.course_selection_page.select_course(1)

        # Create button should be enabled and show text 'Create All'
        self.assertTrue(
            self.course_selection_page.is_create_selected_button_enabled()
        )

    def test_course_with_registrar_code_display(self):

        """
        TLT-2522: Tests that "registrar_code_display" appears in the bulk
        create tool table, for a course that has a registrar_code display_value

        LIMITATION: This test checks against an element of a particular row and
        column in the bulk create table. If the data changes, it is possible
        that the test will fail.  However, this tightened test is marginally
        preferable and specific to simply checking that any elements that
        matches expected text in the table.

        """
        self._load_bulk_create_tool()
        expected_registrar_code = self.test_data_course_with_registrar_code_display[
            'registrar_code_display']

        # This returns the text of a specific locator on canvas_site_creator table
        registrar_code_element = self.driver.find_element(
                *Locators.COURSE_CODE_LOCATOR_R4_C3)
        actual_registrar_code = registrar_code_element.text
        self.assertEqual(expected_registrar_code, actual_registrar_code,
                         "Registrar code display does not match")

    def test_course_without_registrar_code_display(self):

        """
        TLT- 2522:  TLT-2522: Tests that "registrar_code" appears in the bulk
        create tool table, for a course does not have a registrar_code_display

        LIMITATION: This test checks against an element of a particular row and
        column in the bulk create table. If the data changes, it is possible
        that the test will fail.  However, this tightened test is more
        specific and marginally preferable and specific to simply checking
        that any elements that matches expected text in the table.

        """
        self._load_bulk_create_tool()
        expected_registrar_code = self.test_data_course_without_registrar_code_display[
            'registrar_code_display']

        # This returns the text of a specific locator on canvas_site_creator table
        registrar_code_element = self.driver.find_element(
                *Locators.COURSE_CODE_LOCATOR_R3_C3)
        actual_registrar_code = registrar_code_element.text

        # Compare the expected registrar code with actual registrar code on the
        # page
        self.assertEqual(expected_registrar_code, actual_registrar_code,
                         "Registrar code does not match")
Ejemplo n.º 8
0
class BulkCreateTests(BulkCreateBaseTestCase):
    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'])

    def test_course_selection(self):
        """
        Tests that a user accessing the bulk create tool can access the landing
        page, make selections from the dropdowns, proceed to the course
        selection page, and select courses and a template to enable course
        creation.
        """
        # Load up the tool as predefined
        self._load_bulk_create_tool()

        # Create button should be enabled and show text 'Create All'
        self.assertTrue(
            self.course_selection_page.is_create_all_button_enabled())

        # select two courses from the datatable
        # we are not actually creating courses here, if we do
        # we'll need to change this
        self.course_selection_page.select_course(0)
        self.course_selection_page.select_course(1)

        # Create button should be enabled and show text 'Create All'
        self.assertTrue(
            self.course_selection_page.is_create_selected_button_enabled())

    def test_course_with_registrar_code_display(self):
        """
        TLT-2522: Tests that "registrar_code_display" appears in the bulk
        create tool table, for a course that has a registrar_code display_value

        LIMITATION: This test checks against an element of a particular row and
        column in the bulk create table. If the data changes, it is possible
        that the test will fail.  However, this tightened test is marginally
        preferable and specific to simply checking that any elements that
        matches expected text in the table.

        """
        self._load_bulk_create_tool()
        expected_registrar_code = self.test_data_course_with_registrar_code_display[
            'registrar_code_display']

        # This returns the text of a specific locator on canvas_site_creator table
        registrar_code_element = self.driver.find_element(
            *Locators.COURSE_CODE_LOCATOR_R4_C3)
        actual_registrar_code = registrar_code_element.text
        self.assertEqual(expected_registrar_code, actual_registrar_code,
                         "Registrar code display does not match")

    def test_course_without_registrar_code_display(self):
        """
        TLT- 2522:  TLT-2522: Tests that "registrar_code" appears in the bulk
        create tool table, for a course does not have a registrar_code_display

        LIMITATION: This test checks against an element of a particular row and
        column in the bulk create table. If the data changes, it is possible
        that the test will fail.  However, this tightened test is more
        specific and marginally preferable and specific to simply checking
        that any elements that matches expected text in the table.

        """
        self._load_bulk_create_tool()
        expected_registrar_code = self.test_data_course_without_registrar_code_display[
            'registrar_code_display']

        # This returns the text of a specific locator on canvas_site_creator table
        registrar_code_element = self.driver.find_element(
            *Locators.COURSE_CODE_LOCATOR_R3_C3)
        actual_registrar_code = registrar_code_element.text

        # Compare the expected registrar code with actual registrar code on the
        # page
        self.assertEqual(expected_registrar_code, actual_registrar_code,
                         "Registrar code does not match")