def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     if not LOCAL_RUN:
         self.teacher = Teacher(
             use_env_vars=True,
             pasta_user=self.ps,
             capabilities=self.desired_capabilities
         )
         self.student = Student(
             use_env_vars=True,
             existing_driver=self.teacher.driver,
             pasta_user=self.ps,
             capabilities=self.desired_capabilities
         )
         self.admin = Admin(
             use_env_vars=True,
             existing_driver=self.teacher.driver,
             pasta_user=self.ps,
             capabilities=self.desired_capabilities
         )
     else:
         self.teacher = Teacher(
             use_env_vars=True
         )
         self.student = Student(
             use_env_vars=True,
             existing_driver=self.teacher.driver,
         )
         self.admin = Admin(
             use_env_vars=True,
             existing_driver=self.teacher.driver,
         )
Beispiel #2
0
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     if not LOCAL_RUN:
         self.admin = Admin(use_env_vars=True,
                            pasta_user=self.ps,
                            capabilities=self.desired_capabilities)
     else:
         self.admin = Admin(use_env_vars=True, )
     self.admin.login()
     # make sure there are no new terms to accept
     try:
         self.admin.driver.find_element(By.ID, 'i_agree').click()
     except NoSuchElementException:
         pass
     try:
         self.admin.driver.find_element(By.ID, 'agreement_submit').click()
     except NoSuchElementException:
         pass
     # go to admin console
     self.wait = WebDriverWait(self.admin.driver, 15)
     self.admin.open_user_menu()
     self.admin.wait.until(
         expect.element_to_be_clickable((By.LINK_TEXT, 'Admin'))).click()
     self.admin.page.wait_for_page_load()
     self.admin.driver.find_element(
         By.XPATH, '//a[contains(text(),"Legal")]').click()
Beispiel #3
0
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.teacher = Teacher(use_env_vars=True,
                            pasta_user=self.ps,
                            capabilities=self.desired_capabilities)
    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        if not LOCAL_RUN:
            self.teacher = Teacher(
                use_env_vars=True,
                pasta_user=self.ps,
                capabilities=self.desired_capabilities
            )
        else:
            self.teacher = Teacher(
                use_env_vars=True
            )
        self.wait = WebDriverWait(self.student.driver, Assignment.WAIT_TIME)


        self.teacher.login()

        # go to student scores
        self.teacher.select_course(appearance='biology')
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Student Scores').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[contains(text(), "Student Scores")]')
            )
        ).click()
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     if not LOCAL_RUN:
         self.admin = Admin(
             use_env_vars=True,
             pasta_user=self.ps,
             capabilities=self.desired_capabilities
         )
         self.content = ContentQA(
             existing_driver=self.admin.driver,
             use_env_vars=True,
             pasta_user=self.ps,
             capabilities=self.desired_capabilities
         )
     else:
         self.admin = Admin(
             use_env_vars=True
         )
         self.content = ContentQA(
             use_env_vars=True,
             existing_driver=self.admin.driver
         )
     self.wait = WebDriverWait(self.admin.driver, Assignment.WAIT_TIME)
     self.admin.login()
     self.wait.sleep(2)
     self.admin.goto_admin_control()
Beispiel #6
0
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     if not LOCAL_RUN:
         self.student = Student(
             use_env_vars=True,
             pasta_user=self.ps,
             capabilities=self.desired_capabilities
         )
     else:
         self.student = Student(
             use_env_vars=True
         )
     self.student.login()
     self.student.select_course(title='College Physics with Courseware')
     self.wait = WebDriverWait(self.student.driver, Assignment.WAIT_TIME)
     self.wait.until(
         expect.visibility_of_element_located((
             By.XPATH,
             '//button[contains(@class,"practice")]'
         ))
     ).click()
     self.wait = WebDriverWait(self.student.driver, Assignment.WAIT_TIME)
     self.student.login()
 def setUp(self):
     """Pretest settings."""
     if not LOCAL_RUN:
         self.ps = PastaSauce()
         self.desired_capabilities['name'] = self.id()
         self.student = Student(
             use_env_vars=True,
             pasta_user=self.ps,
             capabilities=self.desired_capabilities
         )
         self.teacher = Teacher(
             existing_driver=self.student.driver,
             use_env_vars=True,
             pasta_user=self.ps,
             capabilities=self.desired_capabilities
         )
     else:
         self.teacher = Teacher(
             use_env_vars=True
         )
         self.student = Student(
             use_env_vars=True,
             existing_driver=self.teacher.driver,
         )
     self.wait = WebDriverWait(self.student.driver, Assignment.WAIT_TIME)
class TestGenerateReports(unittest.TestCase):
    """T1.68 - Generate Reports."""

    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.admin = Admin(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.admin.login()

    def tearDown(self):
        """Test destructor."""
        self.ps.update_job(
            job_id=str(self.admin.driver.session_id),
            **self.ps.test_updates
        )
        try:
            self.admin.delete()
        except:
            pass

    # Case C8361 - 001 - Admin | Export research data to OwnCloud Research
    @pytest.mark.skipif(str(8361) not in TESTS, reason='Excluded')
    def test_admin_export_research_data_to_own_cloud_research_8361(self):
        """Export research data to OwnCloud Research.

        Steps:
        Open the user menu by clicking on the user's name
        Click on the 'Admin' button
        Click the 'Research Data' button
        Click on the 'Export Data' button

        Expected Result:
        The page is reloaded and a confirmation message is displayed.
        """
        self.ps.test_updates['name'] = 't1.68.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.68', 't1.68.001', '8361']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.open_user_menu()
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.LINK_TEXT, 'Admin')
            )
        ).click()
        self.admin.page.wait_for_page_load()
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Research Data")]').click()
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Export Data"]').click()
        self.admin.driver.find_element(
            By.XPATH, '//div[contains(@class,"alert-info")]')

        self.ps.test_updates['passed'] = True
Beispiel #9
0
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.student = Student(use_env_vars=True,
                            pasta_user=self.ps,
                            capabilities=self.desired_capabilities)
     self.student.login()
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.content = ContentQA(
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities,
     )
Beispiel #11
0
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.user = User(username='',
                      password='',
                      pasta_user=self.ps,
                      capabilities=self.desired_capabilities)
     self.user.get('https://qa.cnx.org/')
Beispiel #12
0
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.teacher = Teacher(use_env_vars=True,
                            pasta_user=self.ps,
                            capabilities=self.desired_capabilities)
     self.teacher.login()
     self.teacher.select_course(title='HS Physics')
Beispiel #13
0
class TestEpicName(unittest.TestCase):
    """Product.Epic - Epic Text."""

    def setUp(self):
        """Pretest settings."""

        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        if not LOCAL_RUN:
            self.teacher = Teacher(
                use_env_vars=True,
                pasta_user=self.ps,
                capabilities=self.desired_capabilities
            )
        else:
            self.teacher = Teacher(
                use_env_vars=True
            )

    def tearDown(self):
        """Test destructor."""
        if not LOCAL_RUN:
            self.ps.update_job(
                job_id=str(self.teacher.driver.session_id),
                **self.ps.test_updates
            )
        try:
            self.teacher.delete()
        except:
            pass

    # Case CaseID - Story# - UserType
    @pytest.mark.skipif(str(CaseID) not in TESTS, reason='Excluded')
    def test_usertype_storytext_CaseID(self):
        """Story Text.

        Steps:


        Expected Result:

        """
        self.ps.test_updates['name'] = 'product.epic.story' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'product',
            'product.epic',
            'product.epic.story',
            'CaseID'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates['passed'] = True
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.admin = Admin(use_env_vars=True,
                        pasta_user=self.ps,
                        capabilities=self.desired_capabilities)
     self.admin.login()
     self.admin.goto_admin_control()
     self.admin.sleep(5)
Beispiel #15
0
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.teacher = Teacher(use_env_vars=True,
                            pasta_user=self.ps,
                            capabilities=self.desired_capabilities)
     self.teacher.login()
     self.teacher.driver.find_element(
         By.XPATH, '//a[contains(@href,"/cc-dashboard")]').click()
Beispiel #16
0
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     if not LOCAL_RUN:
         self.teacher = Teacher(use_env_vars=True,
                                pasta_user=self.ps,
                                capabilities=self.desired_capabilities)
     else:
         self.teacher = Teacher(use_env_vars=True)
     self.CONDENSED_WIDTH = 1105
Beispiel #17
0
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.teacher = Teacher(
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
     self.teacher.login()
     self.teacher.select_course(appearance='biology')
     self.teacher.find(By.PARTIAL_LINK_TEXT, 'Performance Forecast').click()
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     if not LOCAL_RUN:
         self.teacher = Teacher(use_env_vars=True,
                                pasta_user=self.ps,
                                capabilities=self.desired_capabilities)
     else:
         self.teacher = Teacher(use_env_vars=True)
     self.teacher.login()
     self.teacher.select_course(appearance='college_physics')
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.student = Student(
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
     self.student.username = os.getenv('STUDENT_USER_CC')
     self.student.login()
     self.student.sleep(5)  # for CNX redirect
Beispiel #20
0
 def setUp(self):
     """Pretest settings."""
     # login as admin, go to user menu, click admin option
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     if not LOCAL_RUN:
         self.admin = Admin(use_env_vars=True,
                            pasta_user=self.ps,
                            capabilities=self.desired_capabilities)
     else:
         self.admin = Admin(use_env_vars=True, )
     self.admin.login()
     self.admin.goto_admin_control()
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     if not LOCAL_RUN:
         self.teacher = Teacher(username=os.getenv('TEACHER_USER_CC'),
                                password=os.getenv('TEACHER_PASSWORD'),
                                pasta_user=self.ps,
                                capabilities=self.desired_capabilities)
     else:
         self.teacher = Teacher(
             username=os.getenv('TEACHER_USER_CC'),
             password=os.getenv('TEACHER_PASSWORD'),
         )
     self.teacher.login()
     if 'cc-dashboard' not in self.teacher.current_url():
         courses = self.teacher.find_all(By.CLASS_NAME,
                                         'tutor-booksplash-course-item')
         assert (courses), 'No courses found.'
         if not isinstance(courses, list):
             courses = [courses]
         course_id = randint(0, len(courses) - 1)
         self.course = courses[course_id].get_attribute('data-title')
         self.teacher.select_course(title=self.course)
     self.teacher.goto_course_roster()
     try:
         section = self.teacher.find_all(
             By.XPATH, '//*[contains(@class,"nav-tabs")]//a')
         if isinstance(section, list):
             section = '%s' % section[randint(0, len(section) - 1)].text
         else:
             section = '%s' % section.text
     except Exception:
         section = '%s' % randint(100, 999)
         self.teacher.add_course_section(section)
     self.code = self.teacher.get_enrollment_code(section)
     print('Course Phrase: ' + self.code)
     self.book_url = self.teacher.find(
         By.XPATH,
         '//a[span[contains(text(),"Online Book")]]').get_attribute('href')
     self.teacher.find(By.CSS_SELECTOR, 'button.close').click()
     self.teacher.sleep(0.5)
     self.teacher.logout()
     self.teacher.sleep(1)
     self.student = Student(use_env_vars=True,
                            existing_driver=self.teacher.driver)
     self.first_name = Assignment.rword(6)
     self.last_name = Assignment.rword(8)
     self.email = self.first_name + '.' \
         + self.last_name \
         + '@tutor.openstax.org'
class TestImproveCourseManagement(unittest.TestCase):
    """T2.07 - Improve Course Management."""
    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.teacher = Teacher(use_env_vars=True,
                               pasta_user=self.ps,
                               capabilities=self.desired_capabilities)
        self.admin = Admin(use_env_vars=True,
                           pasta_user=self.ps,
                           capabilities=self.desired_capabilities,
                           existing_driver=self.teacher.driver)

    def tearDown(self):
        """Test destructor."""
        if not LOCAL_RUN:
            self.ps.update_job(job_id=str(self.teacher.driver.session_id),
                               **self.ps.test_updates)
        self.admin = None
        try:
            self.teacher.delete()
        except:
            pass

    def test_view_stats_admin(self):
        """
        Log in as Admin
        Click on User Menu for drop-down
        Click on 'Admin' on user menu
        Click "Stats"
        Click "Concept Coach"
        ***The user is presented with Concept Coach Statistics (t2.07.01)***

        Corresponds to...
        t2.07.01
        :return:
        """
        # t2.07.01 --> The user is presented with Concept Coach Statistics
        self.admin.login()
        self.admin.goto_admin_control()
        self.admin.sleep(5)
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Stats'))).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Concept Coach'))).click()

        assert ('/stats/concept_coach' in self.admin.current_url()), \
            'Not viewing Concept Coach stats'
Beispiel #23
0
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.teacher = Teacher(use_env_vars=True,
                            pasta_user=self.ps,
                            capabilities=self.desired_capabilities)
     self.teacher.login()
     self.teacher.select_course(appearance='physics')
     self.teacher.open_user_menu()
     self.teacher.wait.until(
         expect.element_to_be_clickable(
             (By.LINK_TEXT, 'Course Settings and Roster'))).click()
     self.teacher.page.wait_for_page_load()
Beispiel #24
0
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.student = Student(use_env_vars=True,
                            pasta_user=self.ps,
                            capabilities=self.desired_capabilities)
     self.student.login()
     self.student.select_course(appearance='physics')
     self.wait = WebDriverWait(self.student.driver, Assignment.WAIT_TIME)
     self.wait.until(
         expect.visibility_of_element_located(
             (By.XPATH,
              '//button[contains(@class,"practice")]//span'))).click()
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     if not LOCAL_RUN:
         self.admin = Admin(
             use_env_vars=True,
             pasta_user=self.ps,
             capabilities=self.desired_capabilities
         )
     else:
         self.admin = Admin(
             use_env_vars=True,
         )
