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 setUp(self): """Create a course that is closed for enrollment, and sign in as a user.""" super(EnrollmentClosedRedirectTest, self).setUp() course = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) now = datetime.now(pytz.UTC) course.add_course_details({ 'enrollment_start': (now - timedelta(days=30)).isoformat(), 'enrollment_end': (now - timedelta(days=1)).isoformat() }) course.install() # Add an honor mode to the course ModeCreationPage(self.browser, self.course_id).visit() # Add a verified mode to the course ModeCreationPage( self.browser, self.course_id, mode_slug=u'verified', mode_display_name=u'Verified Certificate', min_price=10, suggested_prices='10,20' ).visit()
def setUp(self): """ Create search page and course content to search """ # 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) super(CoursewareSearchTest, self).setUp() self.courseware_search_page = CoursewareSearchPage(self.browser, self.course_id) self.course_outline = CourseOutlinePage( self.browser, self.course_info["org"], self.course_info["number"], self.course_info["run"] ) 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("chapter", "Section 1").add_children(XBlockFixtureDesc("sequential", "Subsection 1")) ).add_children( XBlockFixtureDesc("chapter", "Section 2").add_children(XBlockFixtureDesc("sequential", "Subsection 2")) ).install()
class StaffViewTest(UniqueCourseTest): """ Tests that verify the staff view. """ USERNAME = "******" EMAIL = "*****@*****.**" def setUp(self): super(StaffViewTest, self).setUp() self.courseware_page = CoursewarePage(self.browser, self.course_id) # Install a course with sections/problems, tabs, updates, and handouts self.course_fixture = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) self.populate_course_fixture(self.course_fixture) # pylint: disable=no-member self.course_fixture.install() # Auto-auth register for the course. # Do this as global staff so that you will see the Staff View AutoAuthPage(self.browser, username=self.USERNAME, email=self.EMAIL, course_id=self.course_id, staff=True).visit() def _goto_staff_page(self): """ Open staff page with assertion """ self.courseware_page.visit() staff_page = StaffPage(self.browser, self.course_id) self.assertEqual(staff_page.staff_view_mode, 'Staff') return staff_page
def setUp(self): super(ProblemStateOnNavigationTest, self).setUp() self.courseware_page = CoursewarePage(self.browser, self.course_id) # Install a course with section, tabs and multiple choice problems. 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('chapter', 'Test Section 1').add_children( XBlockFixtureDesc('sequential', 'Test Subsection 1,1').add_children( self.create_multiple_choice_problem(self.problem1_name), self.create_multiple_choice_problem(self.problem2_name), ), ), ).install() # Auto-auth register for the course. AutoAuthPage( self.browser, username=self.USERNAME, email=self.EMAIL, course_id=self.course_id, staff=False ).visit() self.courseware_page.visit() self.problem_page = ProblemPage(self.browser)
def setUp(self): """ Create search page and course content to search """ # 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) super(CoursewareSearchTest, self).setUp() self.courseware_search_page = CoursewareSearchPage(self.browser, self.course_id) self.studio_course_outline = StudioCourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) 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('chapter', 'Section 1').add_children( XBlockFixtureDesc('sequential', 'Subsection 1') ) ).add_children( XBlockFixtureDesc('chapter', 'Section 2').add_children( XBlockFixtureDesc('sequential', 'Subsection 2') ) ).install()
def setUp(self): super(GatingTest, self).setUp() self.logout_page = LogoutPage(self.browser) self.course_home_page = CourseHomePage(self.browser, self.course_id) self.courseware_page = CoursewarePage(self.browser, self.course_id) self.studio_course_outline = StudioCourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) xml = dedent(""" <problem> <p>What is height of eiffel tower without the antenna?.</p> <multiplechoiceresponse> <choicegroup label="What is height of eiffel tower without the antenna?" type="MultipleChoice"> <choice correct="false">324 meters<choicehint>Antenna is 24 meters high</choicehint></choice> <choice correct="true">300 meters</choice> <choice correct="false">224 meters</choice> <choice correct="false">400 meters</choice> </choicegroup> </multiplechoiceresponse> </problem> """) self.problem1 = XBlockFixtureDesc('problem', 'HEIGHT OF EIFFEL TOWER', data=xml) # Install a course with sections/problems course_fixture = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) course_fixture.add_advanced_settings({ "enable_subsection_gating": {"value": "true"}, 'enable_proctored_exams': {"value": "true"} }) course_fixture.add_children( XBlockFixtureDesc('chapter', 'Test Section 1').add_children( XBlockFixtureDesc('sequential', 'Test Subsection 1').add_children( self.problem1 ), XBlockFixtureDesc('sequential', 'Test Subsection 2').add_children( XBlockFixtureDesc('problem', 'Test Problem 2') ), XBlockFixtureDesc('sequential', 'Test Subsection 3').add_children( XBlockFixtureDesc('problem', 'Test Problem 3') ), ) ).install()
class CreateCCXCoachTest(EventsTestMixin, UniqueCourseTest): """ Test ccx end to end process. """ USERNAME = "******" EMAIL = "*****@*****.**" shard = 7 def setUp(self): super(CreateCCXCoachTest, self).setUp() self.course_info.update({"settings": {"enable_ccx": "true"}}) self.course_fixture = CourseFixture(**self.course_info) self.course_fixture.add_advanced_settings({ "enable_ccx": {"value": "true"} }) self.course_fixture.install() self.auto_auth(self.USERNAME, self.EMAIL) self.coach_dashboard_page = self.visit_coach_dashboard() 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 visit_coach_dashboard(self): """ Visits the instructor dashboard. """ coach_dashboard_page = CoachDashboardPage(self.browser, self.course_id) coach_dashboard_page.visit() return coach_dashboard_page def test_create_ccx(self): """ Assert that ccx created. """ ccx_name = "Test ccx" self.coach_dashboard_page.fill_ccx_name_text_box(ccx_name) self.coach_dashboard_page.wait_for_page() # Assert that new ccx is created and we are on ccx dashboard/enrollment tab. self.assertTrue(self.coach_dashboard_page.is_browser_on_enrollment_page()) # Assert that the user cannot click in the "View Unit in Studio" button, # which means the user cannot edit the ccx course in studio self.assertFalse(self.coach_dashboard_page.is_button_view_unit_in_studio_visible())
def setUp(self): super(CoursewareMultipleVerticalsTest, self).setUp() self.courseware_page = CoursewarePage(self.browser, self.course_id) self.course_outline = CourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) # Install a course with sections/problems, tabs, updates, and handouts course_fix = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) course_fix.add_children( XBlockFixtureDesc('chapter', 'Test Section 1').add_children( XBlockFixtureDesc('sequential', 'Test Subsection 1,1').add_children( XBlockFixtureDesc('problem', 'Test Problem 1', data='<problem>problem 1 dummy body</problem>'), XBlockFixtureDesc('html', 'html 1', data="<html>html 1 dummy body</html>"), XBlockFixtureDesc('problem', 'Test Problem 2', data="<problem>problem 2 dummy body</problem>"), XBlockFixtureDesc('html', 'html 2', data="<html>html 2 dummy body</html>"), ), XBlockFixtureDesc('sequential', 'Test Subsection 1,2').add_children( XBlockFixtureDesc('problem', 'Test Problem 3', data='<problem>problem 3 dummy body</problem>'), ), XBlockFixtureDesc( 'sequential', 'Test HIDDEN Subsection', metadata={'visible_to_staff_only': True} ).add_children( XBlockFixtureDesc('problem', 'Test HIDDEN Problem', data='<problem>hidden problem</problem>'), ), ), XBlockFixtureDesc('chapter', 'Test Section 2').add_children( XBlockFixtureDesc('sequential', 'Test Subsection 2,1').add_children( XBlockFixtureDesc('problem', 'Test Problem 4', data='<problem>problem 4 dummy body</problem>'), ), ), XBlockFixtureDesc('chapter', 'Test HIDDEN Section', metadata={'visible_to_staff_only': True}).add_children( XBlockFixtureDesc('sequential', 'Test HIDDEN Subsection'), ), ).install() # Auto-auth register for the course. AutoAuthPage(self.browser, username=self.USERNAME, email=self.EMAIL, course_id=self.course_id, staff=False).visit() self.courseware_page.visit() self.course_nav = CourseNavPage(self.browser)
def setUp(self): """ Initialize pages and install a course fixture. """ super(ProblemExecutionTest, self).setUp() self.course_home_page = CourseHomePage(self.browser, self.course_id) self.tab_nav = TabNavPage(self.browser) # Install a course with sections and problems. course_fix = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) course_fix.add_asset(['python_lib.zip']) course_fix.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc('sequential', 'Test Subsection').add_children( XBlockFixtureDesc('problem', 'Python Problem', data=dedent( """\ <problem> <script type="loncapa/python"> from number_helpers import seventeen, fortytwo oneseven = seventeen() def check_function(expect, ans): if int(ans) == fortytwo(-22): return True else: return False </script> <p>What is the sum of $oneseven and 3?</p> <customresponse expect="20" cfn="check_function"> <textline/> </customresponse> </problem> """ )) ) ) ).install() # Auto-auth register for the course AutoAuthPage(self.browser, course_id=self.course_id).visit()
def setUp(self): super(CoursewareTest, self).setUp() self.courseware_page = CoursewarePage(self.browser, self.course_id) self.course_nav = CourseNavPage(self.browser) self.course_outline = CourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) # Install a course with sections/problems, tabs, updates, and handouts self.course_fix = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) self.course_fix.add_children( XBlockFixtureDesc('chapter', 'Test Section 1').add_children( XBlockFixtureDesc('sequential', 'Test Subsection 1').add_children( XBlockFixtureDesc('problem', 'Test Problem 1') ) ), XBlockFixtureDesc('chapter', 'Test Section 2').add_children( XBlockFixtureDesc('sequential', 'Test Subsection 2').add_children( XBlockFixtureDesc('problem', 'Test Problem 2') ) ) ).install() # Auto-auth register for the course. self._auto_auth(self.USERNAME, self.EMAIL, False)
def setUp(self): # pylint: disable=arguments-differ super(SignUpAndSignInTest, self).setUp() self.sign_up_page = SignupPage(self.browser) self.login_page = LoginPage(self.browser) self.course_outline_page = CourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) self.course_outline_sign_in_redirect_page = CourseOutlineSignInRedirectPage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) self.course_fixture = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'], ) self.user = None
def setUp(self): super(CertificateWebViewTest, self).setUp() # set same course number as we have in fixture json self.course_info["number"] = "335535897951379478207964576572017930000" test_certificate_config = { "id": 1, "name": "Certificate name", "description": "Certificate description", "course_title": "Course title override", "signatories": [], "version": 1, "is_active": True, } course_settings = {"certificates": test_certificate_config} self.course_fixture = CourseFixture( self.course_info["org"], self.course_info["number"], self.course_info["run"], self.course_info["display_name"], settings=course_settings, ) self.course_fixture.add_advanced_settings({"cert_html_view_enabled": {"value": "true"}}) self.course_fixture.install() self.user_id = "99" # we have created a user with this id in fixture self.cert_fixture = CertificateConfigFixture(self.course_id, test_certificate_config) # Load certificate web view page for use by the tests self.certificate_page = CertificatePage(self.browser, self.user_id, self.course_id)
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 setUp(self): super(CertificateWebViewTest, self).setUp() # set same course number as we have in fixture json self.course_info['number'] = "335535897951379478207964576572017930000" test_certificate_config = { 'id': 1, 'name': 'Certificate name', 'description': 'Certificate description', 'course_title': 'Course title override', 'signatories': [], 'version': 1, 'is_active': True, } course_settings = {'certificates': test_certificate_config} self.course_fixture = CourseFixture( self.course_info["org"], self.course_info["number"], self.course_info["run"], self.course_info["display_name"], settings=course_settings ) self.course_fixture.add_advanced_settings({ "cert_html_view_enabled": {"value": "true"}, "certificates_display_behavior": {"value": "early_with_info"}, }) self.course_fixture.install() self.user_id = "99" # we have created a user with this id in fixture self.cert_fixture = CertificateConfigFixture(self.course_id, test_certificate_config) # Load certificate web view page for use by the tests self.certificate_page = CertificatePage(self.browser, self.user_id, self.course_id)
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 setUp(self): """ Initialization of pages and course fixture for tests """ super(CMSVideoBaseTest, self).setUp() self.video = VideoComponentPage(self.browser) # This will be initialized later self.unit_page = None self.outline = CourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) self.course_fixture = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) self.assets = [] self.metadata = None self.addCleanup(YouTubeStubConfig.reset)
def setUp(self): super(ProctoredExamTest, self).setUp() self.courseware_page = CoursewarePage(self.browser, self.course_id) self.course_outline = CourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) # Install a course with sections/problems, tabs, updates, and handouts course_fix = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) course_fix.add_advanced_settings({ "enable_proctored_exams": {"value": "true"} }) course_fix.add_children( XBlockFixtureDesc('chapter', 'Test Section 1').add_children( XBlockFixtureDesc('sequential', 'Test Subsection 1').add_children( XBlockFixtureDesc('problem', 'Test Problem 1') ) ) ).install() self.track_selection_page = TrackSelectionPage(self.browser, self.course_id) self.payment_and_verification_flow = PaymentAndVerificationFlow(self.browser, self.course_id) self.immediate_verification_page = PaymentAndVerificationFlow( self.browser, self.course_id, entry_point='verify-now' ) self.upgrade_page = PaymentAndVerificationFlow(self.browser, self.course_id, entry_point='upgrade') self.fake_payment_page = FakePaymentPage(self.browser, self.course_id) self.dashboard_page = DashboardPage(self.browser) self.problem_page = ProblemPage(self.browser) # Add a verified mode to the course ModeCreationPage( self.browser, self.course_id, mode_slug=u'verified', mode_display_name=u'Verified Certificate', min_price=10, suggested_prices='10,20' ).visit() # Auto-auth register for the course. self._auto_auth(self.USERNAME, self.EMAIL, False)
def setup_fixtures(self): 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('chapter', 'Test Section').add_children( XBlockFixtureDesc('sequential', 'Test Subsection').add_children( XBlockFixtureDesc('vertical', 'Test Unit').add_children( XBlockFixtureDesc('acid', 'Acid Block') ) ) ) ).install()
class BaseDiscussionTestCase(UniqueCourseTest): def setUp(self): super(BaseDiscussionTestCase, self).setUp() self.discussion_id = "test_discussion_{}".format(uuid4().hex) self.course_fixture = CourseFixture(**self.course_info) self.course_fixture.add_advanced_settings( {'discussion_topics': {'value': {'Test Discussion Topic': {'id': self.discussion_id}}}} ) self.course_fixture.install() def create_single_thread_page(self, thread_id): """ Sets up a `DiscussionTabSingleThreadPage` for a given `thread_id`. """ return DiscussionTabSingleThreadPage(self.browser, self.course_id, self.discussion_id, thread_id)
def setUp(self): super(CertificateProgressPageTest, self).setUp() # set same course number as we have in fixture json self.course_info['number'] = "3355358979513794782079645765720179311111" test_certificate_config = { 'id': 1, 'name': 'Certificate name', 'description': 'Certificate description', 'course_title': 'Course title override', 'signatories': [], 'version': 1, 'is_active': True } course_settings = {'certificates': test_certificate_config} self.course_fixture = CourseFixture( self.course_info["org"], self.course_info["number"], self.course_info["run"], self.course_info["display_name"], settings=course_settings ) self.course_fixture.add_advanced_settings({ "cert_html_view_enabled": {"value": "true"}, "certificates_show_before_end": {"value": "true"} }) self.course_fixture.add_update( CourseUpdateDesc(date='January 29, 2014', content='Test course update1') ) self.course_fixture.add_children( XBlockFixtureDesc('static_tab', 'Test Static Tab'), XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc('sequential', 'Test Subsection', grader_type='Final Exam').add_children( XBlockFixtureDesc('problem', 'Test Problem 1', data=load_data_str('multiple_choice.xml')), XBlockFixtureDesc('html', 'Test HTML'), ) ), XBlockFixtureDesc('chapter', 'Test Section 2').add_children( XBlockFixtureDesc('sequential', 'Test Subsection 2', grader_type='Midterm Exam').add_children( XBlockFixtureDesc('problem', 'Test Problem 2', data=load_data_str('formula_problem.xml')), ) ) ) self.course_fixture.install() self.user_id = "99" # we have created a user with this id in fixture self.cert_fixture = CertificateConfigFixture(self.course_id, test_certificate_config) self.course_info_page = CourseInfoPage(self.browser, self.course_id) self.progress_page = ProgressPage(self.browser, self.course_id) self.courseware_page = CoursewarePage(self.browser, self.course_id) self.course_home_page = CourseHomePage(self.browser, self.course_id) self.tab_nav = TabNavPage(self.browser)
def setUp(self): super(BaseDiscussionTestCase, self).setUp() self.discussion_id = "test_discussion_{}".format(uuid4().hex) self.course_fixture = CourseFixture(**self.course_info) self.course_fixture.add_advanced_settings( {'discussion_topics': {'value': {'Test Discussion Topic': {'id': self.discussion_id}}}} ) self.course_fixture.install()
def setup_fixtures(self): 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("chapter", "Test Section").add_children( XBlockFixtureDesc("sequential", "Test Subsection").add_children( XBlockFixtureDesc("vertical", "Test Unit").add_children(XBlockFixtureDesc("acid", "Acid Block")) ) ) ).install() self.user = course_fix.user
def setUp(self): super(AnnotatableProblemTest, self).setUp() self.courseware_page = CoursewarePage(self.browser, self.course_id) # Install a course with two annotations and two annotations problems. course_fix = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) self.annotation_count = 2 course_fix.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc('sequential', 'Test Subsection').add_children( XBlockFixtureDesc('vertical', 'Test Annotation Vertical').add_children( XBlockFixtureDesc('annotatable', 'Test Annotation Module', data=self.DATA_TEMPLATE.format("\n".join( self.ANNOTATION_TEMPLATE.format(i) for i in xrange(self.annotation_count) ))), XBlockFixtureDesc('problem', 'Test Annotation Problem 0', data=self.PROBLEM_TEMPLATE.format(number=0, options="\n".join( self.OPTION_TEMPLATE.format( number=k, correctness=_correctness(k, 0)) for k in xrange(self.annotation_count) ))), XBlockFixtureDesc('problem', 'Test Annotation Problem 1', data=self.PROBLEM_TEMPLATE.format(number=1, options="\n".join( self.OPTION_TEMPLATE.format( number=k, correctness=_correctness(k, 1)) for k in xrange(self.annotation_count) ))) ) ) ) ).install() # Auto-auth register for the course. AutoAuthPage(self.browser, username=self.USERNAME, email=self.EMAIL, course_id=self.course_id, staff=False).visit()
def setUp(self): super(CreateCCXCoachTest, self).setUp() self.course_info.update({"settings": {"enable_ccx": "true"}}) self.course_fixture = CourseFixture(**self.course_info) self.course_fixture.add_advanced_settings({ "enable_ccx": {"value": "true"} }) self.course_fixture.install() self.auto_auth(self.USERNAME, self.EMAIL) self.coach_dashboard_page = self.visit_coach_dashboard()
def setUp(self): """ Create the search page and courses to search. """ # 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) super(DashboardSearchTest, self).setUp() self.dashboard = DashboardSearchPage(self.browser) self.courses = { "A": {"org": "test_org", "number": self.unique_id, "run": "test_run_A", "display_name": "Test Course A "}, "B": {"org": "test_org", "number": self.unique_id, "run": "test_run_B", "display_name": "Test Course B "}, "C": {"org": "test_org", "number": self.unique_id, "run": "test_run_C", "display_name": "Test Course C "}, } # generate course fixtures and outline pages self.course_outlines = {} self.course_fixtures = {} for key, course_info in self.courses.iteritems(): course_outline = CourseOutlinePage( self.browser, course_info["org"], course_info["number"], course_info["run"] ) course_fix = CourseFixture( course_info["org"], course_info["number"], course_info["run"], course_info["display_name"] ) course_fix.add_children( XBlockFixtureDesc("chapter", "Section 1").add_children( XBlockFixtureDesc("sequential", "Subsection 1").add_children( XBlockFixtureDesc("problem", "Test Problem") ) ) ).add_children( XBlockFixtureDesc("chapter", "Section 2").add_children(XBlockFixtureDesc("sequential", "Subsection 2")) ).install() self.course_outlines[key] = course_outline self.course_fixtures[key] = course_fix
def setUp(self): super(CrowdsourcehinterProblemTest, self).setUp() self.courseware_page = CoursewarePage(self.browser, self.course_id) # Install a course with sections/problems, tabs, updates, and handouts course_fix = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) problem_data = dedent(''' <problem> <p>A text input problem accepts a line of text from the student, and evaluates the input for correctness based on an expected answer.</p> <p>The answer is correct if it matches every character of the expected answer. This can be a problem with international spelling, dates, or anything where the format of the answer is not clear.</p> <p>Which US state has Lansing as its capital?</p> <stringresponse answer="Michigan" type="ci" > <textline label="Which US state has Lansing as its capital?" size="20"/> </stringresponse> <solution> <div class="detailed-solution"> <p>Explanation</p> <p>Lansing is the capital of Michigan, although it is not Michigan's largest city, or even the seat of the county in which it resides.</p> </div> </solution> </problem> ''') children = XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc('sequential', 'Test Subsection').add_children( XBlockFixtureDesc('vertical', 'Test Unit').add_children( XBlockFixtureDesc('problem', 'text input problem', data=problem_data), XBlockFixtureDesc('crowdsourcehinter', 'test crowdsourcehinter') ) ) ) course_fix.add_children(children).install() # Auto-auth register for the course. AutoAuthPage(self.browser, username=self.USERNAME, email=self.EMAIL, course_id=self.course_id, staff=False).visit()
def setup_fixtures(self): 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('chapter', 'Test Section').add_children( XBlockFixtureDesc('sequential', 'Test Subsection').add_children( XBlockFixtureDesc('vertical', 'Test Unit').add_children( XBlockFixtureDesc('acid_parent', 'Acid Parent Block').add_children( XBlockFixtureDesc('acid', 'First Acid Child', metadata={'name': 'first'}), XBlockFixtureDesc('acid', 'Second Acid Child', metadata={'name': 'second'}), XBlockFixtureDesc('html', 'Html Child', data="<html>Contents</html>"), ) ) ) ) ).install()
class BookmarksTestMixin(EventsTestMixin, UniqueCourseTest): """ Mixin with helper methods for testing Bookmarks. """ USERNAME = "******" EMAIL = "*****@*****.**" def create_course_fixture(self, num_chapters): """ Create course fixture Arguments: num_chapters: number of chapters to create """ self.course_fixture = CourseFixture( # pylint: disable=attribute-defined-outside-init self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) xblocks = [] for index in range(num_chapters): xblocks += [ XBlockFixtureDesc('chapter', 'TestSection{}'.format(index)).add_children( XBlockFixtureDesc('sequential', 'TestSubsection{}'.format(index)).add_children( XBlockFixtureDesc('vertical', 'TestVertical{}'.format(index)) ) ) ] self.course_fixture.add_children(*xblocks).install() def verify_event_data(self, event_type, event_data): """ Verify emitted event data. Arguments: event_type: expected event type event_data: expected event data """ actual_events = self.wait_for_events(event_filter={'event_type': event_type}, number_of_matches=1) self.assert_events_match(event_data, actual_events)
def setUp(self): """ Initialization of pages and course fixture for tests """ super(CMSVideoBaseTest, self).setUp() self.video = VideoComponentPage(self.browser) # This will be initialized later self.unit_page = None self.outline = CourseOutlinePage(self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run']) self.course_fixture = CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']) self.assets = [] self.addCleanup(YouTubeStubConfig.reset)
def setUp(self): super().setUp() self.courseware_page = CoursewarePage(self.browser, self.course_id) # Install a course with sections/problems, tabs, updates, and handouts self.course_fixture = CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']) self.populate_course_fixture(self.course_fixture) self.course_fixture.install() # Auto-auth register for the course. # Do this as global staff so that you will see the Staff View AutoAuthPage(self.browser, username=self.USERNAME, email=self.EMAIL, course_id=self.course_id, staff=True).visit()
def create_course_fixture(self, num_chapters): """ Create course fixture Arguments: num_chapters: number of chapters to create """ self.course_fixture = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) xblocks = [] for index in range(num_chapters): xblocks += [ XBlockFixtureDesc('chapter', 'TestSection{}'.format(index)).add_children( XBlockFixtureDesc('sequential', 'TestSubsection{}'.format(index)).add_children( XBlockFixtureDesc('vertical', 'TestVertical{}'.format(index)) ) ) ] self.course_fixture.add_children(*xblocks).install()
class BaseLmsDashboardTest(UniqueCourseTest): """ Base test suite for the LMS Student Dashboard """ 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()
def setUp(self): super(DiscussionSearchAlertTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments CourseFixture(**self.course_info).install() # first auto auth call sets up a user that we will search for in some tests self.searched_user_id = AutoAuthPage( self.browser, username=self.SEARCHED_USERNAME, course_id=self.course_id ).visit().get_user_id() # this auto auth call creates the actual session user AutoAuthPage(self.browser, course_id=self.course_id).visit() self.page = DiscussionTabHomePage(self.browser, self.course_id) self.page.visit()
def setUp(self): """ Set up a cohorted course """ super(CohortConfigurationTest, self).setUp() # create course with cohorts self.manual_cohort_name = "ManualCohort1" self.auto_cohort_name = "AutoCohort1" self.course_fixture = CourseFixture(**self.course_info).install() self.setup_cohort_config(self.course_fixture, auto_cohort_groups=[self.auto_cohort_name]) self.manual_cohort_id = self.add_manual_cohort(self.course_fixture, self.manual_cohort_name) # create a non-instructor who will be registered for the course and in the manual cohort. self.student_name, self.student_email = self._generate_unique_user_data( ) self.student_id = AutoAuthPage(self.browser, username=self.student_name, email=self.student_email, course_id=self.course_id, staff=False).visit().get_user_id() self.add_user_to_cohort(self.course_fixture, self.student_name, self.manual_cohort_id) # create a second student user self.other_student_name, self.other_student_email = self._generate_unique_user_data( ) self.other_student_id = AutoAuthPage( self.browser, username=self.other_student_name, email=self.other_student_email, course_id=self.course_id, staff=False).visit().get_user_id() # login as an instructor self.instructor_name, self.instructor_email = self._generate_unique_user_data( ) self.instructor_id = AutoAuthPage(self.browser, username=self.instructor_name, email=self.instructor_email, course_id=self.course_id, staff=True).visit().get_user_id() # go to the membership page on the instructor dashboard self.instructor_dashboard_page = InstructorDashboardPage( self.browser, self.course_id) self.instructor_dashboard_page.visit() self.cohort_management_page = self.instructor_dashboard_page.select_cohort_management( )
class StaffViewTest(UniqueCourseTest): """ Tests that verify the staff view. """ USERNAME = "******" EMAIL = "*****@*****.**" def setUp(self): super(StaffViewTest, self).setUp() self.courseware_page = CoursewarePage(self.browser, self.course_id) # Install a course with sections/problems, tabs, updates, and handouts self.course_fixture = CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']) self.populate_course_fixture(self.course_fixture) # pylint: disable=no-member self.course_fixture.install() # Auto-auth register for the course. # Do this as global staff so that you will see the Staff View AutoAuthPage(self.browser, username=self.USERNAME, email=self.EMAIL, course_id=self.course_id, staff=True).visit() def _goto_staff_page(self): """ Open staff page with assertion """ self.courseware_page.visit() staff_page = StaffCoursewarePage(self.browser, self.course_id) self.assertEqual(staff_page.staff_view_mode, 'Staff') return staff_page
def __enter__(self): super().__enter__() # Ensure that we have a directory to put logs and reports self.log_dir.makedirs_p() self.har_dir.makedirs_p() self.report_dir.makedirs_p() test_utils.clean_reports_dir() # pylint: disable=no-value-for-parameter # Set the environment so that webpack understands where to compile its resources. # This setting is expected in other environments, so we are setting it for the # bok-choy test run. os.environ['EDX_PLATFORM_SETTINGS'] = 'test_static_optimized' if not (self.fasttest or self.skip_clean or self.testsonly): test_utils.clean_test_files() msg = colorize('green', "Checking for mongo, memchache, and mysql...") print(msg) check_services() if not self.testsonly: call_task('prepare_bokchoy_run', options={ 'log_dir': self.log_dir, 'coveragerc': self.coveragerc }) else: # load data in db_fixtures load_bok_choy_data() # pylint: disable=no-value-for-parameter update_fixtures() msg = colorize('green', "Confirming servers have started...") print(msg) wait_for_test_servers() try: # Create course in order to seed forum data underneath. This is # a workaround for a race condition. The first time a course is created; # role permissions are set up for forums. dry( "Installing course fixture for forums", CourseFixture('foobar_org', '1117', 'seed_forum', 'seed_foo').install) print('Forums permissions/roles data has been seeded') except FixtureError: # this means it's already been done pass if self.serversonly: self.run_servers_continuously()
def setUp(self): super(VisibleToStaffOnlyTest, self).setUp() 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('chapter', 'Test Section').add_children( XBlockFixtureDesc('sequential', 'Subsection With Locked Unit').add_children( XBlockFixtureDesc('vertical', 'Locked Unit', metadata={'visible_to_staff_only': True}).add_children( XBlockFixtureDesc('html', 'Html Child in locked unit', data="<html>Visible only to staff</html>"), ), XBlockFixtureDesc('vertical', 'Unlocked Unit').add_children( XBlockFixtureDesc('html', 'Html Child in unlocked unit', data="<html>Visible only to all</html>"), ) ), XBlockFixtureDesc('sequential', 'Unlocked Subsection').add_children( XBlockFixtureDesc('vertical', 'Test Unit').add_children( XBlockFixtureDesc('html', 'Html Child in visible unit', data="<html>Visible to all</html>"), ) ), XBlockFixtureDesc('sequential', 'Locked Subsection', metadata={'visible_to_staff_only': True}).add_children( XBlockFixtureDesc('vertical', 'Test Unit').add_children( XBlockFixtureDesc( 'html', 'Html Child in locked subsection', data="<html>Visible only to staff</html>" ) ) ) ) ).install() self.course_home_page = CourseHomePage(self.browser, self.course_id) self.courseware_page = CoursewarePage(self.browser, self.course_id)
def setUp(self): """ Set up a cohorted course with a user_partition of scheme "cohort". """ super(CohortContentGroupAssociationTest, self).setUp() # create course with single cohort and two content groups (user_partition of type "cohort") self.cohort_name = "OnlyCohort" self.course_fixture = CourseFixture(**self.course_info).install() self.setup_cohort_config(self.course_fixture) self.cohort_id = self.add_manual_cohort(self.course_fixture, self.cohort_name) self.course_fixture._update_xblock(self.course_fixture._course_location, { "metadata": { u"user_partitions": [ create_user_partition_json( 0, 'Apples, Bananas', 'Content Group Partition', [Group("0", 'Apples'), Group("1", 'Bananas')], scheme="cohort" ) ], }, }) # login as an instructor self.instructor_name = "instructor_user" self.instructor_id = AutoAuthPage( self.browser, username=self.instructor_name, email="*****@*****.**", course_id=self.course_id, staff=True ).visit().get_user_id() # go to the membership page on the instructor dashboard self.instructor_dashboard_page = InstructorDashboardPage(self.browser, self.course_id) self.instructor_dashboard_page.visit() self.cohort_management_page = self.instructor_dashboard_page.select_cohort_management()
class BaseDiscussionTestCase(UniqueCourseTest): def setUp(self): super(BaseDiscussionTestCase, self).setUp() self.discussion_id = "test_discussion_{}".format(uuid4().hex) self.course_fixture = CourseFixture(**self.course_info) self.course_fixture.add_advanced_settings({ 'discussion_topics': { 'value': { 'Test Discussion Topic': { 'id': self.discussion_id } } } }) self.course_fixture.install() def create_single_thread_page(self, thread_id): """ Sets up a `DiscussionTabSingleThreadPage` for a given `thread_id`. """ return DiscussionTabSingleThreadPage(self.browser, self.course_id, self.discussion_id, thread_id)
def setUp(self): """ Create search page and course content to search """ # 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) super(CoursewareSearchTest, self).setUp() self.course_home_page = CourseHomePage(self.browser, self.course_id) self.studio_course_outline = StudioCourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) 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('chapter', 'Section 1').add_children( XBlockFixtureDesc('sequential', 'Subsection 1') ) ).add_children( XBlockFixtureDesc('chapter', 'Section 2').add_children( XBlockFixtureDesc('sequential', 'Subsection 2') ) ).install()
def setUp(self): """Initialize the page objects and create a test course. """ super(RegisterFromCombinedPageTest, self).setUp() self.register_page = CombinedLoginAndRegisterPage( self.browser, start_page="register", course_id=self.course_id ) self.dashboard_page = DashboardPage(self.browser) # Create a course to enroll in CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ).install()
def setUp(self): """ Initialize pages and install a course fixture. """ super(HighLevelTabTest, self).setUp() # self.course_info['number'] must be shorter since we are accessing the wiki. See TNL-1751 self.course_info['number'] = self.unique_id[0:6] self.course_home_page = CourseHomePage(self.browser, self.course_id) self.progress_page = ProgressPage(self.browser, self.course_id) self.courseware_page = CoursewarePage(self.browser, self.course_id) self.tab_nav = TabNavPage(self.browser) self.video = VideoPage(self.browser) # Install a course with sections/problems, tabs, updates, and handouts course_fix = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) course_fix.add_update( CourseUpdateDesc(date='January 29, 2014', content='Test course update1') ) course_fix.add_handout('demoPDF.pdf') course_fix.add_children( XBlockFixtureDesc('static_tab', 'Test Static Tab', data=r"static tab data with mathjax \(E=mc^2\)"), XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc('sequential', 'Test Subsection').add_children( XBlockFixtureDesc('problem', 'Test Problem 1', data=load_data_str('multiple_choice.xml')), XBlockFixtureDesc('problem', 'Test Problem 2', data=load_data_str('formula_problem.xml')), XBlockFixtureDesc('html', 'Test HTML'), ) ), XBlockFixtureDesc('chapter', 'Test Section 2').add_children( XBlockFixtureDesc('sequential', 'Test Subsection 2'), XBlockFixtureDesc('sequential', 'Test Subsection 3').add_children( XBlockFixtureDesc('problem', 'Test Problem A', data=load_data_str('multiple_choice.xml')) ), ) ).install() # Auto-auth register for the course AutoAuthPage(self.browser, course_id=self.course_id).visit()
def setUp(self): super(BaseDiscussionTestCase, self).setUp() self.discussion_id = "test_discussion_{}".format(uuid4().hex) self.course_fixture = CourseFixture(**self.course_info) self.course_fixture.add_children( XBlockFixtureDesc("chapter", "Test Section").add_children( XBlockFixtureDesc("sequential", "Test Subsection").add_children( XBlockFixtureDesc("vertical", "Test Unit").add_children( XBlockFixtureDesc( "discussion", "Test Discussion", metadata={"discussion_id": self.discussion_id} ) ) ) ) ) self.course_fixture.add_advanced_settings( {'discussion_topics': {'value': {'General': {'id': 'course'}}}} ) self.course_fixture.install() self.enable_forums()
def setUp(self): super(GatingTest, self).setUp() self.logout_page = LogoutPage(self.browser) self.course_home_page = CourseHomePage(self.browser, self.course_id) self.courseware_page = CoursewarePage(self.browser, self.course_id) self.studio_course_outline = StudioCourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run']) xml = dedent(""" <problem> <p>What is height of eiffel tower without the antenna?.</p> <multiplechoiceresponse> <choicegroup label="What is height of eiffel tower without the antenna?" type="MultipleChoice"> <choice correct="false">324 meters<choicehint>Antenna is 24 meters high</choicehint></choice> <choice correct="true">300 meters</choice> <choice correct="false">224 meters</choice> <choice correct="false">400 meters</choice> </choicegroup> </multiplechoiceresponse> </problem> """) self.problem1 = XBlockFixtureDesc('problem', 'HEIGHT OF EIFFEL TOWER', data=xml) # Install a course with sections/problems course_fixture = CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']) course_fixture.add_advanced_settings({ "enable_subsection_gating": { "value": "true" }, 'enable_proctored_exams': { "value": "true" } }) course_fixture.add_children( XBlockFixtureDesc('chapter', 'Test Section 1').add_children( XBlockFixtureDesc('sequential', 'Test Subsection 1').add_children( self.problem1), XBlockFixtureDesc('sequential', 'Test Subsection 2').add_children( XBlockFixtureDesc( 'problem', 'Test Problem 2')), XBlockFixtureDesc('sequential', 'Test Subsection 3').add_children( XBlockFixtureDesc( 'problem', 'Test Problem 3')), )).install()
def setUp(self): """ Set up a discussion topic """ super(BaseDividedDiscussionTest, self).setUp() self.discussion_id = "test_discussion_{}".format(uuid.uuid4().hex) self.course_fixture = CourseFixture(**self.course_info).add_children( XBlockFixtureDesc("chapter", "Test Section").add_children( XBlockFixtureDesc( "sequential", "Test Subsection").add_children( XBlockFixtureDesc( "vertical", "Test Unit").add_children( XBlockFixtureDesc("discussion", "Test Discussion", metadata={ "discussion_id": self.discussion_id }))))).install() # create course with single cohort and two content groups (user_partition of type "cohort") self.cohort_name = "OnlyCohort" self.setup_cohort_config(self.course_fixture) self.cohort_id = self.add_manual_cohort(self.course_fixture, self.cohort_name) # login as an instructor self.instructor_name = "instructor_user" self.instructor_id = AutoAuthPage(self.browser, username=self.instructor_name, email="*****@*****.**", course_id=self.course_id, staff=True).visit().get_user_id() # go to the membership page on the instructor dashboard self.instructor_dashboard_page = InstructorDashboardPage( self.browser, self.course_id) self.instructor_dashboard_page.visit() self.discussion_management_page = self.instructor_dashboard_page.select_discussion_management( ) self.discussion_management_page.wait_for_page() self.course_wide_key = 'course-wide' self.inline_key = 'inline' self.scheme_key = 'scheme'
def setUp(self): super(CertificatesTest, self).setUp() self.test_certificate_config = { 'id': 1, 'name': 'Certificate name', 'description': 'Certificate description', 'course_title': 'Course title override', 'signatories': [], 'version': 1, 'is_active': True } CourseFixture(**self.course_info).install() 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): """ Initialize pages and install a course fixture. """ super(EntranceExamTest, self).setUp() CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']).install() self.course_home_page = CourseHomePage(self.browser, self.course_id) self.settings_page = SettingsPage(self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run']) # Auto-auth register for the course AutoAuthPage(self.browser, course_id=self.course_id).visit()
def setUp(self): super(ProctoredExamTest, self).setUp() self.courseware_page = CoursewarePage(self.browser, self.course_id) self.course_outline = CourseOutlinePage(self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run']) # Install a course with sections/problems, tabs, updates, and handouts course_fix = CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']) course_fix.add_advanced_settings( {"enable_proctored_exams": { "value": "true" }}) course_fix.add_children( XBlockFixtureDesc('chapter', 'Test Section 1').add_children( XBlockFixtureDesc('sequential', 'Test Subsection 1').add_children( XBlockFixtureDesc( 'problem', 'Test Problem 1')))).install() self.track_selection_page = TrackSelectionPage(self.browser, self.course_id) self.payment_and_verification_flow = PaymentAndVerificationFlow( self.browser, self.course_id) self.immediate_verification_page = PaymentAndVerificationFlow( self.browser, self.course_id, entry_point='verify-now') self.upgrade_page = PaymentAndVerificationFlow(self.browser, self.course_id, entry_point='upgrade') self.fake_payment_page = FakePaymentPage(self.browser, self.course_id) self.dashboard_page = DashboardPage(self.browser) self.problem_page = ProblemPage(self.browser) # Add a verified mode to the course ModeCreationPage(self.browser, self.course_id, mode_slug=u'verified', mode_display_name=u'Verified Certificate', min_price=10, suggested_prices='10,20').visit() # Auto-auth register for the course. self._auto_auth(self.USERNAME, self.EMAIL, False)
def setUp(self): super(InlineDiscussionTest, self).setUp() self.discussion_id = "test_discussion_{}".format(uuid4().hex) self.course_fixture = CourseFixture(**self.course_info).add_children( XBlockFixtureDesc("chapter", "Test Section").add_children( XBlockFixtureDesc( "sequential", "Test Subsection").add_children( XBlockFixtureDesc( "vertical", "Test Unit").add_children( XBlockFixtureDesc("discussion", "Test Discussion", metadata={ "discussion_id": self.discussion_id }))))).install() self.setup_cohorts() self.user_id = AutoAuthPage( self.browser, course_id=self.course_id).visit().get_user_id()
def setUp(self): """ Create course page and courses to find """ # create index file with open(self.TEST_INDEX_FILENAME, "w+") as index_file: json.dump({}, index_file) self.addCleanup(remove_file, self.TEST_INDEX_FILENAME) super(CourseDiscoveryTest, self).setUp() self.page = CourseDiscoveryPage(self.browser) for i in range(12): org = 'test_org' number = "{}{}".format(str(i), str(uuid.uuid4().hex.upper()[0:6])) run = "test_run" name = "test course" if i < 10 else "grass is always greener" settings = {'enrollment_start': datetime.datetime(1970, 1, 1).isoformat()} CourseFixture(org, number, run, name, settings=settings).install()
def __enter__(self): super(BokChoyTestSuite, self).__enter__() # Ensure that we have a directory to put logs and reports self.log_dir.makedirs_p() self.har_dir.makedirs_p() self.report_dir.makedirs_p() test_utils.clean_reports_dir() # pylint: disable=no-value-for-parameter if not (self.fasttest or self.skip_clean or self.testsonly): test_utils.clean_test_files() msg = colorize('green', "Checking for mongo, memchache, and mysql...") print msg check_services() if not self.testsonly: call_task('prepare_bokchoy_run', options={'log_dir': self.log_dir}) # pylint: disable=no-value-for-parameter else: # load data in db_fixtures load_bok_choy_data() # pylint: disable=no-value-for-parameter msg = colorize('green', "Confirming servers have started...") print msg wait_for_test_servers() try: # Create course in order to seed forum data underneath. This is # a workaround for a race condition. The first time a course is created; # role permissions are set up for forums. dry( "Installing course fixture for forums", CourseFixture('foobar_org', '1117', 'seed_forum', 'seed_foo').install) print 'Forums permissions/roles data has been seeded' except FixtureError: # this means it's already been done pass if self.serversonly: self.run_servers_continuously()
def setUp(self): super(EntranceExamTest, self).setUp() 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'], settings={ 'entrance_exam_enabled': 'true', 'entrance_exam_minimum_score_pct': '50' }) problem = self.get_problem() course_fixture.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc( 'sequential', 'Test Subsection').add_children(problem))).install() entrance_exam_subsection = None outline = course_fixture.course_outline for child in outline['child_info']['children']: if child.get('display_name') == "Entrance Exam": entrance_exam_subsection = child['child_info']['children'][0] if entrance_exam_subsection: course_fixture.create_xblock(entrance_exam_subsection['id'], problem) # Auto-auth register for the course. AutoAuthPage(self.browser, username=self.USERNAME, email=self.EMAIL, course_id=self.course_id, staff=False).visit()
class BaseDiscussionTestCase(UniqueCourseTest, ForumsConfigMixin): """Base test case class for all discussions-related tests.""" def setUp(self): super(BaseDiscussionTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.discussion_id = "test_discussion_{}".format(uuid4().hex) self.course_fixture = CourseFixture(**self.course_info) self.course_fixture.add_children( XBlockFixtureDesc("chapter", "Test Section").add_children( XBlockFixtureDesc( "sequential", "Test Subsection").add_children( XBlockFixtureDesc( "vertical", "Test Unit").add_children( XBlockFixtureDesc("discussion", "Test Discussion", metadata={ "discussion_id": self.discussion_id }))))) self.course_fixture.add_advanced_settings( {'discussion_topics': { 'value': { 'General': { 'id': 'course' } } }}) self.course_fixture.install() self.enable_forums() def create_single_thread_page(self, thread_id): """ Sets up a `DiscussionTabSingleThreadPage` for a given `thread_id`. """ return DiscussionTabSingleThreadPage(self.browser, self.course_id, self.discussion_id, thread_id)
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(u"PDF Book {}".format(i), [{"title": u"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 setUp(self): """Create a course that is closed for enrollment, and sign in as a user.""" super(EnrollmentClosedRedirectTest, self).setUp() course = CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']) now = datetime.now(pytz.UTC) course.add_course_details({ 'enrollment_start': (now - timedelta(days=30)).isoformat(), 'enrollment_end': (now - timedelta(days=1)).isoformat() }) course.install() # Add an honor mode to the course ModeCreationPage(self.browser, self.course_id).visit() # Add a verified mode to the course ModeCreationPage(self.browser, self.course_id, mode_slug=u'verified', mode_display_name=u'Verified Certificate', min_price=10, suggested_prices='10,20').visit()
class LibraryContentTestBase(UniqueCourseTest): """ Base class for library content block tests """ USERNAME = "******" EMAIL = "*****@*****.**" STAFF_USERNAME = "******" STAFF_EMAIL = "*****@*****.**" shard = 10 def populate_library_fixture(self, library_fixture): """ To be overwritten by subclassed tests. Used to install a library to run tests on. """ def setUp(self): """ Set up library, course and library content XBlock """ super(LibraryContentTestBase, self).setUp() self.courseware_page = CoursewarePage(self.browser, self.course_id) self.studio_course_outline = StudioCourseOutlinePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run']) self.library_fixture = LibraryFixture( 'test_org', self.unique_id, u'Test Library {}'.format(self.unique_id)) self.populate_library_fixture(self.library_fixture) self.library_fixture.install() self.library_info = self.library_fixture.library_info self.library_key = self.library_fixture.library_key # Install a course with library content xblock self.course_fixture = CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']) library_content_metadata = { 'source_library_id': six.text_type(self.library_key), 'mode': 'random', 'max_count': 1, } self.lib_block = XBlockFixtureDesc('library_content', "Library Content", metadata=library_content_metadata) self.course_fixture.add_children( XBlockFixtureDesc('chapter', SECTION_NAME).add_children( XBlockFixtureDesc('sequential', SUBSECTION_NAME).add_children( XBlockFixtureDesc('vertical', UNIT_NAME).add_children( self.lib_block)))) self.course_fixture.install() def _change_library_content_settings(self, count=1, capa_type=None): """ Performs library block refresh in Studio, configuring it to show {count} children """ unit_page = self._go_to_unit_page(True) library_container_block = StudioLibraryContainerXBlockWrapper.from_xblock_wrapper( unit_page.xblocks[1]) library_container_block.edit() editor = StudioLibraryContentEditor(self.browser, library_container_block.locator) editor.count = count if capa_type is not None: editor.capa_type = capa_type editor.save() self._go_to_unit_page(change_login=False) unit_page.wait_for_page() unit_page.publish() self.assertIn("Published and Live", unit_page.publish_title) @property def library_xblocks_texts(self): """ Gets texts of all xblocks in library """ return frozenset(child.data for child in self.library_fixture.children) def _go_to_unit_page(self, change_login=True): """ Open unit page in Studio """ if change_login: LogoutPage(self.browser).visit() self._auto_auth(self.STAFF_USERNAME, self.STAFF_EMAIL, True) self.studio_course_outline.visit() subsection = self.studio_course_outline.section( SECTION_NAME).subsection(SUBSECTION_NAME) return subsection.expand_subsection().unit(UNIT_NAME).go_to() def _goto_library_block_page(self, block_id=None): """ Open library page in LMS """ self.courseware_page.visit() paragraphs = self.courseware_page.q(css='.course-content p').results if not paragraphs: course_home_page = CourseHomePage(self.browser, self.course_id) course_home_page.visit() course_home_page.outline.go_to_section_by_index(0, 0) block_id = block_id if block_id is not None else self.lib_block.locator #pylint: disable=attribute-defined-outside-init self.library_content_page = LibraryContentXBlockWrapper( self.browser, block_id) self.library_content_page.wait_for_page() def _auto_auth(self, username, email, staff): """ Logout and login with given credentials. """ AutoAuthPage(self.browser, username=username, email=email, course_id=self.course_id, staff=staff).visit()
def test_prerequisite_course_save_successfully(self): """ Scenario: Selecting course from Pre-Requisite course drop down save the selected course as pre-requisite course. Given that I am on the Schedule & Details page on studio When I select an item in pre-requisite course drop down and click Save Changes button Then My selected item should be saved as pre-requisite course And My selected item should be selected after refreshing the page.' """ course_number = self.unique_id CourseFixture(org='test_org', number=course_number, run='test_run', display_name='Test Course' + course_number).install() pre_requisite_course_key = generate_course_key(org='test_org', number=course_number, run='test_run') pre_requisite_course_id = unicode(pre_requisite_course_key) # Refresh the page to load the new course fixture and populate the prrequisite course dropdown # Then select the prerequisite course and save the changes self.settings_detail.refresh_page() self.settings_detail.wait_for_prerequisite_course_options() select_option_by_value( browser_query=self.settings_detail.pre_requisite_course_options, value=pre_requisite_course_id) self.settings_detail.save_changes() self.assertEqual('Your changes have been saved.', self.settings_detail.alert_confirmation_title.text) # Refresh the page again and confirm the prerequisite course selection is properly reflected self.settings_detail.refresh_page() self.settings_detail.wait_for_prerequisite_course_options() self.assertTrue( is_option_value_selected(browser_query=self.settings_detail. pre_requisite_course_options, value=pre_requisite_course_id)) # Set the prerequisite course back to None and save the changes select_option_by_value( browser_query=self.settings_detail.pre_requisite_course_options, value='') self.settings_detail.save_changes() self.assertEqual('Your changes have been saved.', self.settings_detail.alert_confirmation_title.text) # Refresh the page again to confirm the None selection is properly reflected self.settings_detail.refresh_page() self.settings_detail.wait_for_prerequisite_course_options() self.assertTrue( is_option_value_selected(browser_query=self.settings_detail. pre_requisite_course_options, value='')) # Re-pick the prerequisite course and confirm no errors are thrown (covers a discovered bug) select_option_by_value( browser_query=self.settings_detail.pre_requisite_course_options, value=pre_requisite_course_id) self.settings_detail.save_changes() self.assertEqual('Your changes have been saved.', self.settings_detail.alert_confirmation_title.text) # Refresh the page again to confirm the prerequisite course selection is properly reflected self.settings_detail.refresh_page() self.settings_detail.wait_for_prerequisite_course_options() dropdown_status = is_option_value_selected( browser_query=self.settings_detail.pre_requisite_course_options, value=pre_requisite_course_id) self.assertTrue(dropdown_status)