class LibraryTabHelpTest(AcceptanceTest): """ Test help links on the library tab present at dashboard. """ def setUp(self): super(LibraryTabHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() def test_library_tab_nav_help(self): """ Scenario: Help link in navigation bar is working on 'Home'(Courses tab) page. Given that I am on the 'Home'(Courses tab) page. And I want help about the process And I click the 'Help' in the navigation bar Then Help link should open. And help url should be correct """ self.assertTrue(self.dashboard_page.has_new_library_button) click_css(self.dashboard_page, '#course-index-tabs .libraries-tab', 0, False) expected_url = _get_expected_documentation_url('/getting_started/CA_get_started_Studio.html') # Assert that help link is correct. assert_nav_help_link( test=self, page=self.dashboard_page, href=expected_url )
def log_in_as_unique_user(self): """ Create a unique user and return the account's username and id. """ username = "******".format(uuid=self.unique_id[0:6]) auto_auth_page = AutoAuthPage(self.browser, username=username).visit() user_id = auto_auth_page.get_user_id() return username, user_id
def auth(self, enroll=True): """Authenticate, enrolling the user in the configured course if requested.""" CourseFixture(**self.course_info).install() course_id = self.course_id if enroll else None auth_page = AutoAuthPage(self.browser, course_id=course_id) auth_page.visit() self.username = auth_page.user_info['username']
def log_in(self, user, is_staff=False): """ Log in as the user that created the library. By default the user will not have staff access unless is_staff is passed as True. """ auth_page = AutoAuthPage( self.browser, staff=is_staff, username=user.get('username'), email=user.get('email'), password=user.get('password') ) auth_page.visit()
class NewLibraryHelpTest(AcceptanceTest): """ Test help links while creating a new library """ def setUp(self): super(NewLibraryHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() self.assertTrue(self.dashboard_page.has_new_library_button) self.dashboard_page.click_new_library() def test_library_create_nav_help(self): """ Scenario: Help link in navigation bar is working on 'Create a New Library' page in the dashboard. Given that I am on the 'Create a New Library' page in the dashboard. And I want help about the process And I click the 'Help' in the navigation bar Then Help link should open. And help url should be correct """ expected_url = _get_expected_documentation_url('/getting_started/CA_get_started_Studio.html') # Assert that help link is correct. assert_nav_help_link( test=self, page=self.dashboard_page, href=expected_url ) def test_library_create_side_bar_help(self): """ Scenario: Help link in sidebar links is working on 'Create a New Library' page in the dashboard. Given that I am on the 'Create a New Library' page in the dashboard. And I want help about the process And I click the 'Getting Started with Your Platform Studio' in the sidebar links Then Help link should open. And help url should be correct """ expected_url = _get_expected_documentation_url('/getting_started/CA_get_started_Studio.html') # Assert that help link is correct. assert_side_bar_help_link( test=self, page=self.dashboard_page, href=expected_url, help_text='Getting Started with Your Platform Studio', as_list_item=True )
def log_in_as_unique_user(self, email=None, full_name=None, password=None): """ Create a unique user and return the account's username and id. """ username = "******".format(uuid=self.unique_id[0:6]) auto_auth_page = AutoAuthPage( self.browser, username=username, email=email, full_name=full_name, password=password ).visit() user_id = auto_auth_page.get_user_id() return username, user_id
class NewCourseHelpTest(AcceptanceTest): """ Test help links while creating a new course. """ def setUp(self): super(NewCourseHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button() def test_course_create_nav_help(self): """ Scenario: Help link in navigation bar is working on 'Create a New Course' page in the dashboard. Given that I am on the 'Create a New Course' page in the dashboard. And I want help about the process And I click the 'Help' in the navigation bar Then Help link should open. And help url should be correct """ expected_url = _get_expected_documentation_url( '/getting_started/CA_get_started_Studio.html') # Assert that help link is correct. assert_nav_help_link(test=self, page=self.dashboard_page, href=expected_url) def test_course_create_side_bar_help(self): """ Scenario: Help link in sidebar links is working on 'Create a New Course' page in the dashboard. Given that I am on the 'Create a New Course' page in the dashboard. And I want help about the process And I click the 'Getting Started with Your Platform Studio' in the sidebar links Then Help link should open. And help url should be correct """ expected_url = _get_expected_documentation_url( '/getting_started/CA_get_started_Studio.html') # Assert that help link is correct. assert_side_bar_help_link( test=self, page=self.dashboard_page, href=expected_url, help_text=u'Getting Started with Your Platform 𝓢𝓽𝓾𝓭𝓲𝓸', as_list_item=True)
class CreateLibraryTest(AcceptanceTest): """ Test that we can create a new content library on the studio home page. """ def setUp(self): """ Load the helper for the home page (dashboard page) """ super(CreateLibraryTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) def test_create_library(self): """ From the home page: Click "New Library" Fill out the form Submit the form We should be redirected to the edit view for the library Return to the home page The newly created library should now appear in the list of libraries """ unique_suffix = uuid4().hex[:4] name = "New Library Name " + unique_suffix org = "TestOrgX" + unique_suffix number = "TESTLIB_" + unique_suffix self.auth_page.visit() self.dashboard_page.visit() self.assertFalse( self.dashboard_page.has_library(name=name, org=org, number=number)) self.assertTrue(self.dashboard_page.has_new_library_button()) self.dashboard_page.click_new_library() self.assertTrue(self.dashboard_page.is_new_library_form_visible()) self.dashboard_page.fill_new_library_form(name, org, number) self.assertTrue(self.dashboard_page.is_new_library_form_valid()) self.dashboard_page.submit_new_library_form() # The next page is the library edit view; make sure it loads: lib_page = LibraryEditPage(self.browser, LibraryLocator(org, number)) lib_page.wait_for_page() # Then go back to the home page and make sure the new library is listed there: self.dashboard_page.visit() self.assertTrue( self.dashboard_page.has_library(name=name, org=org, number=number))
def _auto_auth(self, username, email, staff): """ Logout and login with given credentials. """ self.logout_page.visit() AutoAuthPage(self.browser, username=username, email=email, course_id=self.course_id, staff=staff).visit()
def setUp(self): super(CertificateInvalidationTest, self).setUp() # set same course number as we have in fixture json self.course_info['number'] = "335535897951379478207964576572017930000" # we have created a user with this id in fixture, and created a generated certificate for it. self.student_id = "99" self.student_name = "testcert" self.student_email = "*****@*****.**" # Enroll above test user in the course AutoAuthPage( self.browser, username=self.student_name, email=self.student_email, course_id=self.course_id, ).visit() self.test_certificate_config = { 'id': 1, 'name': 'Certificate name', 'description': 'Certificate description', 'course_title': 'Course title override', 'signatories': [], 'version': 1, 'is_active': True } self.cert_fixture = CertificateConfigFixture(self.course_id, self.test_certificate_config) self.cert_fixture.install() self.user_name, self.user_id, __, __ = self.log_in_as_instructor() self.instructor_dashboard_page = self.visit_instructor_dashboard() self.certificates_section = self.instructor_dashboard_page.select_certificates() disable_animations(self.certificates_section)
def setUp(self): """ Initialization of pages and course fixture for video tests """ super(VideoBaseTest, self).setUp() self.longMessage = True self.video = VideoPage(self.browser) self.tab_nav = TabNavPage(self.browser) self.courseware_page = CoursewarePage(self.browser, self.course_id) self.course_info_page = CourseInfoPage(self.browser, self.course_id) self.auth_page = AutoAuthPage(self.browser, course_id=self.course_id) self.course_fixture = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) self.metadata = None self.assets = [] self.contents_of_verticals = None self.youtube_configuration = {} self.user_info = {} # reset youtube stub server self.addCleanup(YouTubeStubConfig.reset)
def log_in(self, user, is_staff=False): """ Log in as the user that created the course. The user will be given instructor access to the course and enrolled in it. By default the user will not have staff access unless is_staff is passed as True. Args: user(dict): dictionary containing user data: {'username': ..., 'email': ..., 'password': ...} is_staff(bool): register this user as staff """ self.auth_page = AutoAuthPage(self.browser, staff=is_staff, username=user.get('username'), email=user.get('email'), password=user.get('password')) self.auth_page.visit()
def setUp(self): """ Create a unique identifier for the course used in this test. """ # Ensure that the superclass sets up super(XBlockAcidBase, self).setUp() # Define a unique course identifier self.course_info = { 'org': 'test_org', 'number': 'course_' + self.unique_id[:5], 'run': 'test_' + self.unique_id, 'display_name': 'Test Course ' + self.unique_id } self.outline = CourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) self.course_id = '{org}.{number}.{run}'.format(**self.course_info) self.setup_fixtures() self.auth_page = AutoAuthPage( self.browser, staff=False, username=self.user.get('username'), email=self.user.get('email'), password=self.user.get('password') ) self.auth_page.visit()
def test_hinted_login(self): """ Test the login page when coming from course URL that specified which third party provider to use """ # Create a user account and link it to third party auth with the dummy provider: AutoAuthPage(self.browser, course_id=self.course_id).visit() self._link_dummy_account() try: LogoutPage(self.browser).visit() # When not logged in, try to load a course URL that includes the provider hint ?tpa_hint=... course_page = CoursewarePage(self.browser, self.course_id) self.browser.get(course_page.url + '?tpa_hint=oa2-dummy') # We should now be redirected to the login page self.login_page.wait_for_page() self.assertIn( "Would you like to sign in using your Dummy credentials?", self.login_page.hinted_login_prompt) # Baseline screen-shots are different for chrome and firefox. #self.assertScreenshot('#hinted-login-form', 'hinted-login-{}'.format(self.browser.name), .25) #The line above is commented out temporarily see SOL-1937 self.login_page.click_third_party_dummy_provider() # We should now be redirected to the course page course_page.wait_for_page() finally: self._unlink_dummy_account()
def setUp(self): """ Initialize the test. Create the necessary page objects, create course page and courses to find. """ super(RegisterCourseTests, self).setUp() # create test file in which index for this test will live with open(self.TEST_INDEX_FILENAME, "w+") as index_file: json.dump({}, index_file) self.addCleanup(remove_file, self.TEST_INDEX_FILENAME) self.course_discovery = CourseDiscoveryPage(self.browser) self.dashboard_page = DashboardPage(self.browser) self.course_about = CourseAboutPage(self.browser, self.course_id) # Create a course CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'], settings={ 'enrollment_start': datetime(1970, 1, 1).isoformat() }).install() # Create a user and log them in AutoAuthPage(self.browser).visit()
def setUp(self): """ Initialize pages and install a course fixture. """ super(TooltipTest, self).setUp() self.course_home_page = CourseHomePage(self.browser, self.course_id) self.tab_nav = TabNavPage(self.browser) course_fix = CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']) course_fix.add_children( XBlockFixtureDesc('static_tab', 'Test Static Tab'), XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc( 'sequential', 'Test Subsection').add_children( XBlockFixtureDesc( 'problem', 'Test Problem 1', data=load_data_str('multiple_choice.xml')), XBlockFixtureDesc( 'problem', 'Test Problem 2', data=load_data_str('formula_problem.xml')), XBlockFixtureDesc('html', 'Test HTML'), ))).install() self.courseware_page = CoursewarePage(self.browser, self.course_id) # Auto-auth register for the course AutoAuthPage(self.browser, course_id=self.course_id).visit()
def setUp(self): super(ProblemsTest, self).setUp() self.username = "******".format(uuid=self.unique_id[0:8]) self.email = "{username}@example.com".format(username=self.username) self.password = "******" self.xqueue_grade_response = None self.courseware_page = CoursewarePage(self.browser, self.course_id) # Install a course with a hierarchy and problems course_fixture = CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']) problem = self.get_problem() sequential = self.get_sequential() course_fixture.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( sequential.add_children(problem))).install() # Auto-auth register for the course. AutoAuthPage(self.browser, username=self.username, email=self.email, password=self.password, course_id=self.course_id, staff=True).visit()
def test_visible_to_staff(self): """ Scenario: All content is visible for a user marked is_staff (different from course staff) Given some of the course content has been marked 'visible_to_staff_only' And I am logged on with an account marked 'is_staff' Then I can see all course content """ AutoAuthPage(self.browser, username="******", email="*****@*****.**", course_id=self.course_id, staff=True).visit() self.course_home_page.visit() self.assertEqual(3, len(self.course_home_page.outline.sections['Test Section'])) self.course_home_page.outline.go_to_section("Test Section", "Subsection With Locked Unit") self.courseware_page.wait_for_page() self.assertEqual([u'Locked Unit', u'Unlocked Unit'], self.courseware_page.nav.sequence_items) self.course_home_page.visit() self.course_home_page.outline.go_to_section("Test Section", "Unlocked Subsection") self.courseware_page.wait_for_page() self.assertEqual([u'Test Unit'], self.courseware_page.nav.sequence_items) self.course_home_page.visit() self.course_home_page.outline.go_to_section("Test Section", "Locked Subsection") self.courseware_page.wait_for_page() self.assertEqual([u'Test Unit'], self.courseware_page.nav.sequence_items)
def setUp(self): """ Initialize pages and install a course fixture. """ super(CourseWikiA11yTest, self).setUp() # self.course_info['number'] must be shorter since we are accessing the wiki. See TNL-1751 self.course_info['number'] = self.unique_id[0:6] self.course_wiki_page = CourseWikiPage(self.browser, self.course_id) self.course_home_page = CourseHomePage(self.browser, self.course_id) self.course_wiki_edit_page = CourseWikiEditPage( self.browser, self.course_id, self.course_info) self.tab_nav = TabNavPage(self.browser) CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']).install() # Auto-auth register for the course AutoAuthPage(self.browser, course_id=self.course_id).visit() # Access course wiki page self.course_home_page.visit() self.tab_nav.go_to_tab('Wiki')
def test_immediate_verification_enrollment(self): # Create a user and log them in student_id = AutoAuthPage(self.browser).visit().get_user_id() enroll_user_track(self.browser, self.course_id, 'verified') # Proceed to verification self.payment_and_verification_flow.immediate_verification() # Take face photo and proceed to the ID photo step self.payment_and_verification_flow.webcam_capture() self.payment_and_verification_flow.next_verification_step( self.immediate_verification_page) # Take ID photo and proceed to the review photos step self.payment_and_verification_flow.webcam_capture() self.payment_and_verification_flow.next_verification_step( self.immediate_verification_page) # Submit photos and proceed to the enrollment confirmation step self.payment_and_verification_flow.next_verification_step( self.immediate_verification_page) # Navigate to the dashboard self.dashboard_page.visit() # Expect that we're enrolled as verified in the course enrollment_mode = self.dashboard_page.get_enrollment_mode( self.course_info["display_name"]) self.assertEqual(enrollment_mode, 'verified')
def _install_course_fixture(self): """ Prepare for tests by creating a course with a section, subsection, and unit. Performs the following: Create a course with a section, subsection, and unit Create a user and make that user a course author Log the user into studio """ if self.assets: self.course_fixture.add_asset(self.assets) # Create course with Video component self.course_fixture.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc( 'sequential', 'Test Subsection').add_children( XBlockFixtureDesc( 'vertical', 'Test Unit').add_children( XBlockFixtureDesc( 'video', 'Video', metadata=self.metadata))))).install() # Auto login and register the course AutoAuthPage( self.browser, staff=False, username=self.course_fixture.user.get('username'), email=self.course_fixture.user.get('email'), password=self.course_fixture.user.get('password')).visit()
def setUp(self): """ Initialize pages and install a course fixture. """ super(PDFTextBooksTabTest, self).setUp() self.course_home_page = CourseHomePage(self.browser, self.course_id) self.tab_nav = TabNavPage(self.browser) # Install a course with TextBooks course_fix = CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']) # Add PDF textbooks to course fixture. for i in range(1, 3): course_fix.add_textbook( "PDF Book {}".format(i), [{ "title": "Chapter Of Book {}".format(i), "url": "" }]) course_fix.install() # Auto-auth register for the course AutoAuthPage(self.browser, course_id=self.course_id).visit()
def _auto_auth(self, username, email, staff): """ Logout and login with given credentials. """ LogoutPage(self.browser).visit() AutoAuthPage(self.browser, username=username, email=email, staff=staff).visit()
def test_visible_to_student(self): """ Scenario: Content marked 'visible_to_staff_only' is not visible for students in the course Given some of the course content has been marked 'visible_to_staff_only' And I am logged on with an authorized student account Then I can only see content without 'visible_to_staff_only' set to True """ AutoAuthPage(self.browser, username="******", email="*****@*****.**", course_id=self.course_id, staff=False).visit() self.course_home_page.visit() self.assertEqual( 2, len(self.course_home_page.outline.sections['Test Section'])) self.course_home_page.outline.go_to_section( "Test Section", "Subsection With Locked Unit") self.courseware_page.wait_for_page() self.assertEqual([u'Unlocked Unit'], self.courseware_page.nav.sequence_items) self.course_home_page.visit() self.course_home_page.outline.go_to_section("Test Section", "Unlocked Subsection") self.courseware_page.wait_for_page() self.assertEqual([u'Test Unit'], self.courseware_page.nav.sequence_items)
def setUp(self): """ Initializes the components (page objects, courses, users) for this test suite """ # Some parameters are provided by the parent setUp() routine, such as the following: # self.course_id, self.course_info, self.unique_id super(BaseLmsDashboardTest, self).setUp() # Load page objects for use by the tests self.dashboard_page = DashboardPage(self.browser) # Configure some aspects of the test course and install the settings into the course self.course_fixture = CourseFixture( self.course_info["org"], self.course_info["number"], self.course_info["run"], self.course_info["display_name"], ) self.course_fixture.add_advanced_settings( {u"social_sharing_url": { u"value": "http://custom/course/url" }}) self.course_fixture.install() self.username = "******".format(uuid=self.unique_id[0:6]) self.email = "{user}@example.com".format(user=self.username) # Create the test user, register them for the course, and authenticate AutoAuthPage(self.browser, username=self.username, email=self.email, course_id=self.course_id).visit() # Navigate the authenticated, enrolled user to the dashboard page and get testing! self.dashboard_page.visit()
class CreateLibraryTest(AcceptanceTest): """ Test that we can create a new content library on the studio home page. """ def setUp(self): """ Load the helper for the home page (dashboard page) """ super(CreateLibraryTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) def test_create_library(self): """ From the home page: Click "New Library" Fill out the form Submit the form We should be redirected to the edit view for the library Return to the home page The newly created library should now appear in the list of libraries """ unique_suffix = uuid4().hex[:4] name = "New Library Name " + unique_suffix org = "TestOrgX" + unique_suffix number = "TESTLIB_" + unique_suffix self.auth_page.visit() self.dashboard_page.visit() self.assertFalse(self.dashboard_page.has_library(name=name, org=org, number=number)) self.assertTrue(self.dashboard_page.has_new_library_button()) self.dashboard_page.click_new_library() self.assertTrue(self.dashboard_page.is_new_library_form_visible()) self.dashboard_page.fill_new_library_form(name, org, number) self.assertTrue(self.dashboard_page.is_new_library_form_valid()) self.dashboard_page.submit_new_library_form() # The next page is the library edit view; make sure it loads: lib_page = LibraryEditPage(self.browser, LibraryLocator(org, number)) lib_page.wait_for_page() # Then go back to the home page and make sure the new library is listed there: self.dashboard_page.visit() self.assertTrue(self.dashboard_page.has_library(name=name, org=org, number=number))
class LoggedInPagesTest(AcceptanceTest): """ Verify the pages in Studio that you can get to when logged in and do not have a course yet. """ def setUp(self): super(LoggedInPagesTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.home_page = HomePage(self.browser) def test_logged_in_no_courses(self): """ Make sure that you can get to the dashboard and home pages without a course. """ self.auth_page.visit() self.dashboard_page.visit() self.home_page.visit()
def setUp(self): super(LibraryUsersPageTest, self).setUp() # Create a second user for use in these tests: AutoAuthPage(self.browser, username="******", email="*****@*****.**", no_login=True).visit() self.page = LibraryUsersPage(self.browser, self.library_key) self.page.visit()
def login_and_verify_visible_problems(username, email, expected_problems, track=None): AutoAuthPage( self.browser, username=username, email=email, course_id=self.course_id ).visit() if track is not None: enroll_user_track(self.browser, self.course_id, track) courseware_page.visit() verify_expected_problem_visibility(self, courseware_page, expected_problems)
def _update_user(self, user_info): """ Update user with provided `user_info` Arguments: `user_info`: dictionary containing values of attributes to be updated """ AutoAuthPage(self.browser, no_login=True, **user_info).visit()
def setUp(self): super(NewLibraryHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() self.assertTrue(self.dashboard_page.has_new_library_button) self.dashboard_page.click_new_library()
def setUp(self): super(NewCourseHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit() self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button()
def setUp(self): """ Load the helper for the home page (dashboard page) """ super(CreateLibraryTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser)
def test_badge_share_modal(self): username = '******' AutoAuthPage(self.browser, username=username).visit() profile_page = self.visit_profile_page(username) profile_page.display_accomplishments() badge = profile_page.badges[0] badge.display_modal() badge.close_modal()
def _create_user(self): """ Create a unique user """ auto_auth = AutoAuthPage(self.browser).visit() user_info = auto_auth.user_info LogoutPage(self.browser).visit() return user_info
def setUp(self): """Create a course that isn't live yet and enroll for it.""" super(NotLiveRedirectTest, self).setUp() CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'], start_date=datetime(year=2099, month=1, day=1) ).install() AutoAuthPage(self.browser, course_id=self.course_id).visit()
def log_in_as_unique_user(self): """ Log in as a valid lms user. """ AutoAuthPage(self.browser, username="******", email="*****@*****.**", password="******", course_id=self.course_id).visit()
def log_in_as_instructor(self, global_staff=True, course_access_roles=None): """ Login with an instructor account. Args: course_access_roles (str[]): List of course access roles that should be assigned to the user. Returns username (str) user_id (int) """ course_access_roles = course_access_roles or [] auto_auth_page = AutoAuthPage( self.browser, course_id=self.course_id, staff=global_staff, course_access_roles=course_access_roles ) auto_auth_page.visit() user_info = auto_auth_page.user_info return user_info['username'], user_info['user_id'], user_info['email'], user_info['password']
def auto_auth(self, username, email): """ Logout and login with given credentials. """ AutoAuthPage(self.browser, username=username, email=email, course_id=self.course_id, staff=True).visit()
def auto_auth(browser, username, email, staff, course_id): """ Logout and login with given credentials. """ AutoAuthPage(browser, username=username, email=email, course_id=course_id, staff=staff).visit()
def test_redirect_banner(self): """ Navigate to the course info page, then check that we're on the dashboard page with the appropriate message. """ AutoAuthPage(self.browser).visit() url = BASE_URL + "/course_modes/choose/" + self.course_id self.browser.get(url) self._assert_dashboard_message()
def setUp(self): """ Load the helper for the home page (dashboard page) """ super(CreateCourseTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.course_name = "New Course Name" self.course_org = "orgX" self.course_number = str(uuid.uuid4().get_hex().upper()[0:6]) self.course_run = "2015_T2"
def log_in(self, user, is_staff=False): """ Log in as the user that created the course. The user will be given instructor access to the course and enrolled in it. By default the user will not have staff access unless is_staff is passed as True. Args: user(dict): dictionary containing user data: {'username': ..., 'email': ..., 'password': ...} is_staff(bool): register this user as staff """ self.auth_page = AutoAuthPage( self.browser, staff=is_staff, username=user.get('username'), email=user.get('email'), password=user.get('password') ) self.auth_page.visit()
class CreateCourseTest(AcceptanceTest): """ Test that we can create a new course the studio home page. """ def setUp(self): """ Load the helper for the home page (dashboard page) """ super(CreateCourseTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.course_name = "New Course Name" self.course_org = "orgX" self.course_number = str(uuid.uuid4().get_hex().upper()[0:6]) self.course_run = "2015_T2" def test_create_course_with_non_existing_org(self): """ Scenario: Ensure that the course creation with non existing org display proper error message. Given I have filled course creation form with a non existing and all required fields When I click 'Create' button Form validation should pass Then I see the error message explaining reason for failure to create course """ self.auth_page.visit() self.dashboard_page.visit() self.assertFalse(self.dashboard_page.has_course( org='testOrg', number=self.course_number, run=self.course_run )) self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button() self.assertTrue(self.dashboard_page.is_new_course_form_visible()) self.dashboard_page.fill_new_course_form( self.course_name, 'testOrg', self.course_number, self.course_run ) self.assertTrue(self.dashboard_page.is_new_course_form_valid()) self.dashboard_page.submit_new_course_form() self.assertTrue(self.dashboard_page.error_notification.present) self.assertIn( u'Organization you selected does not exist in the system', self.dashboard_page.error_notification_message ) def test_create_course_with_existing_org(self): """ Scenario: Ensure that the course creation with an existing org should be successful. Given I have filled course creation form with an existing org and all required fields When I click 'Create' button Form validation should pass Then I see the course listing page with newly created course """ self.auth_page.visit() self.dashboard_page.visit() self.assertFalse(self.dashboard_page.has_course( org=self.course_org, number=self.course_number, run=self.course_run )) self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button() self.assertTrue(self.dashboard_page.is_new_course_form_visible()) self.dashboard_page.fill_new_course_form( self.course_name, self.course_org, self.course_number, self.course_run ) self.assertTrue(self.dashboard_page.is_new_course_form_valid()) self.dashboard_page.submit_new_course_form() # Successful creation of course takes user to course outline page course_outline_page = CourseOutlinePage( self.browser, self.course_org, self.course_number, self.course_run ) course_outline_page.visit() course_outline_page.wait_for_page() # Go back to dashboard and verify newly created course exists there self.dashboard_page.visit() self.assertTrue(self.dashboard_page.has_course( org=self.course_org, number=self.course_number, run=self.course_run )) # Click on the course listing and verify that the Studio course outline page opens. self.dashboard_page.click_course_run(self.course_run) course_outline_page.wait_for_page() def test_create_course_with_existing_org_via_autocomplete(self): """ Scenario: Ensure that the course creation with an existing org should be successful. Given I have filled course creation form with an existing org and all required fields And I selected `Course Organization` input via autocomplete When I click 'Create' button Form validation should pass Then I see the course listing page with newly created course """ self.auth_page.visit() self.dashboard_page.visit() new_org = 'orgX2' self.assertFalse(self.dashboard_page.has_course( org=new_org, number=self.course_number, run=self.course_run )) self.assertTrue(self.dashboard_page.new_course_button.present) self.dashboard_page.click_new_course_button() self.assertTrue(self.dashboard_page.is_new_course_form_visible()) self.dashboard_page.fill_new_course_form( self.course_name, '', self.course_number, self.course_run ) self.dashboard_page.course_org_field.fill('org') self.dashboard_page.select_item_in_autocomplete_widget(new_org) self.assertTrue(self.dashboard_page.is_new_course_form_valid()) self.dashboard_page.submit_new_course_form() # Successful creation of course takes user to course outline page course_outline_page = CourseOutlinePage( self.browser, new_org, self.course_number, self.course_run ) course_outline_page.visit() course_outline_page.wait_for_page() # Go back to dashboard and verify newly created course exists there self.dashboard_page.visit() self.assertTrue(self.dashboard_page.has_course( org=new_org, number=self.course_number, run=self.course_run ))
class VideoBaseTest(UniqueCourseTest): """ Base class for tests of the Video Player Sets up the course and provides helper functions for the Video tests. """ def setUp(self): """ Initialization of pages and course fixture for video tests """ super(VideoBaseTest, self).setUp() self.longMessage = True self.video = VideoPage(self.browser) self.tab_nav = TabNavPage(self.browser) self.courseware_page = CoursewarePage(self.browser, self.course_id) self.course_info_page = CourseInfoPage(self.browser, self.course_id) self.auth_page = AutoAuthPage(self.browser, course_id=self.course_id) self.course_fixture = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) self.metadata = None self.assets = [] self.contents_of_verticals = None self.youtube_configuration = {} self.user_info = {} # reset youtube stub server self.addCleanup(YouTubeStubConfig.reset) def navigate_to_video(self): """ Prepare the course and get to the video and render it """ self._install_course_fixture() self._navigate_to_courseware_video_and_render() def navigate_to_video_no_render(self): """ Prepare the course and get to the video unit however do not wait for it to render, because the has been an error. """ self._install_course_fixture() self._navigate_to_courseware_video_no_render() def _install_course_fixture(self): """ Install the course fixture that has been defined """ if self.assets: self.course_fixture.add_asset(self.assets) chapter_sequential = XBlockFixtureDesc('sequential', 'Test Section') chapter_sequential.add_children(*self._add_course_verticals()) chapter = XBlockFixtureDesc('chapter', 'Test Chapter').add_children(chapter_sequential) self.course_fixture.add_children(chapter) self.course_fixture.install() if len(self.youtube_configuration) > 0: YouTubeStubConfig.configure(self.youtube_configuration) def _add_course_verticals(self): """ Create XBlockFixtureDesc verticals :return: a list of XBlockFixtureDesc """ xblock_verticals = [] _contents_of_verticals = self.contents_of_verticals # Video tests require at least one vertical with a single video. if not _contents_of_verticals: _contents_of_verticals = [[{'display_name': 'Video', 'metadata': self.metadata}]] for vertical_index, vertical in enumerate(_contents_of_verticals): xblock_verticals.append(self._create_single_vertical(vertical, vertical_index)) return xblock_verticals def _create_single_vertical(self, vertical_contents, vertical_index): """ Create a single course vertical of type XBlockFixtureDesc with category `vertical`. A single course vertical can contain single or multiple video modules. :param vertical_contents: a list of items for the vertical to contain :param vertical_index: index for the vertical display name :return: XBlockFixtureDesc """ xblock_course_vertical = XBlockFixtureDesc('vertical', u'Test Vertical-{0}'.format(vertical_index)) for video in vertical_contents: xblock_course_vertical.add_children( XBlockFixtureDesc('video', video['display_name'], metadata=video.get('metadata'))) return xblock_course_vertical def _navigate_to_courseware_video(self): """ Register for the course and navigate to the video unit """ self.auth_page.visit() self.user_info = self.auth_page.user_info self.courseware_page.visit() def _navigate_to_courseware_video_and_render(self): """ Wait for the video player to render """ self._navigate_to_courseware_video() self.video.wait_for_video_player_render() def _navigate_to_courseware_video_no_render(self): """ Wait for the video Xmodule but not for rendering """ self._navigate_to_courseware_video() self.video.wait_for_video_class() def metadata_for_mode(self, player_mode, additional_data=None): """ Create a dictionary for video player configuration according to `player_mode` :param player_mode (str): Video player mode :param additional_data (dict): Optional additional metadata. :return: dict """ metadata = {} youtube_ids = { 'youtube_id_1_0': '', 'youtube_id_0_75': '', 'youtube_id_1_25': '', 'youtube_id_1_5': '', } if player_mode == 'html5': metadata.update(youtube_ids) metadata.update({ 'html5_sources': HTML5_SOURCES }) if player_mode == 'youtube_html5': metadata.update({ 'html5_sources': HTML5_SOURCES, }) if player_mode == 'youtube_html5_unsupported_video': metadata.update({ 'html5_sources': HTML5_SOURCES_INCORRECT }) if player_mode == 'html5_unsupported_video': metadata.update(youtube_ids) metadata.update({ 'html5_sources': HTML5_SOURCES_INCORRECT }) if player_mode == 'hls': metadata.update(youtube_ids) metadata.update({ 'html5_sources': HLS_SOURCES, }) if player_mode == 'html5_and_hls': metadata.update(youtube_ids) metadata.update({ 'html5_sources': HTML5_SOURCES + HLS_SOURCES, }) if additional_data: metadata.update(additional_data) return metadata def go_to_sequential_position(self, position): """ Navigate to sequential specified by `video_display_name` """ self.courseware_page.go_to_sequential_position(position) self.video.wait_for_video_player_render()
class XBlockAcidBase(AcceptanceTest): """ Base class for tests that verify that XBlock integration is working correctly """ __test__ = False def setUp(self): """ Create a unique identifier for the course used in this test. """ # Ensure that the superclass sets up super(XBlockAcidBase, self).setUp() # Define a unique course identifier self.course_info = { 'org': 'test_org', 'number': 'course_' + self.unique_id[:5], 'run': 'test_' + self.unique_id, 'display_name': 'Test Course ' + self.unique_id } self.outline = CourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) self.course_id = '{org}.{number}.{run}'.format(**self.course_info) self.setup_fixtures() self.auth_page = AutoAuthPage( self.browser, staff=False, username=self.user.get('username'), email=self.user.get('email'), password=self.user.get('password') ) self.auth_page.visit() def validate_acid_block_preview(self, acid_block): """ Validate the Acid Block's preview """ self.assertTrue(acid_block.init_fn_passed) self.assertTrue(acid_block.resource_url_passed) self.assertTrue(acid_block.scope_passed('user_state')) self.assertTrue(acid_block.scope_passed('user_state_summary')) self.assertTrue(acid_block.scope_passed('preferences')) self.assertTrue(acid_block.scope_passed('user_info')) def test_acid_block_preview(self): """ Verify that all expected acid block tests pass in studio preview """ self.outline.visit() subsection = self.outline.section('Test Section').subsection('Test Subsection') unit = subsection.expand_subsection().unit('Test Unit').go_to() acid_block = AcidView(self.browser, unit.xblocks[0].preview_selector) self.validate_acid_block_preview(acid_block) def test_acid_block_editor(self): """ Verify that all expected acid block tests pass in studio editor """ self.outline.visit() subsection = self.outline.section('Test Section').subsection('Test Subsection') unit = subsection.expand_subsection().unit('Test Unit').go_to() acid_block = AcidView(self.browser, unit.xblocks[0].edit().editor_selector) self.assertTrue(acid_block.init_fn_passed) self.assertTrue(acid_block.resource_url_passed)
def setUp(self): super(LibraryTabHelpTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.auth_page.visit() self.dashboard_page.visit()
def setUp(self): super(LoggedInPagesTest, self).setUp() self.auth_page = AutoAuthPage(self.browser, staff=True) self.dashboard_page = DashboardPage(self.browser) self.home_page = HomePage(self.browser)
class StudioCourseTest(UniqueCourseTest): """ Base class for all Studio course tests. """ def setUp(self, is_staff=False, test_xss=True): # pylint: disable=arguments-differ """ Install a course with no content using a fixture. """ super(StudioCourseTest, self).setUp() self.test_xss = test_xss self.install_course_fixture(is_staff) def install_course_fixture(self, is_staff=False): """ Install a course fixture """ self.course_fixture = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'], ) if self.test_xss: xss_injected_unique_id = XSS_INJECTION + self.unique_id test_improper_escaping = {u"value": xss_injected_unique_id} self.course_fixture.add_advanced_settings({ "advertised_start": test_improper_escaping, "info_sidebar_name": test_improper_escaping, "cert_name_short": test_improper_escaping, "cert_name_long": test_improper_escaping, "display_organization": test_improper_escaping, "display_coursenumber": test_improper_escaping, }) self.course_info['display_organization'] = xss_injected_unique_id self.course_info['display_coursenumber'] = xss_injected_unique_id self.populate_course_fixture(self.course_fixture) self.course_fixture.install() self.user = self.course_fixture.user self.log_in(self.user, is_staff) def populate_course_fixture(self, course_fixture): """ Populate the children of the test course fixture. """ pass def log_in(self, user, is_staff=False): """ Log in as the user that created the course. The user will be given instructor access to the course and enrolled in it. By default the user will not have staff access unless is_staff is passed as True. Args: user(dict): dictionary containing user data: {'username': ..., 'email': ..., 'password': ...} is_staff(bool): register this user as staff """ self.auth_page = AutoAuthPage( self.browser, staff=is_staff, username=user.get('username'), email=user.get('email'), password=user.get('password') ) self.auth_page.visit()