class TestEpicName(unittest.TestCase):
    """Product.Epic - Epic Text."""

    def setUp(self):
        """Pretest settings."""

        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.teacher = Teacher(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )

    def tearDown(self):
        """Test destructor."""
        self.ps.update_job(
            job_id=str(self.teacher.driver.session_id),
            **self.ps.test_updates
        )
        try:
            self.teacher.delete()
        except:
            pass

    # Case CaseID - Story# - UserType
    @pytest.mark.skipif(str(CaseID) not in TESTS, reason='Excluded')
    def test_usertype_storytext_CaseID(self):
        """Story Text.

        Steps:


        Expected Result:

        """
        self.ps.test_updates['name'] = 'product.epic.story' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'product',
            'product.epic',
            'product.epic.story',
            'CaseID'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates['passed'] = True
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.admin = Admin(use_env_vars=True,
                        pasta_user=self.ps,
                        capabilities=self.desired_capabilities)
     self.admin.login()
     self.admin.wait = WebDriverWait(self.admin.driver, 15)
     self.admin.open_user_menu()
     self.admin.wait.until(
         expect.element_to_be_clickable((By.LINK_TEXT, 'Admin'))).click()
     self.admin.page.wait_for_page_load()
     self.admin.driver.find_element(
         By.XPATH, '//a[contains(text(),"Users")]').click()
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.admin = Admin(
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
     self.admin.login()
     # make sure there are no new terms to accept
     try:
         self.admin.driver.find_element(
             By.ID, 'i_agree'
         ).click()
         self.admin.driver.find_element(
             By.ID, 'agreement_submit'
         ).click()
     except NoSuchElementException:
         pass
     # go to admin console
     self.wait = WebDriverWait(self.admin.driver, 15)
     self.admin.open_user_menu()
     self.admin.wait.until(
         expect.element_to_be_clickable(
             (By.LINK_TEXT, 'Admin')
         )
     ).click()
     self.admin.page.wait_for_page_load()
     self.admin.driver.find_element(
         By.XPATH, '//a[contains(text(),"Legal")]').click()
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.admin = Admin(
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
     self.content = ContentQA(
         existing_driver=self.admin.driver,
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
     self.student = Student(
         existing_driver=self.admin.driver,
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
     self.teacher = Teacher(
         existing_driver=self.admin.driver,
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.teacher = Teacher(use_env_vars=True,
                            pasta_user=self.ps,
                            capabilities=self.desired_capabilities)
     # create a reading for the student to work
     self.teacher.login()
     self.teacher.driver.execute_script("window.resizeTo(1920,1080)")
     self.teacher.select_course(appearance='ap_biology')
     self.assignment_name = 't1.18 reading-%s' % randint(100, 999)
     today = datetime.date.today()
     begin = today.strftime('%m/%d/%Y')
     end = (today + datetime.timedelta(days=randint(1, 10))) \
         .strftime('%m/%d/%Y')
     self.teacher.add_assignment(assignment='reading',
                                 args={
                                     'title': self.assignment_name,
                                     'description': chomsky(),
                                     'periods': {
                                         'all': (begin, end)
                                     },
                                     'reading_list': ['1.1'],
                                     'status': 'publish',
                                 })
     self.teacher.wait.until(
         expect.visibility_of_element_located(
             (By.XPATH, '//div[contains(@class,"calendar-container")]')))
     self.teacher.logout()
     # login as a student to work the reading
     self.student = Student(existing_driver=self.teacher.driver,
                            use_env_vars=True,
                            pasta_user=self.ps,
                            capabilities=self.desired_capabilities)
     self.student.login()
     self.student.select_course(appearance='ap_biology')
     self.student.wait.until(
         expect.visibility_of_element_located((By.LINK_TEXT, 'This Week')))
     reading = self.student.driver.find_element(
         By.XPATH, '//div[text()="%s"]' % self.assignment_name)
     self.teacher.driver.execute_script(
         'return arguments[0].scrollIntoView();', reading)
     self.teacher.driver.execute_script('window.scrollBy(0, -80);')
     reading.click()
     self.student.driver.set_window_size(width=1300, height=1200)
 def setUp(self):
     self.ps = PastaSauce()
     self.helper = StaxHelper()
     self.desired_capabilities["name"] = self.id()
     self.driver = StaxHelper.run_on(StaxHelper.LOCAL, self.ps, self.desired_capabilities)
     self.driver.implicitly_wait(15)
     self.wait = WebDriverWait(self.driver, 15)
     self.driver.set_window_size(*standard_window)
     self.rword = self.helper.user.assignment.rword
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.Teacher = Teacher(
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     if not LOCAL_RUN:
         self.teacher = Teacher(
             use_env_vars=True,
             pasta_user=self.ps,
             capabilities=self.desired_capabilities
         )
     else:
         self.teacher = Teacher(
             use_env_vars=True
         )
     self.teacher.login()
     self.teacher.driver.find_element(
         By.XPATH,
         '//p[contains(text(),"OpenStax Concept Coach")]'
     ).click()
Beispiel #34
0
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.admin = Admin(use_env_vars=True,
                        pasta_user=self.ps,
                        capabilities=self.desired_capabilities)
     self.content = ContentQA(existing_driver=self.admin.driver,
                              use_env_vars=True,
                              pasta_user=self.ps,
                              capabilities=self.desired_capabilities)
     self.student = Student(existing_driver=self.admin.driver,
                            use_env_vars=True,
                            pasta_user=self.ps,
                            capabilities=self.desired_capabilities)
     self.teacher = Teacher(existing_driver=self.admin.driver,
                            use_env_vars=True,
                            pasta_user=self.ps,
                            capabilities=self.desired_capabilities)
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.student = Student(
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
     self.student.login()
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.teacher = Teacher(
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
     self.teacher.login()
     self.teacher.select_course(title='HS Physics')
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.admin = Admin(
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
     self.admin.login()
     self.admin.goto_admin_control()
     self.admin.sleep(5)
Beispiel #38
0
 def setUp(self):
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.admin = Admin(use_env_vars=True)
     self.helper = StaxHelper(driver_type='chrome', pasta_user=self.ps,
                              capabilities=self.desired_capabilities,
                              initial_user=self.admin)
     self.driver = self.helper.driver
     self.wait = WebDriverWait(self.driver, StaxHelper.DEFAULT_WAIT_TIME)
     self.driver.set_window_size(*standard_window)
     self.admin.login(self.driver)
     self.rword = Assignment.rword
     self.screenshot_path = '/tmp/errors/'
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.teacher = Teacher(
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
     self.teacher.login()
     self.teacher.driver.find_element(
         By.XPATH, '//a[contains(@href,"/cc-dashboard")]'
     ).click()
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.teacher = Teacher(
         username=os.getenv('TEACHER_USER_CC'),
         password=os.getenv('TEACHER_PASSWORD'),
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
     self.teacher.login()
     if 'cc-dashboard' not in self.teacher.current_url():
         courses = self.teacher.find_all(
             By.CLASS_NAME,
             'tutor-booksplash-course-item'
         )
         assert(courses), 'No courses found.'
         if not isinstance(courses, list):
             courses = [courses]
         course_id = randint(0, len(courses) - 1)
         self.course = courses[course_id].get_attribute('data-title')
         self.teacher.select_course(title=self.course)
     self.teacher.goto_course_roster()
     try:
         section = self.teacher.find_all(
             By.XPATH,
             '//*[contains(@class,"nav-tabs")]//a'
         )
         if isinstance(section, list):
             section = '%s' % section[randint(0, len(section) - 1)].text
         else:
             section = '%s' % section.text
     except Exception:
         section = '%s' % randint(100, 999)
         self.teacher.add_course_section(section)
     self.code = self.teacher.get_enrollment_code(section)
     print('Course Phrase: ' + self.code)
     self.book_url = self.teacher.find(
         By.XPATH, '//a[span[contains(text(),"Online Book")]]'
     ).get_attribute('href')
     self.teacher.find(By.CSS_SELECTOR, 'button.close').click()
     self.teacher.sleep(0.5)
     self.teacher.logout()
     self.teacher.sleep(1)
     self.student = Student(use_env_vars=True,
                            existing_driver=self.teacher.driver)
     self.first_name = Assignment.rword(6)
     self.last_name = Assignment.rword(8)
     self.email = self.first_name + '.' \
         + self.last_name \
         + '@tutor.openstax.org'
 def setUp(self):
     self.ps = PastaSauce()
     self.desired_capabilities["name"] = self.id()
     self.teacher = Teacher(use_env_vars=True)
     self.helper = StaxHelper(
         driver_type="chrome", pasta_user=self.ps, capabilities=self.desired_capabilities, initial_user=self.teacher
     )
     self.driver = self.helper.driver
     self.wait = WebDriverWait(self.driver, StaxHelper.DEFAULT_WAIT_TIME)
     self.driver.set_window_size(*standard_window)
     self.teacher.login(self.driver)
     self.teacher.select_course(self.driver, title="physics")
     self.rword = Assignment.rword
     self.screenshot_path = "/tmp/errors/"
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.teacher = Teacher(
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
     self.student = Student(
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities,
         existing_driver=self.teacher.driver
     )
Beispiel #43
0
 def setUp(self):
     self.ps = PastaSauce()
     self.helper = StaxHelper()
     self.desired_capabilities['name'] = self.id()
     student = self.helper.student.name
     student_password = self.helper.student.password
     self.driver = StaxHelper.run_on(
         StaxHelper.LOCAL, self.ps, self.desired_capabilities
     )
     self.driver.implicitly_wait(15)
     self.wait = WebDriverWait(self.driver, 15)
     self.driver.set_window_size(*standard_window)
     self.helper.user.login(self.driver, student, student_password,
                            self.helper.user.url)
     self.helper.user.select_course(self.driver, category='Physics')
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.student = Student(
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
     self.student.login()
     self.student.select_course(appearance='physics')
     self.wait = WebDriverWait(self.student.driver, Assignment.WAIT_TIME)
     self.wait.until(
         expect.visibility_of_element_located((
             By.XPATH,
             '//button[contains(@class,"practice")]//span'
         ))
     ).click()
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.teacher = Teacher(
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
     self.teacher.login()
     self.teacher.select_course(appearance='physics')
     self.teacher.open_user_menu()
     self.teacher.wait.until(
         expect.element_to_be_clickable(
             (By.LINK_TEXT, 'Course Settings and Roster')
         )
     ).click()
     self.teacher.page.wait_for_page_load()
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.admin = Admin(
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities
     )
     self.admin.login()
     self.admin.wait = WebDriverWait(self.admin.driver, 15)
     self.admin.open_user_menu()
     self.admin.wait.until(
         expect.element_to_be_clickable(
             (By.LINK_TEXT, 'Admin')
         )
     ).click()
     self.admin.page.wait_for_page_load()
     self.admin.driver.find_element(
         By.XPATH,
         '//a[contains(text(),"Users")]'
     ).click()
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities["name"] = self.id()
     self.teacher = Teacher(use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities)
     # create a reading for the student to work
     self.teacher.login()
     self.assignment_name = "t1.18 reading-%s" % randint(100, 999)
     today = datetime.date.today()
     begin = today.strftime("%m/%d/%Y")
     end = (today + datetime.timedelta(days=randint(1, 10))).strftime("%m/%d/%Y")
     self.teacher.add_assignment(
         assignment="reading",
         args={
             "title": self.assignment_name,
             "description": chomsky(),
             "periods": {"all": (begin, end)},
             "reading_list": ["1.1", "1.2"],
             "status": "publish",
         },
     )
     self.teacher.wait.until(
         expect.visibility_of_element_located((By.XPATH, '//div[contains(@class,"calendar-container")]'))
     )
     self.teacher.logout()
     # login as a student to work the reading
     self.student = Student(
         existing_driver=self.teacher.driver,
         use_env_vars=True,
         pasta_user=self.ps,
         capabilities=self.desired_capabilities,
     )
     self.student.login()
     self.student.wait.until(expect.visibility_of_element_located((By.LINK_TEXT, "This Week")))
     reading = self.student.driver.find_element(By.XPATH, '//span[text()="%s"]' % self.assignment_name)
     self.teacher.driver.execute_script("return arguments[0].scrollIntoView();", reading)
     self.teacher.driver.execute_script("window.scrollBy(0, -80);")
     reading.click()
class TestGuideMonitorSupportAndTrainUsers(unittest.TestCase):
    """T2.18 - Guide, Monitor, Support, and Train Users."""

    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities["name"] = self.id()
        self.teacher = Teacher(use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities)

    def tearDown(self):
        """Test destructor."""
        self.ps.update_job(job_id=str(self.teacher.driver.session_id), **self.ps.test_updates)
        try:
            self.teacher.delete()
        except:
            pass

    # 14752 - 001 - User | In-app Notification of downtime
    @pytest.mark.skipif(str(14752) not in TESTS, reason="Excluded")
    def test_user_inapp_notification_of_downtime_14752(self):
        """In-app Notification of downtime.

        Steps:

        Go to Tutor
        Log in as admin
        Click "Admin" from the user menu
        Click "System Setting"
        Click "Notifications"
        Enter a new notification into the text box
        Click "Add"
        Log out of admin
        Log in as teacher01

        Expected Result:
        An orange header with the notification pops up when you sign in
        """
        self.ps.test_updates["name"] = "t2.18.001" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.001", "14752"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 14751 - 002 - Teacher | Directed to a "No Courses" page when not in any
    # courses yet
    @pytest.mark.skipif(str(14751) not in TESTS, reason="Excluded")
    def test_teacher_directed_to_a_no_courses_page_when_not_in_any_14751(self):
        """Directed to a "No Courses" page when not in any courses yet.

        Steps:
        Go to tutor-qa.openstax.org
        Sign in as demo_teacher; password

        Expected Result:
        The message "We cannot find an OpenStax course associated with your
        account" displays with help links below
        """
        self.ps.test_updates["name"] = "t2.18.002" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.002", "14751"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58279 - 003 - Teacher | View "Getting Started with Tutor" Guide
    @pytest.mark.skipif(str(58279) not in TESTS, reason="Excluded")
    def test_teacher_view_getting_started_with_tutor_guide_58279(self):
        """View "Getting Started with Tutor" Guide.

        Steps:
        Click "Tutor Instructors. Get help"

        Expected Result:
        Tutor Help Center opens in another tab with the Getting Started guide
        """
        self.ps.test_updates["name"] = "t2.18.003" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.003", "58279"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58280 - 004 - Teacher | Access Tutor Help Center after registering for
    # a course
    @pytest.mark.skipif(str(58280) not in TESTS, reason="Excluded")
    def test_teacher_access_tutor_help_center_after_registering_58280(self):
        """Access Tutor Help Center after registering for a course.

        Steps:
        Go to Tutor
        Sign in as teacher01
        Click on a Tutor course if the user is in more than one
        Click "Get Help" from the user menu in the upper right corner of the
            screen

        Expected Result:
        The user is presented with the Tutor Help Center
        """
        self.ps.test_updates["name"] = "t2.18.004" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.004", "58280"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58284 - 005 - Teacher | Submit a question
    @pytest.mark.skipif(str(58284) not in TESTS, reason="Excluded")
    def test_teacher_submit_a_question_58284(self):
        """Submit a question.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter

        Expected Result:
        The user is presented with search results
        """
        self.ps.test_updates["name"] = "t2.18.005" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.005", "58284"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58352 - 006 - Teacher | View "Contact Us" button after submitting a
    # question
    @pytest.mark.skipif(str(58352) not in TESTS, reason="Excluded")
    def test_teacher_view_contact_us_button_after_submitting_quest_58352(self):
        """View "Contact Us" button after submitting a question.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Scroll to the bottom of the screen

        Expected Result:
        "Contact Us" button exists
        """
        self.ps.test_updates["name"] = "t2.18.006" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.006", "58352"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58288 - 007 - Teacher | View an article after submitting a question
    @pytest.mark.skipif(str(58288) not in TESTS, reason="Excluded")
    def test_teacher_view_an_article_after_submitting_a_question_58288(self):
        """View an article after submitting a question.

        Steps:

        Click "Get Help" from the user menu in the upper right corner of the
        screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result

        Expected Result:
        The user is presented with an article containing answer to the question
        """
        self.ps.test_updates["name"] = "t2.18.007" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.007", "58288"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58313 - 008 - Teacher | Indicate that the article was helpful
    @pytest.mark.skipif(str(58313) not in TESTS, reason="Excluded")
    def test_teacher_indicate_that_the_article_was_helpful_58313(self):
        """Indicate that the article was helpful.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "Yes"

        Expected Result:
        A message that says "Thanks for your feedback!" is displayed
        """
        self.ps.test_updates["name"] = "t2.18.008" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.008", "58313"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58314 - 009 - Teacher | Negative feedback renders a feedback popup box
    @pytest.mark.skipif(str(58314) not in TESTS, reason="Excluded")
    def test_teacher_negative_feedback_renders_feedback_popup_box_58314(self):
        """Negative feedback renders a feedback popup box.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"

        Expected Result:
        The user is presented with a popup box that allows them to input
        feedback
        """
        self.ps.test_updates["name"] = "t2.18.009" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.009", "58314"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58315 - 010 - Teacher | Submit feedback for an article
    @pytest.mark.skipif(str(58315) not in TESTS, reason="Excluded")
    def test_teacher_submit_feedback_for_an_article_58315(self):
        """Submit feedback for an article.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"
        Enter feedback into the box that pops up
        Click "Submit"

        Expected Result:
        A message that says "Thanks for your feedback!" is displayed in the box
        """
        self.ps.test_updates["name"] = "t2.18.010" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.010", "58315"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58322 - 011 - Teacher | Close window after submitting feedback for an
    # article
    @pytest.mark.skipif(str(58322) not in TESTS, reason="Excluded")
    def test_teacher_close_window_after_submitting_feedback_for_58322(self):
        """Close window after submitting feedback for an article.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"
        Enter feedback into the box that pops up
        Click "Submit"
        Click "Close window"

        Expected Result:
        The popup box closes and the message "Thanks for your feedback"
        displays beneath "Feedback"
        """
        self.ps.test_updates["name"] = "t2.18.011" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.011", "58322"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58316 - 012 - Teacher | Cancel feedback
    @pytest.mark.skipif(str(58316) not in TESTS, reason="Excluded")
    def test_teacher_cancel_feedback_before_making_changes_58316(self):
        """Cancel feedback.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"
        [optional] Enter feedback into the text box
        Click "Cancel"

        Expected Result:
        The popup box closes
        """
        self.ps.test_updates["name"] = "t2.18.012" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.012", "58316"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58318 - 013 - Teacher | View related articles
    @pytest.mark.skipif(str(58318) not in TESTS, reason="Excluded")
    def test_teacher_view_related_articles_58318(self):
        """View related articles.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Related Articles"
        Click on one of the articles (if any)

        Expected Result:
        The user is presented with the related article
        """
        self.ps.test_updates["name"] = "t2.18.013" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.013", "58318"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58319 - 014 - Teacher | Submit a question to Customer Support
    @pytest.mark.skipif(str(58319) not in TESTS, reason="Excluded")
    def test_teacher_submit_a_question_to_customer_support_58319(self):
        """Submit a question to Customer Support.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        CLick "Search" or press enter
        Click on a search result
        Scroll to the bottom of the page
        CLick "Contact Us"
        Fill out the required fields
        Enter "Submit"

        Expected Result:
        The message "Thank you for your message! We'll be back to you within
        one business day" is displayed
        """
        self.ps.test_updates["name"] = "t2.18.014" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.014", "58319"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 14755 - 015 - Teacher | View guided tutorials of Tutor
    @pytest.mark.skipif(str(14755) not in TESTS, reason="Excluded")
    def test_teacher_view_guided_tutorials_of_concept_coach_14755(self):
        """View guided tutorials of Tutor.

        Steps:


        Expected Result:

        """
        self.ps.test_updates["name"] = "t2.18.015" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.015", "14755"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 14750 - 016 - Student | Directed to a "No Courses" page when not in any
    # courses yet
    @pytest.mark.skipif(str(14750) not in TESTS, reason="Excluded")
    def test_student_directed_to_a_no_courses_page_when_not_in_any_14750(self):
        """Directed to a "No Courses" page when not in any courses yet.

        Steps:
        Go to Tutor
        Log in as qa_student_37003

        Expected Result:
        The message "We cannot find an OpenStax course associated with your
        account" displays with help links
        """
        self.ps.test_updates["name"] = "t2.18.016" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.016", "14750"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58336 - 017 - Student | View "Getting Started with Tutor" Guide
    @pytest.mark.skipif(str(58336) not in TESTS, reason="Excluded")
    def test_student_view_getting_started_with_tutor_guide_58336(self):
        """View "Getting Started with Tutor" Guide.

        Steps:
        Click "Tutor Students. Get help"

        Expected Result:
        Tutor Help Center opens in another tab with the Getting Started guide
        """
        self.ps.test_updates["name"] = "t2.18.017" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.017", "58336"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58337 - 018 - Student | Access Tutor Help Center after registering for a
    # course
    @pytest.mark.skipif(str(58337) not in TESTS, reason="Excluded")
    def test_student_access_tutor_help_center_after_registering_58337(self):
        """Access Tutor Help Center after registering for a course.

        Steps:
        Go to Tutor
        Sign in as student01
        Click on a Tutor course if the user is in more than one
        Click "Get Help" from the user menu in the upper right corner of the
            screen

        Expected Result:
        The user is presented with the Tutor Help Center
        """
        self.ps.test_updates["name"] = "t2.18.018" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.018", "58337"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58338 - 019 - Student | Submit a question
    @pytest.mark.skipif(str(58338) not in TESTS, reason="Excluded")
    def test_student_submit_a_question_58338(self):
        """Submit a question.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter

        Expected Result:
        The user is presented with search results
        """
        self.ps.test_updates["name"] = "t2.18.019" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.019", "58338"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58353 - 020 - Student | View "Contact Us" button after submitting a
    # question
    @pytest.mark.skipif(str(58353) not in TESTS, reason="Excluded")
    def test_student_view_contact_us_button_after_submitting_quest_58353(self):
        """View "Contact Us" button after submitting a question.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Scroll to the bottom of the page

        Expected Result:
        "Contact Us" button exists
        """
        self.ps.test_updates["name"] = "t2.18.020" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.020", "58353"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58339 - 021 - Student | View an article after submitting a question
    @pytest.mark.skipif(str(58339) not in TESTS, reason="Excluded")
    def test_student_view_an_article_after_submitting_a_question_58339(self):
        """View an article after submitting a question.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result

        Expected Result:
        The user is presented with an article containing answer to the question
        """
        self.ps.test_updates["name"] = "t2.18.021" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.021", "58339"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58340 - 022 - Student | Indicate that the article was helpful
    @pytest.mark.skipif(str(58340) not in TESTS, reason="Excluded")
    def test_student_indicate_that_the_article_was_helpful_58340(self):
        """Indicate that the article was helpful.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "Yes"

        Expected Result:
        A message that says "Thanks for your feedback!" is displayed
        """
        self.ps.test_updates["name"] = "t2.18.022" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.022", "58340"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58341 - 023 - Student | Negative feedback renders a feedback popup box
    @pytest.mark.skipif(str(58341) not in TESTS, reason="Excluded")
    def test_student_negative_feedback_renders_feedback_popup_box_58341(self):
        """Negative feedback renders a feedback popup box.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"

        Expected Result:
        The user is presented with a popup box that allows them to input
        feedback
        """
        self.ps.test_updates["name"] = "t2.18.023" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.023", "58341"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58342 - 024 - Student | Submit feedback for an article
    @pytest.mark.skipif(str(58342) not in TESTS, reason="Excluded")
    def test_student_submit_feedback_for_an_article_58342(self):
        """Submit feedback for an article.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"
        Enter feedback into the box that pops up
        Click "Submit"

        Expected Result:
        A message that says "Thanks for your feedback!" is displayed in the box
        """
        self.ps.test_updates["name"] = "t2.18.024" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.024", "58342"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58343 - 025 - Student | Close window after submitting feedback for an
    # article
    @pytest.mark.skipif(str(58343) not in TESTS, reason="Excluded")
    def test_student_close_window_after_submitting_feedback_for_58343(self):
        """Close window after submitting feedback for an article.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"
        Enter feedback into the box that pops up
        Click "Submit"
        Click "Close window"

        Expected Result:
        The popup box closes and the message "Thanks for your feedback"
        displays beneath "Feedback"
        """
        self.ps.test_updates["name"] = "t2.18.025" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.025", "58343"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58344 - 026 - Student | Cancel feedback
    @pytest.mark.skipif(str(58344) not in TESTS, reason="Excluded")
    def test_student_cancel_feedback_58344(self):
        """Cancel feedback.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"
        [optional] Enter feedback into text box
        Click "Cancel"

        Expected Result:
        The popup box closes
        """
        self.ps.test_updates["name"] = "t2.18.026" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.026", "58344"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58346 - 027 - Student | View related articles
    @pytest.mark.skipif(str(58346) not in TESTS, reason="Excluded")
    def test_student_view_related_articles_58346(self):
        """View related articles.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Related Articles"
        Click on one of the articles (if any)

        Expected Result:
        The user is presented with the related article
        """
        self.ps.test_updates["name"] = "t2.18.027" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.027", "58346"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58347 - 028 - Student | Submit a question to Customer Support
    @pytest.mark.skipif(str(58347) not in TESTS, reason="Excluded")
    def test_student_submit_a_question_to_customer_support_58347(self):
        """Submit a question to Customer Support.

        Steps:
        Click "Get Help" from the user menu in the upper right corner of the
            screen
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to the bottom of the page
        Click "Contact Us"
        Fill out the required fields
        Enter "Submit"

        Expected Result:
        The message "Thank you for your message! We'll be back to you within
        one business day" is displayed
        """
        self.ps.test_updates["name"] = "t2.18.028" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.028", "58347"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True

    # 58348 - 029 - Student | View guided tutorials of Tutor
    @pytest.mark.skipif(str(58348) not in TESTS, reason="Excluded")
    def test_student_view_guided_tutorials_of_concept_coach_58348(self):
        """View guided tutorial of Tutor.

        Steps:


        Expected Result:

        """
        self.ps.test_updates["name"] = "t2.18.029" + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates["tags"] = ["t2", "t2.18", "t2.18.029", "58348"]
        self.ps.test_updates["passed"] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates["passed"] = True
class TestTutorBasicAssignments(unittest.TestCase):
    """"""

    def setUp(self):
        self.ps = PastaSauce()
        self.desired_capabilities["name"] = self.id()
        self.teacher = Teacher(use_env_vars=True)
        self.helper = StaxHelper(
            driver_type="chrome", pasta_user=self.ps, capabilities=self.desired_capabilities, initial_user=self.teacher
        )
        self.driver = self.helper.driver
        self.wait = WebDriverWait(self.driver, StaxHelper.DEFAULT_WAIT_TIME)
        self.driver.set_window_size(*standard_window)
        self.teacher.login(self.driver)
        self.teacher.select_course(self.driver, title="physics")
        self.rword = Assignment.rword
        self.screenshot_path = "/tmp/errors/"

    def tearDown(self):
        # Returns the info of exception being handled
        has_errors = self._test_has_failed()
        if has_errors:
            print(self.driver.current_url, "\n")
            date_and_time = datetime.now().strftime("%Y-%m-%d_%H-%M-%S-%f")
            filename = "testerr_%s.png" % date_and_time
            self.driver.save_screenshot("%s%s" % (self.screenshot_path, filename))
        self.driver = None
        self.helper.quit()
        self.ps.update_job(self.driver.session_id, passed=has_errors)

    def _test_has_failed(self):
        # for 3.4. In 3.3, can just use self._outcomeForDoCleanups.success:
        for method, error in self._outcome.errors:
            if error:
                return True
        return False

    # @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_assignment_today_all_cancel(self):
        """
        """
        # all / 0 / 1 / 1S / Cancel
        print(inspect.currentframe().f_code.co_name)
        print(self.__class__.__name__)
        name = "Automated 1"
        description = "by period cancel"
        open_all = StaxHelper.date_string()
        due_all = StaxHelper.date_string(1)
        try:
            self.assign.add_new_reading(
                driver=self.driver,
                title=name,
                description=description,
                periods={"all": (open_all, due_all)},
                readings=["1.1"],
                status=self.assign.CANCEL,
            )
        except Exception as ex:
            self.fail("1: Add :: %s :: %s" % (ex.__class__.__name__, ex))

    @pytest.mark.skipif(NOT_STARTED, reason="Not started")
    def test_assignment_today_all_draft_and_delete(self):
        """
        """
        # 1st / 0 / 1 / 1S / Cancel
        # 2nd / 1 / 2 / 1S
        print(inspect.currentframe().f_code.co_name)
        print(self.__class__.__name__)
        name = "Automated 2"
        description = "by period cancel"
        open_p1 = StaxHelper.date_string()
        due_p1 = StaxHelper.date_string(1)
        open_p2 = StaxHelper.date_string(1)
        due_p2 = StaxHelper.date_string(2)
        try:
            self.assign.add_new_reading(
                driver=self.driver,
                title=name,
                description=description,
                periods={"1st": (open_p1, due_p1), "2nd": (open_p2, due_p2)},
                readings=["1.1"],
                status=self.assign.CANCEL,
            )
        except Exception as ex:
            self.fail("1: Add :: %s :: %s" % (ex.__class__.__name__, ex))

    @pytest.mark.skipif(NOT_STARTED, reason="Not started")
    def test_assignment_today_all_publish(self):
        """
        """
        # 1st / 0 / 1 / 1S / Cancel
        # 2nd / 1 / 2 / 1S
        print(inspect.currentframe().f_code.co_name)
        print(self.__class__.__name__)
        name = "Automated 3"
        description = "by period cancel"
        open_p1 = StaxHelper.date_string()
        due_p1 = StaxHelper.date_string(1)
        open_p2 = StaxHelper.date_string(1)
        due_p2 = StaxHelper.date_string(2)
        try:
            self.assign.add_new_reading(
                driver=self.driver,
                title=name,
                description=description,
                periods={"1st": (open_p1, due_p1), "2nd": (open_p2, due_p2)},
                readings=["1.1"],
                status=self.assign.CANCEL,
            )
        except Exception as ex:
            self.fail("1: Add :: %s :: %s" % (ex.__class__.__name__, ex))

    @pytest.mark.skipif(NOT_STARTED, reason="Not started")
    def test_assignment_today_by_period_cancel(self):
        """
        """
        # 1st / 0 / 1 / 1S / Cancel
        # 2nd / 1 / 2 / 1S
        print(inspect.currentframe().f_code.co_name)
        print(self.__class__.__name__)
        name = "Automated 4"
        description = "by period cancel"
        open_p1 = StaxHelper.date_string()
        due_p1 = StaxHelper.date_string(1)
        open_p2 = StaxHelper.date_string(1)
        due_p2 = StaxHelper.date_string(2)
        try:
            self.assign.add_new_reading(
                driver=self.driver,
                title=name,
                description=description,
                periods={"1st": (open_p1, due_p1), "2nd": (open_p2, due_p2)},
                readings=["1.1"],
                status=self.assign.CANCEL,
            )
        except Exception as ex:
            self.fail("1: Add :: %s :: %s" % (ex.__class__.__name__, ex))

    @pytest.mark.skipif(NOT_STARTED, reason="Not started")
    def test_assignment_today_by_period_draft_and_delete(self):
        """
        """
        # 1st / 0 / 1 / 1S / Cancel
        # 2nd / 1 / 2 / 1S
        print(inspect.currentframe().f_code.co_name)
        print(self.__class__.__name__)
        name = "Automated 5"
        description = "by period cancel"
        open_p1 = StaxHelper.date_string()
        due_p1 = StaxHelper.date_string(1)
        open_p2 = StaxHelper.date_string(1)
        due_p2 = StaxHelper.date_string(2)
        try:
            self.assign.add_new_reading(
                driver=self.driver,
                title=name,
                description=description,
                periods={"1st": (open_p1, due_p1), "2nd": (open_p2, due_p2)},
                readings=["1.1"],
                status=self.assign.CANCEL,
            )
        except Exception as ex:
            self.fail("1: Add :: %s :: %s" % (ex.__class__.__name__, ex))

    @pytest.mark.skipif(NOT_STARTED, reason="Not started")
    def test_assignment_today_by_period_publish(self):
        """
        """
        # 1st / 0 / 1 / 1S / Cancel
        # 2nd / 1 / 2 / 1S
        print(inspect.currentframe().f_code.co_name)
        print(self.__class__.__name__)
        name = "Automated 6"
        description = "by period cancel"
        open_p1 = StaxHelper.date_string()
        due_p1 = StaxHelper.date_string(1)
        open_p2 = StaxHelper.date_string(1)
        due_p2 = StaxHelper.date_string(2)
        try:
            self.assign.add_new_reading(
                driver=self.driver,
                title=name,
                description=description,
                periods={"1st": (open_p1, due_p1), "2nd": (open_p2, due_p2)},
                readings=["1.1"],
                status=self.assign.CANCEL,
            )
        except Exception as ex:
            self.fail("1: Add :: %s :: %s" % (ex.__class__.__name__, ex))

    @pytest.mark.skipif(NOT_STARTED, reason="Not started")
    def test_assignment_future_all_cancel(self):
        """
        """
        # 1st / 0 / 1 / 1S / Cancel
        # 2nd / 1 / 2 / 1S
        print(inspect.currentframe().f_code.co_name)
        print(self.__class__.__name__)
        name = "Automated 7"
        description = "by period cancel"
        open_p1 = StaxHelper.date_string()
        due_p1 = StaxHelper.date_string(1)
        open_p2 = StaxHelper.date_string(1)
        due_p2 = StaxHelper.date_string(2)
        try:
            self.assign.add_new_reading(
                driver=self.driver,
                title=name,
                description=description,
                periods={"1st": (open_p1, due_p1), "2nd": (open_p2, due_p2)},
                readings=["1.1"],
                status=self.assign.CANCEL,
            )
        except Exception as ex:
            self.fail("1: Add :: %s :: %s" % (ex.__class__.__name__, ex))

    @pytest.mark.skipif(NOT_STARTED, reason="Not started")
    def test_assignment_future_all_draft_and_delete(self):
        """
        """
        # 1st / 0 / 1 / 1S / Cancel
        # 2nd / 1 / 2 / 1S
        print(inspect.currentframe().f_code.co_name)
        print(self.__class__.__name__)
        name = "Automated 8"
        description = "by period cancel"
        open_p1 = StaxHelper.date_string()
        due_p1 = StaxHelper.date_string(1)
        open_p2 = StaxHelper.date_string(1)
        due_p2 = StaxHelper.date_string(2)
        try:
            self.assign.add_new_reading(
                driver=self.driver,
                title=name,
                description=description,
                periods={"1st": (open_p1, due_p1), "2nd": (open_p2, due_p2)},
                readings=["1.1"],
                status=self.assign.CANCEL,
            )
        except Exception as ex:
            self.fail("1: Add :: %s :: %s" % (ex.__class__.__name__, ex))

    @pytest.mark.skipif(NOT_STARTED, reason="Not started")
    def test_assignment_future_all_publish_and_delete(self):
        """
        """
        # 1st / 0 / 1 / 1S / Cancel
        # 2nd / 1 / 2 / 1S
        print(inspect.currentframe().f_code.co_name)
        print(self.__class__.__name__)
        name = "Automated 9"
        description = "by period cancel"
        open_p1 = StaxHelper.date_string()
        due_p1 = StaxHelper.date_string(1)
        open_p2 = StaxHelper.date_string(1)
        due_p2 = StaxHelper.date_string(2)
        try:
            self.assign.add_new_reading(
                driver=self.driver,
                title=name,
                description=description,
                periods={"1st": (open_p1, due_p1), "2nd": (open_p2, due_p2)},
                readings=["1.1"],
                status=self.assign.CANCEL,
            )
        except Exception as ex:
            self.fail("1: Add :: %s :: %s" % (ex.__class__.__name__, ex))

    @pytest.mark.skipif(NOT_STARTED, reason="Not started")
    def test_assignment_future_by_period_cancel(self):
        """
        """
        # 1st / 0 / 1 / 1S / Cancel
        # 2nd / 1 / 2 / 1S
        print(inspect.currentframe().f_code.co_name)
        print(self.__class__.__name__)
        name = "Automated 10"
        description = "by period cancel"
        open_p1 = StaxHelper.date_string()
        due_p1 = StaxHelper.date_string(1)
        open_p2 = StaxHelper.date_string(1)
        due_p2 = StaxHelper.date_string(2)
        try:
            self.assign.add_new_reading(
                driver=self.driver,
                title=name,
                description=description,
                periods={"1st": (open_p1, due_p1), "2nd": (open_p2, due_p2)},
                readings=["1.1"],
                status=self.assign.CANCEL,
            )
        except Exception as ex:
            self.fail("1: Add :: %s :: %s" % (ex.__class__.__name__, ex))

    @pytest.mark.skipif(NOT_STARTED, reason="Not started")
    def test_assignment_future_by_period_draft_and_delete(self):
        """
        """
        # 1st / 0 / 1 / 1S / Cancel
        # 2nd / 1 / 2 / 1S
        print(inspect.currentframe().f_code.co_name)
        print(self.__class__.__name__)
        name = "Automated 11"
        description = "by period cancel"
        open_p1 = StaxHelper.date_string()
        due_p1 = StaxHelper.date_string(1)
        open_p2 = StaxHelper.date_string(1)
        due_p2 = StaxHelper.date_string(2)
        try:
            self.assign.add_new_reading(
                driver=self.driver,
                title=name,
                description=description,
                periods={"1st": (open_p1, due_p1), "2nd": (open_p2, due_p2)},
                readings=["1.1"],
                status=self.assign.CANCEL,
            )
        except Exception as ex:
            self.fail("1: Add :: %s :: %s" % (ex.__class__.__name__, ex))

    @pytest.mark.skipif(NOT_STARTED, reason="Not started")
    def test_assignment_future_by_period_publish_and_delete(self):
        """
        """
        # 1st / 0 / 1 / 1S / Cancel
        # 2nd / 1 / 2 / 1S
        print(inspect.currentframe().f_code.co_name)
        print(self.__class__.__name__)
        name = "Automated 12"
        description = "by period cancel"
        open_p1 = StaxHelper.date_string()
        due_p1 = StaxHelper.date_string(1)
        open_p2 = StaxHelper.date_string(1)
        due_p2 = StaxHelper.date_string(2)
        try:
            self.assign.add_new_reading(
                driver=self.driver,
                title=name,
                description=description,
                periods={"1st": (open_p1, due_p1), "2nd": (open_p2, due_p2)},
                readings=["1.1"],
                status=self.assign.CANCEL,
            )
        except Exception as ex:
            self.fail("1: Add :: %s :: %s" % (ex.__class__.__name__, ex))
class TestAnalyzeCollegeWorkflow(unittest.TestCase):
    """T2.05 - Analyze College Workflow."""

    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.teacher = Teacher(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.student = Student(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities,
            existing_driver=self.teacher.driver
        )

    def tearDown(self):
        """Test destructor."""
        self.ps.update_job(
            job_id=str(self.teacher.driver.session_id),
            **self.ps.test_updates
        )
        try:
            self.student = None
            self.teacher.delete()
        except:
            pass

    # 14645 - 001 - Student | All work is visible for college students
    # not just "This Week"
    @pytest.mark.skipif(str(14645) not in TESTS, reason='Excluded')
    def test_student_all_work_is_visible_for_college_students_14645(self):
        """All work is visible for college students, not just 'This Week'.

        Steps:
        Log into tutor-qa as student
        Click on a college course

        Expected Result:
        Can view assignments due later than this week
        """
        self.ps.test_updates['name'] = 't2.05.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't2',
            't2.05',
            't2.05.001',
            '14645'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.login()
        self.student.select_course(appearance='physics')
        assert('list/' in self.student.current_url()), \
            'Not viewing the calendar dashboard'

        self.student.sleep(5)

        page = self.student.driver.page_source
        assert('Coming Up' in page or 'No upcoming events' in page), \
            'No Coming Up/No upcoming events text is visible/present'

        self.ps.test_updates['passed'] = True

    # 14646 - 002 - Teacher | Create a link to the OpenStax Dashboard
    @pytest.mark.skipif(str(14646) not in TESTS, reason='Excluded')
    def test_teacher_create_a_link_to_the_openstax_dashboard_14646(self):
        """Create a link to the OpenStax Dashboard.

        Steps:


        Expected Result:

        """
        self.ps.test_updates['name'] = 't2.05.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't2',
            't2.05',
            't2.05.002',
            '14646'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates['passed'] = True

    # 14647 - 003 - Teacher | Create a link to the OpenStax Dashboard
    @pytest.mark.skipif(str(14647) not in TESTS, reason='Excluded')
    def test_teacher_create_a_link_to_the_openstax_dashboard_14647(self):
        """Create a link to the OpenStax Dashboard.

        Steps:


        Expected Result:

        """
        self.ps.test_updates['name'] = 't2.05.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't2',
            't2.05',
            't2.05.003',
            '14647'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates['passed'] = True

    # 14648 - 004 - Teacher | Create links to assigned readings in their LMS
    @pytest.mark.skipif(str(14648) not in TESTS, reason='Excluded')
    def test_teacher_create_links_to_assigned_readings_in_lms_14648(self):
        """Create links to assigned readings in their LMS.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the teacher user account in the username and password text boxes
        Click on the 'Sign in' button
        If the user has more than one course, click on a CC course name
        Click on a published reading assignment on the calendar dashboard
        Click "Get Assignment Link"

        Expected Result:
        The user is presented with links to assigned readings
        """
        self.ps.test_updates['name'] = 't2.05.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't2',
            't2.05',
            't2.05.004',
            '14648'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()

        self.teacher.select_course(appearance='physics')
        assert('calendar' in self.teacher.current_url()), \
            'Not viewing the calendar dashboard'

        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.ID, 'add-assignment')
            )
        ).click()
        self.teacher.find(By.PARTIAL_LINK_TEXT, 'Add Reading').click()
        assert('readings' in self.teacher.current_url()), \
            'Not on the add a homework page'

        self.teacher.find(
            By.XPATH, "//input[@id = 'reading-title']").send_keys('Epic 5-4')
        self.teacher.find(
            By.XPATH, "//input[@id = 'hide-periods-radio']").click()

        # Choose the second date calendar[1], first is calendar[0]
        self.teacher.driver.find_elements_by_xpath(
            "//div[@class = 'datepicker__input-container']")[1].click()
        while(self.teacher.find(
            By.XPATH,
            "//span[@class = 'datepicker__current-month']"
        ).text != 'December 2016'):
            self.teacher.find(
                By.XPATH, "//a[@class = 'datepicker__navigation datepicker__" +
                "navigation--next']").click()

        # Choose the due date of December 31, 2016
        weekends = self.teacher.driver.find_elements_by_xpath(
            "//div[@class = 'datepicker__day datepicker__day--weekend']")
        for day in weekends:
            if day.text == '31':
                due = day
                due.click()
                break

        self.teacher.sleep(3)

        # Choose reading sections
        self.teacher.find(
            By.XPATH, "//button[@id='reading-select']").click()
        self.teacher.find(
            By.XPATH, "//span[@class = 'chapter-checkbox']").click()
        self.teacher.find(
            By.XPATH,
            "//button[@class='-show-problems btn btn-primary']").click()
        self.teacher.sleep(10)

        # Publish the assignment
        self.teacher.driver.execute_script('window.scrollBy(0, -200);')
        self.teacher.find(
            By.XPATH,
            "//button[@class='async-button -publish btn btn-primary']").click()

        # Give the assignment time to publish
        self.teacher.sleep(60)

        assert('calendar' in self.teacher.current_url()), \
            'Not viewing the calendar dashboard'

        spans = self.teacher.driver.find_elements_by_tag_name('span')
        for element in spans:
            if element.text.endswith('2016'):
                month = element

        # Change the calendar date if necessary
        while (month.text != 'December 2016'):
            self.teacher.find(
                By.XPATH,
                "//a[@class = 'calendar-header-control next']").click()

        # Select the newly created assignment, get the LMS link, and delete it
        assignments = self.teacher.driver.find_elements_by_tag_name('label')
        for assignment in assignments:
            if assignment.text == 'Epic 5-4':
                assignment.click()
                self.teacher.find(
                    By.PARTIAL_LINK_TEXT, "Get assignment link").click()
                self.teacher.find(
                    By.XPATH,
                    "//div[@class = 'fade in lms-sharable-link popover top']")
                self.teacher.sleep(5)
                self.teacher.find(
                    By.XPATH,
                    "//a[@class='btn btn-default -edit-assignment']").click()
                self.teacher.sleep(5)
                self.teacher.find(
                    By.XPATH,
                    "//button[@class='async-button delete-link pull-" +
                    "right btn btn-default']").click()
                self.teacher.find(
                    By.XPATH, "//button[@class='btn btn-primary']").click()
                self.teacher.sleep(5)
                break

        self.teacher.driver.refresh()
        deleted = True

        # Verfiy the assignment was deleted
        spans = self.teacher.driver.find_elements_by_tag_name('span')
        for element in spans:
            if element.text.endswith('2016'):
                month = element

        while (month.text != 'December 2016'):
            self.teacher.find(
                By.XPATH,
                "//a[@class = 'calendar-header-control next']").click()

        assignments = self.teacher.driver.find_elements_by_tag_name('label')
        for assignment in assignments:
            if assignment.text == 'Epic 5-4':
                deleted = False
                break

        if deleted:
            self.ps.test_updates['passed'] = True

    # 14649 - 005 - Teacher | Create links to assigned homework in their LMS
    @pytest.mark.skipif(str(14649) not in TESTS, reason='Excluded')
    def test_teacher_create_links_to_assigned_homework_in_lms_14649(self):
        """Create links to assigned homework in their LMS.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the teacher user account in the username and password text boxes
        Click on the 'Sign in' button
        If the user has more than one course, click on a CC course name
        Click on a published homework assignment on the calendar dashboard
        Click "Get Assignment Link"

        Expected Result:
        The user is presented with links to assigned homework
        """
        self.ps.test_updates['name'] = 't2.05.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't2',
            't2.05',
            't2.05.005',
            '14649'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()

        self.teacher.select_course(appearance='physics')
        assert('calendar' in self.teacher.current_url()), \
            'Not viewing the calendar dashboard'

        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.ID, 'add-assignment')
            )
        ).click()
        self.teacher.find(By.PARTIAL_LINK_TEXT, 'Add Homework').click()
        assert('homeworks' in self.teacher.current_url()), \
            'Not on the add a homework page'

        self.teacher.find(
            By.XPATH, "//input[@id = 'reading-title']").send_keys('Epic 5-5')
        self.teacher.find(
            By.XPATH, "//input[@id = 'hide-periods-radio']").click()

        # Choose the second date calendar[1], first is calendar[0]
        self.teacher.driver.find_elements_by_xpath(
            "//div[@class = 'datepicker__input-container']")[1].click()
        while(self.teacher.find(
            By.XPATH,
            "//span[@class = 'datepicker__current-month']"
        ).text != 'December 2016'):
            self.teacher.find(
                By.XPATH, "//a[@class = 'datepicker__navigation datepicker__" +
                "navigation--next']").click()

        # Choose the due date of December 31, 2016
        weekends = self.teacher.driver.find_elements_by_xpath(
            "//div[@class = 'datepicker__day datepicker__day--weekend']")
        for day in weekends:
            if day.text == '31':
                due = day
                due.click()
                break

        self.teacher.sleep(3)

        # Open the select problem cards
        self.teacher.find(
            By.XPATH, "//button[@id = 'problems-select']").click()
        self.teacher.find(
            By.XPATH, "//span[@class = 'chapter-checkbox']").click()
        self.teacher.find(
            By.XPATH,
            "//button[@class='-show-problems btn btn-primary']").click()
        self.teacher.sleep(10)

        # Choose a problem for the assignment
        element = self.teacher.find(
            By.XPATH, "//div[@class = 'controls-overlay'][1]")
        actions = ActionChains(self.teacher.driver)
        actions.move_to_element(element)
        actions.perform()
        self.teacher.find(By.XPATH, "//div[@class = 'action include']").click()
        self.teacher.find(
            By.XPATH,
            "//button[@class='-review-exercises btn btn-primary']").click()
        self.teacher.sleep(2)

        # Publish the assignment
        self.teacher.driver.execute_script('window.scrollBy(0, -200);')
        self.teacher.find(
            By.XPATH,
            "//button[@class='async-button -publish btn btn-primary']").click()

        # Give the assignment time to publish
        self.teacher.sleep(60)

        assert('calendar' in self.teacher.current_url()), \
            'Not viewing the calendar dashboard'

        spans = self.teacher.driver.find_elements_by_tag_name('span')
        for element in spans:
            if element.text.endswith('2016'):
                month = element

        # Change the calendar date if necessary
        while (month.text != 'December 2016'):
            self.teacher.find(
                By.XPATH,
                "//a[@class = 'calendar-header-control next']").click()

        # Select the newly created assignment, get the LMS link, and delete it
        assignments = self.teacher.driver.find_elements_by_tag_name('label')
        for assignment in assignments:
            if assignment.text == 'Epic 5-5':
                assignment.click()
                self.teacher.find(
                    By.PARTIAL_LINK_TEXT, "Get assignment link").click()
                self.teacher.find(
                    By.XPATH,
                    "//div[@class = 'fade in lms-sharable-link popover top']")
                self.teacher.sleep(5)
                self.teacher.find(
                    By.XPATH,
                    "//a[@class='btn btn-default -edit-assignment']").click()
                self.teacher.sleep(5)
                self.teacher.find(
                    By.XPATH,
                    "//button[@class='async-button delete-link pull-" +
                    "right btn btn-default']").click()
                self.teacher.find(
                    By.XPATH, "//button[@class='btn btn-primary']").click()
                self.teacher.sleep(5)
                break

        self.teacher.driver.refresh()
        deleted = True

        # Verfiy the assignment was deleted
        spans = self.teacher.driver.find_elements_by_tag_name('span')
        for element in spans:
            if element.text.endswith('2016'):
                month = element

        while (month.text != 'December 2016'):
            self.teacher.find(
                By.XPATH,
                "//a[@class = 'calendar-header-control next']").click()

        assignments = self.teacher.driver.find_elements_by_tag_name('label')
        for assignment in assignments:
            if assignment.text == 'Epic 5-5':
                deleted = False
                break

        if deleted:
            self.ps.test_updates['passed'] = True

    # 14650 - 006 - Teacher | View instructions on how to export summary grade
    # for my student's OpenStax practice to my LMS
    @pytest.mark.skipif(str(14650) not in TESTS, reason='Excluded')
    def test_teacher_view_instructions_on_how_to_export_summary_14650(self):
        """View instructions on how to export summary grade into LMS.

        Steps:


        Expected Result:

        """
        self.ps.test_updates['name'] = 't2.05.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't2',
            't2.05',
            't2.05.006',
            '14650'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates['passed'] = True
 def setUp(self):
     """Pretest settings."""
     self.ps = PastaSauce()
     self.desired_capabilities['name'] = self.id()
     self.user = None
class TestChooseCourse(unittest.TestCase):
    """T1.38 - Choose Course."""

    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.user = None

    def tearDown(self):
        """Test destructor."""
        self.ps.update_job(
            job_id=str(self.user.driver.session_id),
            **self.ps.test_updates
        )
        try:
            self.user.delete()
        except:
            pass

    # Case C8254 - 001 - Student | Select a course
    @pytest.mark.skipif(str(8254) not in TESTS, reason='Excluded')
    def test_student_select_a_course_8254(self):
        """Select a course.

        Steps:
        Click on a Tutor course name

        Expected Result:
        The user selects a course and is presented with the dashboard.
        """
        self.ps.test_updates['name'] = 't1.38.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't1',
            't1.38',
            't1.38.001',
            '8254'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.user = Student(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.user.login()
        self.user.select_course(appearance='physics')

        assert('list' in self.user.current_url()), \
            'Not in a course'

        self.ps.test_updates['passed'] = True

    # Case C8255 - 002 - Student | Bypass the course picker
    @pytest.mark.skipif(str(8255) not in TESTS, reason='Excluded')
    def test_student_bypass_the_course_picker_8255(self):
        """Bypass the course picker.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the student user account qas_01
        Click on the 'Sign in' button

        Expected Result:
        The user bypasses the course picker and is presented with the
        dashboard (because qas_01 is only enrolled in one course)
        """
        self.ps.test_updates['name'] = 't1.38.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't1',
            't1.38',
            't1.38.002',
            '8255'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.user = Student(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.user.login(username="******")
        assert('list' in self.user.current_url()), \
            'Not in a course'

        self.ps.test_updates['passed'] = True

    # Case C8256 - 003 - Teacher | Select a course
    @pytest.mark.skipif(str(8256) not in TESTS, reason='Excluded')
    def test_teacher_select_a_course_8256(self):
        """Select a course.

        Steps:
        Click on a Tutor course name

        Expected Result:
        The user selects a course and is presented with the calendar dashboard
        """
        self.ps.test_updates['name'] = 't1.38.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't1',
            't1.38',
            't1.38.003',
            '8256'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.user = Teacher(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.user.login()
        self.user.select_course(appearance='physics')
        assert('calendar' in self.user.current_url()), \
            'Not in a course'

        self.ps.test_updates['passed'] = True

    # Case C8257 - 004 - Teacher | Bypass the course picker
    @pytest.mark.skipif(str(8257) not in TESTS, reason='Excluded')
    def test_teacher_bypass_the_course_picker_8257(self):
        """Bypass the course picker.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the teacher user account [ qateacher | password ] in the
            username and password text boxes
        Click on the 'Sign in' button

        Expected Result:
        The user bypasses the course picker and is presented with the
        calendar dashboard (because qateacher only has one course)
        """
        self.ps.test_updates['name'] = 't1.38.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't1',
            't1.38',
            't1.38.004',
            '8257'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.user = Teacher(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.user.login(username="******")
        assert('calendar' in self.user.current_url()), \
            'Not in a course'

        self.ps.test_updates['passed'] = True
class TestEditCourseSettingsAndRoster(unittest.TestCase):
    """T1.42 - Edit Course Settings and Roster."""

    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.teacher = Teacher(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.teacher.login()
        self.teacher.select_course(appearance='physics')
        self.teacher.open_user_menu()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.LINK_TEXT, 'Course Settings and Roster')
            )
        ).click()
        self.teacher.page.wait_for_page_load()

    def tearDown(self):
        """Test destructor."""
        self.ps.update_job(
            job_id=str(self.teacher.driver.session_id),
            **self.ps.test_updates
        )
        try:
            self.teacher.delete()
        except:
            pass

    # Case C8258 - 001 - Teacher | Edit the course name
    @pytest.mark.skipif(str(8258) not in TESTS, reason='Excluded')
    def test_teacher_edit_the_course_name_8258(self):
        """Edit the course name.

        Steps:
        Click the "Rename Course" button that is next to the course name
        Enter a new course name
        Click the "Rename" button
        Click the X that is on the upper right corner of the dialogue box

        Expected Result:
        The course name is edited.
        (then put it back at the end)
        """
        self.ps.test_updates['name'] = 't1.42.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.001', '8258']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        course_name = self.teacher.driver.find_element(
            By.XPATH,
            '//div[@class="course-settings-title"]/span'
        ).text
        self.teacher.find(
            By.XPATH, '//button[contains(@class,"edit-course")]' +
            '//span[contains(text(),"Rename Course")]'
        ).click()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//input[contains(@class,"form-control")]')
            )
        ).send_keys('_EDIT')
        self.teacher.find(
            By.XPATH,
            '//button[contains(@class,"edit-course-confirm")]'
        ).click()
        # check that it was edited
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//div[@class="course-settings-title"]' +
                 '/span[contains(text(),"%s_EDIT")]' % course_name)
            )
        )
        # set it back
        self.teacher.sleep(1)
        self.teacher.driver.find_element(
            By.XPATH,
            '//button[contains(@class,"edit-course")]' +
            '//span[contains(text(),"Rename Course")]'
        ).click()
        for _ in range(len('_EDIT')):
            self.teacher.wait.until(
                expect.element_to_be_clickable(
                    (By.XPATH, '//input[contains(@class,"form-control")]')
                )
            ).send_keys(Keys.BACK_SPACE)
        self.teacher.find(
            By.XPATH,
            '//button[contains(@class,"edit-course-confirm")]'
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//div[@class="course-settings-title"]' +
                 '/span[text()="%s"]' % course_name)
            )
        )

        self.ps.test_updates['passed'] = True

    # Case C8259 - 002 - Teacher | Remove an instructor from the course
    @pytest.mark.skipif(str(8259) not in TESTS, reason='Excluded')
    def test_teacher_remove_an_instructor_from_a_course_8259(self):
        """Remove an instructor from the course.

        Steps:
        Click "Remove" for an instructor under the Instructors section
        Click "Remove" on the box that pops up

        Expected Result:
        The instructor is removed from the Instructors list.
        """
        self.ps.test_updates['name'] = 't1.42.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.002', '8259']
        self.ps.test_updates['passed'] = False

        self.teacher.logout()
        # add extra instructor through admin first
        admin = Admin(
            use_env_vars=True,
            existing_driver=self.teacher.driver,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        admin.login()
        admin.get('https://tutor-qa.openstax.org/admin/courses/1/edit')
        admin.page.wait_for_page_load()
        teacher_name = 'Trent'
        admin.find(
            By.XPATH, '//a[contains(text(),"Teachers")]').click()
        admin.find(
            By.ID, 'course_teacher').send_keys(teacher_name)
        admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//li[contains(text(),"%s")]' % teacher_name)
            )
        ).click()
        admin.sleep(1)
        admin.find(
            By.LINK_TEXT, 'Main Dashboard').click()
        admin.page.wait_for_page_load()
        admin.logout()
        # redo set-up, but make sure to go to course 1
        self.teacher.login()
        self.teacher.get('https://tutor-qa.openstax.org/courses/1')
        self.teacher.open_user_menu()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.LINK_TEXT, 'Course Settings and Roster')
            )
        ).click()
        self.teacher.page.wait_for_page_load()
        # delete teacher
        teachers_list = self.teacher.find_all(
            By.XPATH, '//div[@class="teachers-table"]//tbody//tr')
        for x in range(len(teachers_list)):
            temp_first = self.teacher.find(
                By.XPATH,
                '//div[@class="teachers-table"]//tbody//tr[' +
                str(x + 1) + ']/td'
            ).text
            if temp_first == teacher_name:
                self.teacher.find(
                    By.XPATH,
                    '//div[@class="teachers-table"]//tbody//tr[' +
                    str(x + 1) + ']//td//span[contains(text(),"Remove")]'
                ).click()
                self.teacher.sleep(1)
                self.teacher.find(
                    By.XPATH, '//div[@class="popover-content"]//button'
                ).click()
                break
            if x == len(teachers_list) - 1:
                print('added teacher was not found, and not deleted')
                raise Exception
        deleted_teacher = self.teacher.driver.find_elements(
            By.XPATH, '//td[contains(text(),"%s")]' % teacher_name)
        assert(len(deleted_teacher) == 0), 'teacher not deleted'

        self.ps.test_updates['passed'] = True

    # Case C8260 - 003 - Teacher | Remove the last instructor from the course
    @pytest.mark.skipif(str(8260) not in TESTS, reason='Excluded')
    def test_teacher_remove_the_last_instructor_from_the_course_8260(self):
        """Remove the last instructor from the course.

        Steps:
        Click on the user menu in the upper right corner of the page
        Click "Course Roster"
        Click "Remove" for an instructor under the Instructors section
        Click "Remove" on the box that pops up

        Expected Result:
        The instructor is removed from the Instructors list.
        """
        self.ps.test_updates['name'] = 't1.42.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.003', '8260']
        self.ps.test_updates['passed'] = False

        raise NotImplementedError(inspect.currentframe().f_code.co_name)
        self.teacher.logout()
        # add extra instructor through admin first
        admin = Admin(
            use_env_vars=True,
            existing_driver=self.teacher.driver,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        admin.login()
        admin.get('https://tutor-qa.openstax.org/admin/courses/1/edit')
        admin.page.wait_for_page_load()
        teacher_name = 'Trent'
        admin.find(
            By.XPATH, '//a[contains(text(),"Teachers")]').click()
        admin.find(
            By.ID, 'course_teacher').send_keys(teacher_name)
        admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//li[contains(text(),"%s")]' % teacher_name)
            )
        ).click()
        admin.sleep(1)
        admin.find(
            By.LINK_TEXT, 'Main Dashboard').click()
        admin.page.wait_for_page_load()
        admin.logout()
        # redo set-up, but make sure to go to course 1
        self.teacher.login()
        self.teacher.get('https://tutor-qa.openstax.org/courses/1')
        self.teacher.open_user_menu()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.LINK_TEXT, 'Course Settings and Roster')
            )
        ).click()
        self.teacher.page.wait_for_page_load()
        # delete teacher
        teachers_list = self.teacher.find_all(
            By.XPATH, '//div[@class="teachers-table"]//tbody//tr')
        for x in range(len(teachers_list)):
            temp_first = self.teacher.find(
                By.XPATH,
                '//div[@class="teachers-table"]//tbody//tr[' +
                str(x + 1) + ']/td'
            ).text
            if temp_first == teacher_name:
                self.teacher.find(
                    By.XPATH,
                    '//div[@class="teachers-table"]//tbody//tr[' +
                    str(x + 1) + ']//td//span[contains(text(),"Remove")]'
                ).click()
                self.teacher.sleep(1)
                self.teacher.find(
                    By.XPATH, '//div[@class="popover-content"]//button'
                ).click()
                break
            if x == len(teachers_list) - 1:
                print('added teacher was not found, and not deleted')
                raise Exception
        deleted_teacher = self.teacher.driver.find_elements(
            By.XPATH, '//td[contains(text(),"%s")]' % teacher_name)
        assert(len(deleted_teacher) == 0), 'teacher not deleted'

        self.ps.test_updates['passed'] = True

    # Case C8261 - 004 - Teacher | Add a period
    @pytest.mark.skipif(str(8261) not in TESTS, reason='Excluded')
    def test_teacher_add_a_period_8261(self):
        """Add a period.

        Steps:
        Click "+ Add Period"
        Enter a period name into the Period Name text box
        Click "Add"

        Expected Result:
        A new period is added.
        """
        self.ps.test_updates['name'] = 't1.42.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.004', '8261']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        period_name = 'automated_' + str(randint(0, 999))
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"add-period")]//button').click()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//input[contains(@class,"form-control")]')
            )
        ).send_keys(period_name)
        self.teacher.find(
            By.XPATH,
            '//button[contains(@class,"edit-period-confirm")]'
        ).click()
        self.teacher.sleep(1)
        self.teacher.find(
            By.XPATH, '//a[contains(text(),"'+period_name+'")]')

        self.ps.test_updates['passed'] = True

    # Case C8262 - 005 - Teacher | Rename a period
    @pytest.mark.skipif(str(8262) not in TESTS, reason='Excluded')
    def test_teacher_rename_a_period_8262(self):
        """Rename a period.

        Steps:
        Click "Rename Period"
        Enter a new period name into the Period Name text box
        Click "Rename"

        Expected Result:
        A period is renamed.
        """
        self.ps.test_updates['name'] = 't1.42.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.005', '8262']
        self.ps.test_updates['passed'] = False

        # create a period
        period_name = 'automated_' + str(randint(0, 999))
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"add-period")]//button').click()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//input[contains(@class,"form-control")]')
            )
        ).send_keys(period_name)
        self.teacher.find(
            By.XPATH,
            '//button[contains(@class,"edit-period-confirm")]'
        ).click()
        self.teacher.sleep(1)
        # edit the period
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"'+period_name+'")]')
            )
        ).click()
        self.teacher.find(
            By.XPATH, '//span[contains(@class,"rename-period")]/button'
        ).click()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//input[contains(@class,"form-control")]')
            )
        ).send_keys('_EDIT')
        self.teacher.find(
            By.XPATH,
            '//button[contains(@class,"edit-period-confirm")]'
        ).click()
        self.teacher.sleep(1)
        self.teacher.find(
            By.XPATH, '//a[contains(text(),"'+period_name+'_EDIT")]')

        self.ps.test_updates['passed'] = True

    # Case C8263 - 006 - Teacher | Archive an empty period
    @pytest.mark.skipif(str(8263) not in TESTS, reason='Excluded')
    def test_teacher_archive_an_empt_period_8263(self):
        """Archive an empty period.

        Steps:
        Click on an empty period
        Click "Archive Period"
        Click "Archive" on the dialogue box

        Expected Result:
        An empty period is archived.
        """
        self.ps.test_updates['name'] = 't1.42.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.006', '8263']
        self.ps.test_updates['passed'] = False

        # create a period
        period_name = 'automated_' + str(randint(0, 999))
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"add-period")]//button').click()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//input[contains(@class,"form-control")]')
            )
        ).send_keys(period_name)
        self.teacher.find(
            By.XPATH,
            '//button[contains(@class,"edit-period-confirm")]'
        ).click()
        self.teacher.sleep(1)
        # edit the period
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"'+period_name+'")]')
            )
        ).click()
        self.teacher.find(
            By.XPATH, '//a[contains(@class,"archive-period")]').click()
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"popover-content")]' +
            '//button[contains(@class,"archive")]').click()
        self.teacher.sleep(2)
        archived_period = self.teacher.find_all(
            By.XPATH, '//a[contains(text(),"'+period_name+'")]')
        assert(len(archived_period) == 0), 'period not archived'

        self.ps.test_updates['passed'] = True

    # Case C8264 - 007 - Teacher | Archive a non-empty period
    @pytest.mark.skipif(str(8264) not in TESTS, reason='Excluded')
    def test_teacher_archive_a_non_empty_period_8264(self):
        """Archive a non-empty period.

        Steps:
        Click on a non-empty period
        Click "Archive Period"
        Click Archive

        Expected Result:
        Period is archived
        """
        self.ps.test_updates['name'] = 't1.42.007' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.007', '8264']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        period_name = self.teacher.find(
            By.XPATH, '//ul[@role="tablist"]//a[@role="tab"]').text
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"'+period_name+'")]')
            )
        ).click()
        self.teacher.find(
            By.XPATH, '//a[contains(@class,"archive-period")]').click()
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"popover-content")]' +
            '//button[contains(@class,"archive")]').click()
        self.teacher.find(
            By.XPATH, '//span[contains(text(),"View Archived")]').click()
        self.teacher.find(
            By.XPATH, '//div[@class="modal-body"]//td[contains(text(),"' +
            period_name + '")]')
        # add the section back
        periods = self.teacher.find_all(
            By.XPATH, '//div[@class="modal-body"]//table//tbody//tr')
        for x in range(len(periods)):
            temp_period = self.teacher.find(
                By.XPATH, '//div[@class="modal-body"]//table//tbody' +
                '//tr['+str(x+1)+']/td').text
            if temp_period == period_name:
                self.teacher.find(
                    By.XPATH,
                    '//div[@class="modal-body"]//table//tbody//tr[' +
                    str(x+1) + ']//button//span[contains(text(),"Unarchive")]'
                ).click()
                break

        self.ps.test_updates['passed'] = True

    # Case C8265 - 008 - Teacher | Move a student to another period
    @pytest.mark.skipif(str(8265) not in TESTS, reason='Excluded')
    def test_teacher_mover_a_student_to_another_period_8265(self):
        """Move a student to another period.

        Steps:
        Click on the user menu in the upper right corner of the page
        Click "Course Roster"
        Click "Change Period" for a student under the Roster section
        Click the desired period to move a student

        Expected Result:
        A student is moved to another period
        """
        self.ps.test_updates['name'] = 't1.42.008' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.008', '8265']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.find(
            By.XPATH, '//a[@aria-describedby="change-period"]').click()
        student_name = self.teacher.find(
            By.XPATH, '//div[@class="roster"]//td').text
        element = self.teacher.find(
            By.XPATH, '//div[@class="popover-content"]//a')
        period_name = element.text
        element.click()
        self.teacher.sleep(1)
        self.teacher.find(
            By.XPATH, '//li/a[contains(text(),"'+period_name+'")]').click()
        self.teacher.driver.find_element(
            By.XPATH, '//td[contains(text(),"%s")]' % student_name)

        self.ps.test_updates['passed'] = True

    # Case C8266 - 009 - Teacher | Drop a student
    @pytest.mark.skipif(str(8266) not in TESTS, reason='Excluded')
    def test_teacher_drop_a_student_8266(self):
        """Drop a student.

        Steps:
        Click on the user menu in the upper right corner of the page
        Click "Course Roster"
        Click "Drop" for a student under the Roster section
        Click "Drop" in the box that pops up

        Expected Result:
        A student is dropped from the course and
        is put under the Dropped Students section
        """
        self.ps.test_updates['name'] = 't1.42.009' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.009', '8266']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        student_name = self.teacher.find(
            By.XPATH, '//div[@class="roster"]//td').text
        self.teacher.find(
            By.XPATH, '//a[@aria-describedby="drop-student"]').click()
        self.teacher.find(
            By.XPATH, '//div[@class="popover-content"]//button').click()
        self.teacher.sleep(1)
        # check that student was droped
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"dropped-students")]' +
            '//td[contains(text(),"%s")]' % student_name
        )

        self.ps.test_updates['passed'] = True

    # Case C8267 - 010 - Teacher | Readd a dropped student
    @pytest.mark.skipif(str(8267) not in TESTS, reason='Excluded')
    def test_teacher_readd_a_dropped_student_8267(self):
        """Readd a dropped student.

        Steps:
        Click "Add Back to Active Roster" for a student under
            the Dropped Students section
        Click "Add" on the box that pops up

        Expected Result:
        A student is added back to the course
        """
        self.ps.test_updates['name'] = 't1.42.010' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.010', '8267']
        self.ps.test_updates['passed'] = False

        # drop a student (to make sure there is someone to add back)
        student_name = self.teacher.find(
            By.XPATH, '//div[@class="roster"]//td').text
        self.teacher.find(
            By.XPATH, '//a[@aria-describedby="drop-student"]').click()
        self.teacher.find(
            By.XPATH, '//div[@class="popover-content"]//button').click()
        self.teacher.sleep(1)
        # add a student back (not necessarily the same student)
        element = self.teacher.find(
            By.XPATH, '//div[contains(@class,"dropped-students")]' +
            '//span[contains(text(),"Add Back to Active Roster")]')
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', element)
        self.teacher.driver.execute_script('window.scrollBy(0, -80);')
        element.click()
        self.teacher.find(
            By.XPATH, '//div[@class="popover-content"]//button').click()
        # check that student was added back
        self.teacher.find(
            By.XPATH,
            '//div[@class="roster"]//td[contains(text(),"%s")]' % student_name)

        self.ps.test_updates['passed'] = True

    # Case C58356 - 011 - Teacher | Unarchive an empty period
    @pytest.mark.skipif(str(58356) not in TESTS, reason='Excluded')
    def test_teacher_unarchive_an_empty_period_58356(self):
        """Unarchive an empty period.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the teacher user account [ teacher001 ] and password in the boxes
        Click on the 'Sign in' button
        If the user has more than one course, click on a Tutor course name
        Click on the user menu in the upper right corner of the page
        Click "Course Settings and Roster"
        Click "View Archived Period(s)"
        Click Unarchived period next to selected course

        Expected Result:
        Period is made active.
        """
        self.ps.test_updates['name'] = 't1.42.011' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.011', '58356']
        self.ps.test_updates['passed'] = False

        # create a period
        period_name = 'automated_011_' + str(randint(0, 999))
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"add-period")]//button').click()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//input[contains(@class,"form-control")]')
            )
        ).send_keys(period_name)
        self.teacher.find(
            By.XPATH,
            '//button[contains(@class,"edit-period-confirm")]'
        ).click()
        self.teacher.sleep(1)
        # archive the period
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"'+period_name+'")]')
            )
        ).click()
        self.teacher.find(
            By.XPATH, '//a[contains(@class,"archive-period")]').click()
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"popover-content")]' +
            '//button[contains(@class,"archive")]').click()
        self.teacher.sleep(2)
        archived_period = self.teacher.find_all(
            By.XPATH, '//a[contains(text(),"'+period_name+'")]')
        assert(len(archived_period) == 0), 'period not archived'
        # unarchive the period
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"view-archived-periods")]//button'
        ).click()
        self.teacher.sleep(1)
        rows = self.teacher.find_all(
            By.XPATH, '//div[@class="modal-content"]//tbody/tr')
        for row in rows:
            temp_name = row.find_element(By.XPATH, "./td[1]").text
            if temp_name == period_name:
                row.find_element(
                    By.XPATH,
                    "./td[3]//button[contains(@class,'unarchive-section')]"
                ).click()
                self.teacher.find(
                    By.XPATH,
                    '//div[@class="modal-content"]//button[@class="close"]'
                ).click()
                break
        # check that period is no longer archived
        self.teacher.find(
            By.XPATH, '//a[contains(text(),"'+period_name+'")]')

        self.ps.test_updates['passed'] = True
class TestCourseMaintenance(unittest.TestCase):
    """T1.57 - Course Maintenance."""
    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.admin = Admin(use_env_vars=True,
                           pasta_user=self.ps,
                           capabilities=self.desired_capabilities)
        self.admin.login()
        self.admin.goto_admin_control()
        self.admin.sleep(5)

    def tearDown(self):
        """Test destructor."""
        if not LOCAL_RUN:
            self.ps.update_job(job_id=str(self.admin.driver.session_id),
                               **self.ps.test_updates)
        try:
            self.admin.delete()
        except:
            pass

    # Case C8311 - 001 - Admin | Import courses from Salesforece
    @pytest.mark.skipif(str(8311) not in TESTS, reason='Excluded')
    def test_admin_import_courses_from_salesforce_8311(self):
        """Import courses from Salesforce.

        Steps:
        Click on the user menu
        Click on the Admin option
        Click on Salesforce on the header
        Click on the Import Courses button

        Expected Result:

        """
        self.ps.test_updates['name'] = 't1.57.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.001', '8311']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates['passed'] = True

    # Case C8312 - 002 - Admin | Update Salesforce Staistics
    @pytest.mark.skipif(str(8312) not in TESTS, reason='Excluded')
    def test_admin_update_salesforce_statistice_8312(self):
        """Update Salesforce statistics.

        Steps:
        Click on the user menu
        Click on the Admin option
        Click on Salesforce on the header
        Click on Update Salesforce

        Expected Result:

        """
        self.ps.test_updates['name'] = 't1.57.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.002', '8312']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates['passed'] = True

    # Case C8313 - 003 - Admin | Exclude assesments from all courses
    @pytest.mark.skipif(str(8313) not in TESTS, reason='Excluded')
    def test_admin_exclude_assesments_from_all_courses_8313(self):
        """Exclude assesments from all courses.

        Steps:

        Expected Result:
        """
        self.ps.test_updates['name'] = 't1.57.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.003', '8313']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates['passed'] = True

    # Case C8314 - 004 - Admin | Add a system notification
    @pytest.mark.skipif(str(8314) not in TESTS, reason='Excluded')
    def test_admin_add_a_system_notification_8314(self):
        """Add a system notification.

        Steps:
        Click on the user menu
        Click on the Admin option
        Click on System Setting on the header
        Click on the Notifications option
        Enter a notification into the New Notification text box
        Click on the Add button

        Expected Result:
        A system notification is added
        """
        self.ps.test_updates['name'] = 't1.57.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.004', '8314']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'System Setting'))).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Notifications'))).click()
        self.admin.sleep(5)

        self.admin.find(
            By.XPATH, "//input[@id='new_message']").send_keys('automated test')

        self.admin.find(By.XPATH, "//input[@class='btn btn-default']").click()

        self.admin.sleep(5)

        notif = self.admin.driver.find_elements_by_xpath(
            "//div[@class='col-xs-12']")

        for index, n in enumerate(notif):
            if n.text.find('automated test') >= 0:
                self.admin.driver.find_elements_by_xpath(
                    "//a[@class='btn btn-warning']")[index].click()
                self.admin.driver.switch_to_alert().accept()
                self.ps.test_updates['passed'] = True
                break

    # Case C8315 - 005 - Admin | Delete a system notification
    @pytest.mark.skipif(str(8315) not in TESTS, reason='Excluded')
    def test_admin_delete_a_system_notification_8315(self):
        """Delete a system notification.

        Steps:
        Click on the user menu
        Click on the Admin option
        Click on System Setting on the header
        Click on the Notifications option
        Click on the Remove button next to a notification
        Click OK on the dialouge box

        Expected Result:
        A system notification is deleted
        """
        self.ps.test_updates['name'] = 't1.57.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.005', '8315']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'System Setting'))).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Notifications'))).click()
        self.admin.sleep(5)

        self.admin.find(
            By.XPATH, "//input[@id='new_message']").send_keys('automated test')

        self.admin.find(By.XPATH, "//input[@class='btn btn-default']").click()

        self.admin.sleep(5)

        notif = self.admin.driver.find_elements_by_xpath(
            "//div[@class='col-xs-12']")

        for index, n in enumerate(notif):
            if n.text.find('automated test') >= 0:
                self.admin.driver.find_elements_by_xpath(
                    "//a[@class='btn btn-warning']")[index].click()
                self.admin.driver.switch_to_alert().accept()
                break

        deleted = True

        notif = self.admin.driver.find_elements_by_xpath(
            "//div[@class='col-xs-12']")

        for n in notif:
            if n.text.find('automated test') >= 0:
                deleted = False
                break

        if deleted:
            self.ps.test_updates['passed'] = True

    # Case C112519 - 006 - Admin | Add an instructor-only system notification
    @pytest.mark.skipif(str(112519) not in TESTS, reason='Excluded')
    def test_admin_add_instructor_notification_112519(self):
        """Add an instructor-only system notification.

        Steps:

        Expected Result:

        """
        self.ps.test_updates['name'] = 't1.57.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.006', '112519']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'System Setting'))).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Notifications'))).click()
        self.admin.sleep(5)

        self.admin.find(
            By.XPATH,
            "//div[3]//input[@id='message']").send_keys('automated test')

        self.admin.driver.find_elements_by_xpath(
            "//input[@class='btn btn-default']")[1].click()

        self.admin.sleep(5)

        notif = self.admin.driver.find_elements_by_xpath(
            "//div[@class='col-xs-12']")

        for index, n in enumerate(notif):
            if n.text.find('automated test') >= 0:
                self.admin.driver.find_elements_by_xpath(
                    "//a[@class='btn btn-warning']")[index].click()
                self.admin.driver.switch_to_alert().accept()
                self.ps.test_updates['passed'] = True
                break

        self.admin.sleep(5)

        self.ps.test_updates['passed'] = True

    # Case C112520 - 007 - Admin | Delete a instructor-only system notification
    @pytest.mark.skipif(str(112520) not in TESTS, reason='Excluded')
    def test_admin_delete_instructor_notification_112520(self):
        """Delete an instructor-only system notification.

        Steps:

        Expected Result:

        """
        self.ps.test_updates['name'] = 't1.57.007' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.007', '112520']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'System Setting'))).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Notifications'))).click()
        self.admin.sleep(5)

        self.admin.find(
            By.XPATH,
            "//div[3]//input[@id='message']").send_keys('automated test')

        self.admin.driver.find_elements_by_xpath(
            "//input[@class='btn btn-default']")[1].click()

        self.admin.sleep(5)

        notif = self.admin.driver.find_elements_by_xpath(
            "//div[@class='col-xs-12']")

        for index, n in enumerate(notif):
            if n.text.find('automated test') >= 0:
                self.admin.driver.find_elements_by_xpath(
                    "//a[@class='btn btn-warning']")[index].click()
                self.admin.driver.switch_to_alert().accept()
                self.ps.test_updates['passed'] = True
                break

        self.admin.sleep(5)

        deleted = True

        notif = self.admin.driver.find_elements_by_xpath(
            "//div[@class='col-xs-12']")

        for n in notif:
            if n.text.find('automated test') >= 0:
                deleted = False
                break

        assert (deleted), 'notification not deleted'

        self.ps.test_updates['passed'] = True

    # Case C112521 - 008 - Student | View an active system notification
    @pytest.mark.skipif(str(112521) not in TESTS, reason='Excluded')
    def test_student_view_active_notification_112521(self):
        """View an active system notification.

        Steps:

        Expected Result: //div[@class='notification system']/span

        """
        self.ps.test_updates['name'] = 't1.57.008' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.008', '112521']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions

        # Create notification
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'System Setting'))).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Notifications'))).click()
        self.admin.sleep(5)

        self.admin.find(By.XPATH,
                        "//input[@id='message']").send_keys('automated test')

        self.admin.driver.find_elements_by_xpath(
            "//input[@class='btn btn-default']")[0].click()

        self.admin.sleep(5)

        # View notification as student
        student = Student(use_env_vars=True)
        student.login()
        student.select_course(appearance='physics')
        student.sleep(10)
        notifs = student.driver.find_elements_by_xpath(
            "//div[@class='notification system']/span")

        found = False

        for notif in notifs:
            if notif.text.find("automated test") >= 0:
                found = True

        student.delete()

        # Delete notification
        notif = self.admin.driver.find_elements_by_xpath(
            "//div[@class='col-xs-12']")

        for index, n in enumerate(notif):
            if n.text.find('automated test') >= 0:
                self.admin.driver.find_elements_by_xpath(
                    "//a[@class='btn btn-warning']")[index].click()
                self.admin.driver.switch_to_alert().accept()
                self.ps.test_updates['passed'] = True
                break

        self.admin.sleep(5)

        notif = self.admin.driver.find_elements_by_xpath(
            "//div[@class='col-xs-12']")

        assert (found), 'notification not seen'

        self.ps.test_updates['passed'] = True

    # Case C112522 - 009 - Teacher | View an active system notification
    @pytest.mark.skipif(str(112522) not in TESTS, reason='Excluded')
    def test_teacher_view_active_notification_112522(self):
        """View an active system notification.

        Steps:

        Expected Result:

        """
        self.ps.test_updates['name'] = 't1.57.009' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.009', '112522']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'System Setting'))).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Notifications'))).click()
        self.admin.sleep(5)

        self.admin.find(By.XPATH,
                        "//input[@id='message']").send_keys('automated test')

        self.admin.driver.find_elements_by_xpath(
            "//input[@class='btn btn-default']")[0].click()

        self.admin.sleep(5)

        # View notification as student
        teacher = Teacher(use_env_vars=True)
        teacher.login()
        teacher.select_course(appearance='physics')
        teacher.sleep(10)
        notifs = teacher.driver.find_elements_by_xpath(
            "//div[@class='notification system']/span")

        found = False

        for notif in notifs:
            if notif.text.find("automated test") >= 0:
                found = True

        teacher.delete()

        # Delete notification
        notif = self.admin.driver.find_elements_by_xpath(
            "//div[@class='col-xs-12']")

        for index, n in enumerate(notif):
            if n.text.find('automated test') >= 0:
                self.admin.driver.find_elements_by_xpath(
                    "//a[@class='btn btn-warning']")[index].click()
                self.admin.driver.switch_to_alert().accept()
                self.ps.test_updates['passed'] = True
                break

        self.admin.sleep(5)

        notif = self.admin.driver.find_elements_by_xpath(
            "//div[@class='col-xs-12']")

        assert (found), 'notification not seen'

        self.ps.test_updates['passed'] = True

    # Case C112523 - 010 - Teacher | View an active instructor-only
    # system notification
    @pytest.mark.skipif(str(112523) not in TESTS, reason='Excluded')
    def test_teacher_view_instructor_notification_112523(self):
        """View an active instructor-only system notification.

        Steps:

        Expected Result:

        """
        self.ps.test_updates['name'] = 't1.57.010' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.010', '112523']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'System Setting'))).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Notifications'))).click()
        self.admin.sleep(5)

        self.admin.find(
            By.XPATH,
            "//div[3]//input[@id='message']").send_keys('automated test')

        self.admin.driver.find_elements_by_xpath(
            "//input[@class='btn btn-default']")[1].click()

        self.admin.sleep(5)

        # View notification as student
        teacher = Teacher(use_env_vars=True)
        teacher.login()
        teacher.select_course(appearance='physics')
        teacher.sleep(10)
        notifs = teacher.driver.find_elements_by_xpath(
            "//div[@class='notification system']/span")

        found = False

        for notif in notifs:
            if notif.text.find("automated test") >= 0:
                found = True

        teacher.delete()

        # Delete notification
        notif = self.admin.driver.find_elements_by_xpath(
            "//div[@class='col-xs-12']")

        for index, n in enumerate(notif):
            if n.text.find('automated test') >= 0:
                self.admin.driver.find_elements_by_xpath(
                    "//a[@class='btn btn-warning']")[index].click()
                self.admin.driver.switch_to_alert().accept()
                self.ps.test_updates['passed'] = True
                break

        self.admin.sleep(5)

        notif = self.admin.driver.find_elements_by_xpath(
            "//div[@class='col-xs-12']")

        assert (found), 'notification not seen'

        self.ps.test_updates['passed'] = True
class TestWorkAnExternalAssignment(unittest.TestCase):
    """T1.48 - Work an external assignment."""

    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.student = Student(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.teacher = Teacher(
            use_env_vars=True,
            existing_driver=self.student.driver,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.teacher.login()

        # Create an external assignment for the student to work
        self.teacher.select_course(appearance='physics')
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.ID, 'add-assignment')
            )
        ).click()
        self.teacher.find(
            By.PARTIAL_LINK_TEXT, 'Add External Assignment').click()
        assert('externals/new' in self.teacher.current_url()), \
            'Not on the add an external assignment page'

        self.teacher.find(
            By.XPATH, "//input[@id = 'reading-title']").send_keys('Epic 48')
        self.teacher.find(
            By.XPATH, "//textarea[@class='form-control empty']").send_keys(
            "instructions go here")
        self.teacher.find(
            By.XPATH, "//input[@id = 'hide-periods-radio']").click()

        # Choose the first date calendar[0], second is calendar[1]
        # and set the open date to today
        self.teacher.driver.find_elements_by_xpath(
            "//div[@class = 'datepicker__input-container']")[0].click()
        self.teacher.driver.find_element_by_xpath(
            "//div[@class = 'datepicker__day datepicker__day--today']").click()

        # Choose the second date calendar[1], first is calendar[0]
        self.teacher.driver.find_elements_by_xpath(
            "//div[@class = 'datepicker__input-container']")[1].click()
        while(self.teacher.find(
            By.XPATH,
            "//span[@class = 'datepicker__current-month']"
        ).text != 'December 2016'):
            self.teacher.find(
                By.XPATH,
                "//a[@class = 'datepicker__navigation datepicker__" +
                "navigation--next']").click()

        # Choose the due date of December 31, 2016
        weekends = self.teacher.driver.find_elements_by_xpath(
            "//div[@class = 'datepicker__day datepicker__day--weekend']")
        for day in weekends:
            if day.text == '31':
                due = day
                due.click()
                break

        self.teacher.find(By.XPATH, "//input[@id='external-url']").send_keys(
            "google.com")
        self.teacher.sleep(5)

        # Publish the assignment
        self.teacher.find(
            By.XPATH,
            "//button[@class='async-button -publish btn btn-primary']").click()
        self.teacher.sleep(60)
        self.student.login()

    def tearDown(self):
        """Test destructor."""
        self.ps.update_job(
            job_id=str(self.student.driver.session_id),
            **self.ps.test_updates
        )
        try:

            # Delete the assignment
            assert('calendar' in self.teacher.current_url()), \
                'Not viewing the calendar dashboard'

            spans = self.teacher.driver.find_elements_by_tag_name('span')
            for element in spans:
                if element.text.endswith('2016'):
                    month = element

            # Change the calendar date if necessary
            while (month.text != 'December 2016'):
                self.teacher.find(
                    By.XPATH,
                    "//a[@class = 'calendar-header-control next']").click()

            # Select the newly created assignment and delete it
            assignments = self.teacher.driver.find_elements_by_tag_name(
                'label')
            for assignment in assignments:
                if assignment.text == 'Epic 48':
                    assignment.click()
                    self.teacher.find(
                        By.XPATH,
                        "//a[@class='btn btn-default -edit-assignment']"
                    ).click()
                    self.teacher.find(
                        By.XPATH,
                        "//button[@class='async-button delete-link " +
                        "pull-right btn btn-default']").click()
                    self.teacher.find(
                        By.XPATH, "//button[@class='btn btn-primary']").click()
                    self.teacher.sleep(5)
                    break
        except:
            pass
        try:
            self.teacher.driver.refresh()
            self.teacher.sleep(5)

            self.teacher = None
            self.student.delete()
        except:
            pass

    # Case C8281 - 001 - Student | Click on an external assignment
    @pytest.mark.skipif(str(8281) not in TESTS, reason='Excluded')
    def test_student_click_on_a_external_assignment_8281(self):
        """Click on an external assignment.

        Steps:
        Click on an external assignment under the tab "This Week"
        on the dashboard

        Expected Result:
        The user is presented with the assignment link and instructions
        """
        self.ps.test_updates['name'] = 't1.48.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't1',
            't1.48',
            't1.48.001',
            '8281'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.select_course(appearance='physics')
        assert('list' in self.student.current_url()), \
            'Not viewing the calendar dashboard'

        assignments = self.student.driver.find_elements_by_xpath(
            "//div[@class='task row external workable']")
        for assignment in assignments:
            if (assignment.text.find('Epic 48') >= 0):
                assignment.click()
                break

        assert('tasks' in self.student.current_url()), \
            'Not viewing assignment page'

        assert('steps' in self.student.current_url()), \
            'Not viewing assignment page'

        self.student.sleep(5)

        self.ps.test_updates['passed'] = True

    # Case C8282 - 002 - Student | Read the directions below the assignment
    # link or hover over the info icon in the footer
    @pytest.mark.skipif(str(8282) not in TESTS, reason='Excluded')
    def test_student_read_directions_below_or_hover_over_info_icon_8282(self):
        """Read directions below assignment link or hover over the info icon.

        Steps:
        Click on an external assignment under the tab "This Week"
            on the dashboard
        Hover the cursor over the info icon in the footer

        Expected Result:
        The user is presented with the directions for the assignment
        """
        self.ps.test_updates['name'] = 't1.48.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't1',
            't1.48',
            't1.48.002',
            '8282'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.select_course(appearance='physics')
        assert('list' in self.student.current_url()), \
            'Not viewing the calendar dashboard'

        assignments = self.student.driver.find_elements_by_xpath(
            "//div[@class='task row external workable']")
        for assignment in assignments:
            if (assignment.text.find('Epic 48') >= 0):
                assignment.click()
                break

        assert('tasks' in self.student.current_url()), \
            'Not viewing assignment page'

        assert('steps' in self.student.current_url()), \
            'Not viewing assignment page'

        instructions = self.student.driver.find_elements_by_tag_name("p")
        flag = False
        for instruction in instructions:
            if (instruction.text == 'instructions go here'):
                flag = True
                break

        assert(flag), \
            'Did not read instructions'

        self.ps.test_updates['passed'] = True

    # Case C8283 - 003 - Student | Click the assignment link
    @pytest.mark.skipif(str(8283) not in TESTS, reason='Excluded')
    def test_student_click_the_assignment_link_8283(self):
        """Click the assignment link.

        Steps:
        Click on an external assignment under the tab "This Week"
            on the dashboard
        Click on the link to the external assignment

        Expected Result:
        The user is presented with the external assignment
        """
        self.ps.test_updates['name'] = 't1.48.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't1',
            't1.48',
            't1.48.003',
            '8283'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.select_course(appearance='physics')
        assert('list' in self.student.current_url()), \
            'Not viewing the calendar dashboard'

        assignments = self.student.driver.find_elements_by_xpath(
            "//div[@class='task row external workable']")
        for assignment in assignments:
            if (assignment.text.find('Epic 48') >= 0):
                assignment.click()
                break

        assert('tasks' in self.student.current_url()), \
            'Not viewing assignment page'

        assert('steps' in self.student.current_url()), \
            'Not viewing assignment page'

        link = self.student.driver.find_element_by_link_text(
            'Epic 48')
        original = self.student.current_url()
        self.student.driver.get(link.get_attribute("href"))

        assert('google' in self.student.current_url()), \
            'Not viewing assignment link'

        self.student.sleep(5)
        self.student.driver.get(original)

        assert('tasks' in self.student.current_url()), \
            'Not viewing assignment page'

        assert('steps' in self.student.current_url()), \
            'Not viewing assignment page'

        self.ps.test_updates['passed'] = True

    # Case C8284 - 004 - Student | Close the assignment tab or window
    @pytest.mark.skipif(str(8284) not in TESTS, reason='Excluded')
    def test_student_close_the_assignment_8284(self):
        """Close the assignment tab or window.

        Steps:
        Click on an external assignment under the tab "This Week"
            on the dashboard
        Click on the link to the external assignment
        Close the assignment tab

        Expected Result:
        The assignment tab is closed and the user is presented with the
        external assignment link and instructions on Tutor
        """
        self.ps.test_updates['name'] = 't1.48.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't1',
            't1.48',
            't1.48.004',
            '8284'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.select_course(appearance='physics')
        assert('list' in self.student.current_url()), \
            'Not viewing the calendar dashboard'

        assignments = self.student.driver.find_elements_by_xpath(
            "//div[@class='task row external workable']")
        for assignment in assignments:
            if (assignment.text.find('Epic 48') >= 0):
                assignment.click()
                break

        assert('tasks' in self.student.current_url()), \
            'Not viewing assignment page'

        assert('steps' in self.student.current_url()), \
            'Not viewing assignment page'

        link = self.student.driver.find_element_by_link_text(
            'Epic 48')
        original = self.student.current_url()
        self.student.driver.get(link.get_attribute("href"))

        assert('google' in self.student.current_url()), \
            'Not viewing assignment link'

        self.student.sleep(5)
        self.student.driver.get(original)

        assert('tasks' in self.student.current_url()), \
            'Not viewing assignment page'

        assert('steps' in self.student.current_url()), \
            'Not viewing assignment page'

        self.ps.test_updates['passed'] = True

    # Case C8285 - 005 - Student | Click the Back To Dashboard button to
    # finish the assignment
    @pytest.mark.skipif(str(8285) not in TESTS, reason='Excluded')
    def test_student_click_back_to_dashboard_button_8285(self):
        """Click the Back To Dashboard button to finish the assignment.

        Steps:
        Click on an external assignment under the tab "This Week"
            on the dashboard
        Click on the link to the external assignment
        Close the assignment tab
        Click "Back To Dashboard"

        Expected Result:
        The user is presented with the dashboard
        """
        self.ps.test_updates['name'] = 't1.48.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't1',
            't1.48',
            't1.48.005',
            '8285'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.select_course(appearance='physics')
        assert('list' in self.student.current_url()), \
            'Not viewing the calendar dashboard'

        assignments = self.student.driver.find_elements_by_xpath(
            "//div[@class='task row external workable']")
        for assignment in assignments:
            if (assignment.text.find('Epic 48') >= 0):
                assignment.click()
                break

        assert('tasks' in self.student.current_url()), \
            'Not viewing assignment page'

        assert('steps' in self.student.current_url()), \
            'Not viewing assignment page'

        link = self.student.driver.find_element_by_link_text(
            'Epic 48')
        original = self.student.current_url()
        self.student.driver.get(link.get_attribute("href"))

        assert('google' in self.student.current_url()), \
            'Not viewing assignment link'

        self.student.sleep(5)
        self.student.driver.get(original)

        assert('tasks' in self.student.current_url()), \
            'Not viewing assignment page'

        assert('steps' in self.student.current_url()), \
            'Not viewing assignment page'

        self.student.find(By.LINK_TEXT, 'Back To Dashboard').click()

        assert('list' in self.student.current_url()), \
            'Not viewing the calendar dashboard'

        self.ps.test_updates['passed'] = True

    # Case C8286 - 006 - Student | Verify the assignment status as Clicked
    @pytest.mark.skipif(str(8286) not in TESTS, reason='Excluded')
    def test_student_verify_assignment_status_as_clicked_8286(self):
        """Verify the assignment status as Clicked.

        Steps:
        Click on an external assignment under the tab "This Week"
            on the dashboard
        Click on the link to the external assignment
        Close the assignment tab
        Click "Back To Dashboard"

        Expected Result:
        The external assignment is marked as "Clicked" in the Progress column
        on the dashboard
        """
        self.ps.test_updates['name'] = 't1.48.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            't1',
            't1.48',
            't1.48.006',
            '8286'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.select_course(appearance='physics')
        assert('list' in self.student.current_url()), \
            'Not viewing the calendar dashboard'

        assignments = self.student.driver.find_elements_by_xpath(
            "//div[@class='task row external workable']")
        for assignment in assignments:
            if (assignment.text.find('Epic 48') >= 0):
                assignment.click()
                break

        assert('tasks' in self.student.current_url()), \
            'Not viewing assignment page'

        assert('steps' in self.student.current_url()), \
            'Not viewing assignment page'

        link = self.student.driver.find_element_by_link_text(
            'Epic 48')
        original = self.student.current_url()
        self.student.driver.get(link.get_attribute("href"))

        assert('google' in self.student.current_url()), \
            'Not viewing assignment link'

        self.student.sleep(5)
        self.student.driver.get(original)

        assert('tasks' in self.student.current_url()), \
            'Not viewing assignment page'

        assert('steps' in self.student.current_url()), \
            'Not viewing assignment page'

        self.student.find(By.LINK_TEXT, 'Back To Dashboard').click()

        assert('list' in self.student.current_url()), \
            'Not viewing the calendar dashboard'

        externals = self.student.driver.find_elements_by_xpath(
            "//div[@class = 'task row external workable']")

        for assignment in externals:
            if assignment.text.find("Clicked") >= 0 \
                    and assignment.text.find("Epic 48") >= 0:
                self.ps.test_updates['passed'] = True
                break
Beispiel #56
0
class TestTutorTeacher(unittest.TestCase):
    ''''''
    def setUp(self):
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.teacher = Teacher(use_env_vars=True)
        self.helper = StaxHelper(driver_type='chrome', pasta_user=self.ps,
                                 capabilities=self.desired_capabilities,
                                 initial_user=self.teacher)
        self.driver = self.helper.driver
        self.wait = WebDriverWait(self.driver, StaxHelper.DEFAULT_WAIT_TIME)
        self.driver.set_window_size(*standard_window)
        self.teacher.login(self.driver)
        self.teacher.select_course(self.driver, category='physics')
        self.rword = Assignment.rword
        self.screenshot_path = '/tmp/errors/'

    def tearDown(self):
        # Returns the info of exception being handled
        has_errors = self._test_has_failed()
        if has_errors:
            print(self.driver.current_url, '\n')
            date_and_time = datetime.now().strftime('%Y-%m-%d_%H-%M-%S-%f')
            filename = 'testerr_%s.png' % date_and_time
            self.driver.save_screenshot('%s%s' % (self.screenshot_path,
                                        filename))
        try:
            self.driver = None
            self.helper.driver.quit()
        except AttributeError:
            pass
        self.ps.update_job(self.driver.session_id, passed=has_errors)

    def _test_has_failed(self):
        # for 3.4. In 3.3, can just use self._outcomeForDoCleanups.success:
        for method, error in self._outcome.errors:
            if error:
                return True
        return False

    def test_teacher_views_calendar(self):
        ''''''
        today = date.today()
        today = today.strftime('%B %Y')
        cal_date = self.wait.until(
            expect.presence_of_element_located(
                (By.XPATH,
                 '//div[contains(@class,"calendar-header-label")]' +
                 '/span')
            )
        ).text
        assert(cal_date == today), 'Calendar date is not %s' % today

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_student_scores(self):
        ''''''
        # click on student scores
        self.helper.user.goto_student_scores(self.driver)

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_reference_book(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_class_roster(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_removes_a_student_from_class(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_moves_a_student_between_periods(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_reading_analytics_aggregate(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_performance_forecast_aggregate(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_single_student_performance_forecast(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_external_summary(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_homework_summary(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_reading_summary(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_event_summary(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_review_summary(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_single_student_homework(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_class_homework_details(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_single_student_reading(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_class_reading_details(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_single_student_review(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_views_class_review_details(self):
        ''''''

    @pytest.mark.skipif(NOT_STARTED, reason='Not started')
    def test_teacher_export_matches_student_scores(self):
        ''''''
    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.student = Student(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.teacher = Teacher(
            use_env_vars=True,
            existing_driver=self.student.driver,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.teacher.login()

        # Create an external assignment for the student to work
        self.teacher.select_course(appearance='physics')
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.ID, 'add-assignment')
            )
        ).click()
        self.teacher.find(
            By.PARTIAL_LINK_TEXT, 'Add External Assignment').click()
        assert('externals/new' in self.teacher.current_url()), \
            'Not on the add an external assignment page'

        self.teacher.find(
            By.XPATH, "//input[@id = 'reading-title']").send_keys('Epic 48')
        self.teacher.find(
            By.XPATH, "//textarea[@class='form-control empty']").send_keys(
            "instructions go here")
        self.teacher.find(
            By.XPATH, "//input[@id = 'hide-periods-radio']").click()

        # Choose the first date calendar[0], second is calendar[1]
        # and set the open date to today
        self.teacher.driver.find_elements_by_xpath(
            "//div[@class = 'datepicker__input-container']")[0].click()
        self.teacher.driver.find_element_by_xpath(
            "//div[@class = 'datepicker__day datepicker__day--today']").click()

        # Choose the second date calendar[1], first is calendar[0]
        self.teacher.driver.find_elements_by_xpath(
            "//div[@class = 'datepicker__input-container']")[1].click()
        while(self.teacher.find(
            By.XPATH,
            "//span[@class = 'datepicker__current-month']"
        ).text != 'December 2016'):
            self.teacher.find(
                By.XPATH,
                "//a[@class = 'datepicker__navigation datepicker__" +
                "navigation--next']").click()

        # Choose the due date of December 31, 2016
        weekends = self.teacher.driver.find_elements_by_xpath(
            "//div[@class = 'datepicker__day datepicker__day--weekend']")
        for day in weekends:
            if day.text == '31':
                due = day
                due.click()
                break

        self.teacher.find(By.XPATH, "//input[@id='external-url']").send_keys(
            "google.com")
        self.teacher.sleep(5)

        # Publish the assignment
        self.teacher.find(
            By.XPATH,
            "//button[@class='async-button -publish btn btn-primary']").click()
        self.teacher.sleep(60)
        self.student.login()