• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python actions.register函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.functional.actions.register函数的典型用法代码示例。如果您正苦于以下问题:Python register函数的具体用法?Python register怎么用?Python register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了register函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):
        super(PeerReviewDashboardStudentTest, self).setUp()
        self.base = '/' + self.COURSE_NAME
        context = actions.simple_add_course(
            self.COURSE_NAME, '[email protected]', 'Peer Back Button Child')
        self.course = courses.Course(None, context)

        self.assessment = self.course.add_assessment()
        self.assessment.title = 'Assessment'
        self.assessment.html_content = 'assessment content'
        self.assessment.workflow_yaml = (
            '{grader: human,'
            'matcher: peer,'
            'review_due_date: \'2034-07-01 12:00\','
            'review_min_count: 1,'
            'review_window_mins: 20,'
            'submission_due_date: \'2034-07-01 12:00\'}')
        self.assessment.availability = courses.AVAILABILITY_AVAILABLE

        self.course.save()
        actions.login(self.STUDENT_EMAIL)
        actions.register(self, self.STUDENT_EMAIL)

        actions.submit_assessment(
            self,
            self.assessment.unit_id,
            {'answers': '', 'score': 0,
             'assessment_type': self.assessment.unit_id},
            presubmit_checks=False
        )
开发者ID:2023SS,项目名称:coursebuilder-core,代码行数:30,代码来源:controllers_tests.py


示例2: test_student_cannot_see_reviews_prematurely

    def test_student_cannot_see_reviews_prematurely(self):
        """Test that students cannot see others' reviews prematurely."""

        email = '[email protected]'
        name = 'Student 1'
        submission = transforms.dumps([
            {'index': 0, 'type': 'regex', 'value': 'S1-1', 'correct': True},
            {'index': 1, 'type': 'choices', 'value': 3, 'correct': False},
            {'index': 2, 'type': 'regex', 'value': 'is-S1', 'correct': True},
        ])
        payload = {
            'answers': submission, 'assessment_type': LEGACY_REVIEW_UNIT_ID}

        actions.login(email)
        actions.register(self, name)
        response = actions.submit_assessment(
            self, LEGACY_REVIEW_UNIT_ID, payload)

        # Student 1 cannot see the reviews for his assignment yet, because he
        # has not submitted the two required reviews.
        response = self.get('assessment?name=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_equals(response.status_int, 200)
        actions.assert_contains('Due date for this assignment', response.body)
        actions.assert_contains(
            'After you have completed the required number of peer reviews',
            response.body)

        actions.logout()
开发者ID:2023SS,项目名称:coursebuilder-core,代码行数:28,代码来源:controllers_tests.py


示例3: test_not_enough_assignments_to_allocate

    def test_not_enough_assignments_to_allocate(self):
        """Test for the case when there are too few assignments in the pool."""

        email = '[email protected]'
        name = 'Student 1'
        submission = transforms.dumps([
            {'index': 0, 'type': 'regex', 'value': 'S1-1', 'correct': True},
            {'index': 1, 'type': 'choices', 'value': 3, 'correct': False},
            {'index': 2, 'type': 'regex', 'value': 'is-S1', 'correct': True},
        ])
        payload = {
            'answers': submission, 'assessment_type': LEGACY_REVIEW_UNIT_ID}

        actions.login(email)
        actions.register(self, name)
        response = actions.submit_assessment(
            self, LEGACY_REVIEW_UNIT_ID, payload)

        # The student goes to the review dashboard and requests an assignment
        # to review -- but there is nothing to review.
        response = actions.request_new_review(
            self, LEGACY_REVIEW_UNIT_ID, expected_status_code=200)
        actions.assert_does_not_contain('Assignment to review', response.body)
        actions.assert_contains(
            'Sorry, there are no new submissions ', response.body)
        actions.assert_contains('disabled="true"', response.body)

        actions.logout()
开发者ID:2023SS,项目名称:coursebuilder-core,代码行数:28,代码来源:controllers_tests.py


示例4: setUp

    def setUp(self):
        super(ManualProgressTest, self).setUp()

        # Add a course that will show up.
        context = actions.simple_add_course(COURSE_NAME, ADMIN_EMAIL,
                                            COURSE_TITLE)

        # Register a student for that course.
        actions.login(REGISTERED_STUDENT_EMAIL)
        actions.register(self, REGISTERED_STUDENT_NAME, COURSE_NAME)

        # Add content to course
        self._course = courses.Course(None, context)

        self._unit_one = self._course.add_unit()
        self._unit_one.title = 'Unit Labels: Foo'
        self._unit_one.availability = courses.AVAILABILITY_AVAILABLE
        self._lesson_1_1 = self._course.add_lesson(self._unit_one)
        self._lesson_1_1.title = 'Unit One, Lesson One'
        self._lesson_1_1.availability = courses.AVAILABILITY_AVAILABLE
        self._lesson_1_1.manual_progress = True
        self._lesson_1_2 = self._course.add_lesson(self._unit_one)
        self._lesson_1_2.title = 'Unit One, Lesson Two'
        self._lesson_1_2.availability = courses.AVAILABILITY_AVAILABLE
        self._lesson_1_2.manual_progress = True

        self._unit_two = self._course.add_unit()
        self._unit_two.title = 'Unit Labels: Foo'
        self._unit_two.availability = courses.AVAILABILITY_AVAILABLE
        self._unit_two.manual_progress = True
        self._lesson_2_1 = self._course.add_lesson(self._unit_two)
        self._lesson_2_1.title = 'Unit Two, Lesson One'
        self._lesson_2_1.availability = courses.AVAILABILITY_AVAILABLE
        self._lesson_2_2 = self._course.add_lesson(self._unit_two)
        self._lesson_2_2.title = 'Unit Two, Lesson Two'
        self._lesson_2_2.availability = courses.AVAILABILITY_AVAILABLE

        self._sub_assessment = self._course.add_assessment()
        self._sub_assessment.availability = courses.AVAILABILITY_AVAILABLE

        self._toplevel_assessment = self._course.add_assessment()
        self._sub_assessment.availability = courses.AVAILABILITY_AVAILABLE

        self._unit_three = self._course.add_unit()
        self._unit_three.pre_assessment = self._sub_assessment.unit_id

        self._course.save()

        with common_utils.Namespace(NAMESPACE):
            self.foo_id = models.LabelDAO.save(models.LabelDTO(
                None, {'title': 'Foo',
                       'descripton': 'foo',
                       'type': models.LabelDTO.LABEL_TYPE_COURSE_TRACK}))
            self.bar_id = models.LabelDAO.save(models.LabelDTO(
                None, {'title': 'Bar',
                       'descripton': 'bar',
                       'type': models.LabelDTO.LABEL_TYPE_COURSE_TRACK}))
        self.overridden_environment = actions.OverriddenEnvironment(
            {'course': {analytics.CAN_RECORD_STUDENT_EVENTS: 'true'}})
        self.overridden_environment.__enter__()
开发者ID:2023SS,项目名称:coursebuilder-core,代码行数:60,代码来源:manual_progress_tests.py


示例5: test_announcement_i18n_title

    def test_announcement_i18n_title(self):
        locale = 'de'
        announcement = self._add_announcement_and_translation(locale)
        actions.login('[email protected]')
        actions.register(self, 'John Doe')

        # Verify that one-off title translation also works.
        try:
            sites.set_path_info('/' + self.COURSE)
            ctx = sites.get_course_for_current_request()
            save_locale = ctx.get_current_locale()
            key = announcements.TranslatableResourceAnnouncement.key_for_entity(
                announcement)

            # Untranslated
            ctx.set_current_locale(None)
            i18n_title = str(
                announcements.TranslatableResourceAnnouncement.get_i18n_title(
                    key))
            self.assertEquals('Test Announcement', i18n_title)

            # Translated
            ctx.set_current_locale(locale)
            i18n_title = str(
                announcements.TranslatableResourceAnnouncement.get_i18n_title(
                    key))
            self.assertEquals('TEST ANNOUNCEMENT', i18n_title)
        finally:
            ctx.set_current_locale(save_locale)
            sites.unset_path_info()
开发者ID:google,项目名称:coursebuilder-core,代码行数:30,代码来源:announcements_tests.py


示例6: setUp

    def setUp(self):
        super(StudentRedirectTestBase, self).setUp()
        context = actions.simple_add_course(COURSE_NAME, ADMIN_EMAIL,
                                            COURSE_TITLE)
        course = courses.Course(None, context)
        self.unit = course.add_unit()
        self.unit.title = 'The Unit'
        self.unit.now_available = True
        self.lesson_one = course.add_lesson(self.unit)
        self.lesson_one.title = 'Lesson One'
        self.lesson_one.now_available = True
        self.lesson_two = course.add_lesson(self.unit)
        self.lesson_two.title = 'Lesson Two'
        self.lesson_two.now_available = True
        self.assessment = course.add_assessment()
        self.assessment.title = 'The Assessment'
        self.assessment.now_available = True
        course.save()

        actions.login(REGISTERED_STUDENT_EMAIL)
        actions.register(self, REGISTERED_STUDENT_NAME, COURSE_NAME)
        # Actions.register views the student's profile page; clear this out.
        with common_utils.Namespace(NAMESPACE):
            prefs = models.StudentPreferencesDAO.load_or_default()
            prefs.last_location = None
            models.StudentPreferencesDAO.save(prefs)
开发者ID:mmoylan,项目名称:course-builder,代码行数:26,代码来源:student_last_location.py


示例7: setUp

    def setUp(self):
        super(ManualProgressTest, self).setUp()

        # Add a course that will show up.
        context = actions.simple_add_course(COURSE_NAME, ADMIN_EMAIL, COURSE_TITLE)

        # Register a student for that course.
        actions.login(REGISTERED_STUDENT_EMAIL)
        actions.register(self, REGISTERED_STUDENT_NAME, COURSE_NAME)

        # Add content to course
        self._course = courses.Course(None, context)

        self._unit_one = self._course.add_unit()
        self._unit_one.title = "Unit Labels: Foo"
        self._unit_one.now_available = True
        self._lesson_1_1 = self._course.add_lesson(self._unit_one)
        self._lesson_1_1.title = "Unit One, Lesson One"
        self._lesson_1_1.now_available = True
        self._lesson_1_1.manual_progress = True
        self._lesson_1_2 = self._course.add_lesson(self._unit_one)
        self._lesson_1_2.title = "Unit One, Lesson Two"
        self._lesson_1_2.now_available = True
        self._lesson_1_2.manual_progress = True

        self._unit_two = self._course.add_unit()
        self._unit_two.title = "Unit Labels: Foo"
        self._unit_two.now_available = True
        self._unit_two.manual_progress = True
        self._lesson_2_1 = self._course.add_lesson(self._unit_two)
        self._lesson_2_1.title = "Unit Two, Lesson One"
        self._lesson_2_1.now_available = True
        self._lesson_2_2 = self._course.add_lesson(self._unit_two)
        self._lesson_2_2.title = "Unit Two, Lesson Two"
        self._lesson_2_2.now_available = True

        self._sub_assessment = self._course.add_assessment()
        self._sub_assessment.now_available = True

        self._toplevel_assessment = self._course.add_assessment()
        self._sub_assessment.now_available = True

        self._unit_three = self._course.add_unit()
        self._unit_three.pre_assessment = self._sub_assessment.unit_id

        self._course.save()

        with common_utils.Namespace(NAMESPACE):
            self.foo_id = models.LabelDAO.save(
                models.LabelDTO(
                    None, {"title": "Foo", "descripton": "foo", "type": models.LabelDTO.LABEL_TYPE_COURSE_TRACK}
                )
            )
            self.bar_id = models.LabelDAO.save(
                models.LabelDTO(
                    None, {"title": "Bar", "descripton": "bar", "type": models.LabelDTO.LABEL_TYPE_COURSE_TRACK}
                )
            )

        config.Registry.test_overrides[utils.CAN_PERSIST_ACTIVITY_EVENTS.name] = True
开发者ID:Rosebotics,项目名称:RoseboticsWeb,代码行数:60,代码来源:modules_manual_progress.py


示例8: test_delete_link_when_registered_then_cancel_deletion

 def test_delete_link_when_registered_then_cancel_deletion(self):
     actions.login(self.STUDENT_EMAIL)
     actions.register(self, self.STUDENT_EMAIL)
     response = self.get('course')
     response = self.click(response, 'Delete My Data')
     self._unregister_flow(response, with_deletion_checked=True,
                           cancel_on_deletion=True)
开发者ID:mmoylan,项目名称:course-builder,代码行数:7,代码来源:modules_data_removal.py


示例9: test_unenroll_commanded_with_delete_requested

    def test_unenroll_commanded_with_delete_requested(self):
        user = actions.login(self.STUDENT_EMAIL)
        actions.register(self, self.STUDENT_EMAIL, course=self.COURSE)

        # Verify user is really there.
        with common_utils.Namespace(self.NAMESPACE):
            self.assertIsNotNone(models.Student.get_by_user_id(user.user_id()))

            # Mark user for data deletion upon unenroll
            removal_models.ImmediateRemovalState.set_deletion_pending(
                user.user_id())

            response = self.post(
                models.StudentLifecycleObserver.URL,
                {'user_id': user.user_id(),
                 'event':
                     models.StudentLifecycleObserver.EVENT_UNENROLL_COMMANDED,
                 'timestamp': '2015-05-14T10:02:09.758704Z',
                 'callbacks': appengine_config.CORE_MODULE_NAME},
                headers={'X-AppEngine-QueueName':
                         models.StudentLifecycleObserver.QUEUE_NAME})
            self.assertEquals(response.status_int, 200)
            self.assertEquals('', self.get_log())

            # User should still be there, but now marked unenrolled.
            student = models.Student.get_by_user_id(user.user_id())
            self.assertFalse(student.is_enrolled)

            # Running lifecycle queue should cause data removal to delete user.
            self.execute_all_deferred_tasks(
                models.StudentLifecycleObserver.QUEUE_NAME)

            # User should now be gone.
            self.assertIsNone(models.Student.get_by_user_id(user.user_id()))
开发者ID:google,项目名称:coursebuilder-core,代码行数:34,代码来源:data_removal_tests.py


示例10: test_multiple_students

    def test_multiple_students(self):
        # Register two students
        user = actions.login(self.STUDENT_EMAIL)
        actions.register(self, user.email(), course=self.COURSE)

        other_user = actions.login('[email protected]')
        actions.register(self, other_user.email(), course=self.COURSE)

        # Get IDs of those students; make an event for each.
        with common_utils.Namespace(self.NAMESPACE):
            student1_id = (
                models.Student.get_by_user(user).user_id)
            student2_id = (
                models.Student.get_by_user(other_user).user_id)
            models.EventEntity(user_id=student1_id, source='test').put()
            models.EventEntity(user_id=student2_id, source='test').put()

        # Unregister one of them.
        actions.login(self.STUDENT_EMAIL)
        self._unregister_and_request_data_removal(self.COURSE)
        self._complete_removal()

        # Unregistered student and his data are gone; still-registered
        # student's data is still present.
        with common_utils.Namespace(self.NAMESPACE):
            self.assertIsNone(models.Student.get_by_user(user))
            self.assertIsNotNone(models.Student.get_by_user(other_user))
            entities = list(models.EventEntity.all().run())
            self.assertEquals(1, len(entities))
            self.assertEquals(student2_id, entities[0].user_id)
开发者ID:mmoylan,项目名称:course-builder,代码行数:30,代码来源:modules_data_removal.py


示例11: test_remove_by_email

    def test_remove_by_email(self):
        user = actions.login(self.STUDENT_EMAIL)
        actions.register(self, user.email(), course=self.COURSE)

        with common_utils.Namespace(self.NAMESPACE):
            sse = unsubscribe.SubscriptionStateEntity(
                key_name=user.email())
            sse.is_subscribed = True
            sse.save()

            notifications.Manager.send_async(
                user.email(), self.ADMIN_EMAIL, 'testemail',
                'Mary had a little lamb.  She fed it beans and buns.',
                'Pets for Mary', '{"audit_trail": "yes"}',
                retention_policy=notifications.RetainAll)
            # Finish deferred tasks so notifications subsystem would have
            # deleted items if it were going to.  It shouldn't based on our
            # use of RetainAll above, but belt-and-suspenders.
            self.execute_all_deferred_tasks()
            l = list(notifications.Notification.all().run())
            self.assertEquals(1, len(l))
            l = list(notifications.Payload.all().run())
            self.assertEquals(1, len(l))

        self._unregister_and_request_data_removal(self.COURSE)
        self._complete_removal()

        with common_utils.Namespace(self.NAMESPACE):
            l = list(unsubscribe.SubscriptionStateEntity.all().run())
            self.assertEquals(0, len(l))
            l = list(notifications.Notification.all().run())
            self.assertEquals(0, len(l))
            l = list(notifications.Payload.all().run())
            self.assertEquals(0, len(l))
开发者ID:google,项目名称:coursebuilder-core,代码行数:34,代码来源:data_removal_tests.py


示例12: test_multiple_courses

    def test_multiple_courses(self):
        COURSE_TWO = 'course_two'
        COURSE_TWO_NS = 'ns_' + COURSE_TWO

        # Slight cheat: Register gitkit data remover manually, rather than
        # enabling the entire module, which disrupts normal functional test
        # user login handling
        gitkit.EmailMapping.register_for_data_removal()

        actions.simple_add_course(
            COURSE_TWO, self.ADMIN_EMAIL, 'Data Removal Test Two')
        user = actions.login(self.STUDENT_EMAIL)

        actions.register(self, user.email(), course=self.COURSE)
        actions.register(self, user.email(), course=COURSE_TWO)
        # Slight cheat: Rather than enabling gitkit module, just call
        # the method that will insert the EmailMapping row.
        gitkit.EmailUpdatePolicy.apply(user)

        # Global profile object(s) should now exist.
        profile = models.StudentProfileDAO.get_profile_by_user_id(
            user.user_id())
        self.assertIsNotNone(profile)
        email_policy = gitkit.EmailMapping.get_by_user_id(user.user_id())
        self.assertIsNotNone(email_policy)

        # Unregister from 'data_removal_test' course.
        self._unregister_and_request_data_removal(self.COURSE)
        self._complete_removal()

        # Student object should be gone from data_removal_test course, but
        # not from course_two.
        with common_utils.Namespace(self.NAMESPACE):
            self.assertIsNone(models.Student.get_by_user(user))
        with common_utils.Namespace(COURSE_TWO_NS):
            self.assertIsNotNone(models.Student.get_by_user(user))

        # Global profile object(s) should still exist.
        profile = models.StudentProfileDAO.get_profile_by_user_id(
            user.user_id())
        self.assertIsNotNone(profile)
        email_policy = gitkit.EmailMapping.get_by_user_id(user.user_id())
        self.assertIsNotNone(email_policy)

        # Unregister from other course.
        self._unregister_and_request_data_removal(COURSE_TWO)
        self._complete_removal()

        # Both Student objects should now be gone.
        with common_utils.Namespace(self.NAMESPACE):
            self.assertIsNone(models.Student.get_by_user(user))
        with common_utils.Namespace(COURSE_TWO_NS):
            self.assertIsNone(models.Student.get_by_user(user))

        # Global profile object(s) should also be gone.
        profile = models.StudentProfileDAO.get_profile_by_user_id(
            user.user_id())
        self.assertIsNone(profile)
        email_policy = gitkit.EmailMapping.get_by_user_id(user.user_id())
        self.assertIsNone(email_policy)
开发者ID:google,项目名称:coursebuilder-core,代码行数:60,代码来源:data_removal_tests.py


示例13: test_enrollment

    def test_enrollment(self):
        actions.logout()

        response = self.get_response(
            '{course(id: "%s") {enrollment {email enrolled}}}' % (
                self.course_id))
        enrollment = response['data']['course']['enrollment']
        self.assertEquals({'enrolled': False, 'email': None}, enrollment)

        actions.login(STUDENT_EMAIL)

        response = self.get_response(
            '{course(id: "%s") {enrollment {email enrolled}}}' % (
                self.course_id))
        enrollment = response['data']['course']['enrollment']
        self.assertEquals({'enrolled': False, 'email': None}, enrollment)

        actions.register(self, STUDENT_NAME)

        response = self.get_response(
            '{course (id: "%s") { enrollment { email enrolled}}}' % (
                self.course_id))
        enrollment = response['data']['course']['enrollment']
        self.assertEquals(
            {'enrolled': True, 'email': STUDENT_EMAIL}, enrollment)
开发者ID:google,项目名称:coursebuilder-core,代码行数:25,代码来源:gql_tests.py


示例14: test_unenroll_commanded_only_unenrolls_student

    def test_unenroll_commanded_only_unenrolls_student(self):
        # Register user with profile enabled, so as to trigger call to
        # sites.get_course_for_current_request() when profile is updated
        # from lifecycle queue callback handler.
        user = actions.login(self.STUDENT_EMAIL)
        actions.register(self, self.STUDENT_EMAIL)

        # Verify user is really there.
        with common_utils.Namespace(self.NAMESPACE):
            self.assertIsNotNone(models.Student.get_by_user_id(user.user_id()))

            # Add taskqueue task so that queue callback happens w/o 'self.base'
            # being added to the URL and implicitly getting the course context
            # set.
            task = taskqueue.Task(
                params={
                    'event':
                    models.StudentLifecycleObserver.EVENT_UNENROLL_COMMANDED,
                    'user_id': user.user_id(),
                    'timestamp': '2015-05-14T10:02:09.758704Z',
                    'callbacks': appengine_config.CORE_MODULE_NAME
                },
                target=taskqueue.DEFAULT_APP_VERSION)
            task.add('user-lifecycle')

            # Taskqueue add should not have updated student.
            student = models.Student.get_by_user_id(user.user_id())
            self.assertTrue(student.is_enrolled)

            self.execute_all_deferred_tasks(
                models.StudentLifecycleObserver.QUEUE_NAME)

            # User should still be there, but now marked unenrolled.
            student = models.Student.get_by_user_id(user.user_id())
            self.assertFalse(student.is_enrolled)
开发者ID:google,项目名称:coursebuilder-core,代码行数:35,代码来源:model_models.py


示例15: setUp

    def setUp(self):
        super(ExtraTabsTests, self).setUp()

        self.base = '/' + COURSE_NAME
        app_context = actions.simple_add_course(
            COURSE_NAME, ADMIN_EMAIL, 'Extra Tabs Course')
        self.old_namespace = namespace_manager.get_namespace()
        namespace_manager.set_namespace('ns_%s' % COURSE_NAME)

        self.course = courses.Course(None, app_context)

        courses.Course.ENVIRON_TEST_OVERRIDES = {
            'course': {
                'extra_tabs': [
                    {
                        'label': 'FAQ',
                        'position': 'left',
                        'visibility': 'all',
                        'url': '',
                        'content': 'Frequently asked questions'},
                    {
                        'label': 'Resources',
                        'position': 'right',
                        'visibility': 'student',
                        'url': 'http://www.example.com',
                        'content': 'Links to resources'}]
            }
        }
        self.faq_url = 'modules/extra_tabs/render?index=0'

        actions.login(STUDENT_EMAIL, is_admin=False)
        actions.register(self, STUDENT_NAME)
开发者ID:2023SS,项目名称:coursebuilder-core,代码行数:32,代码来源:extra_tabs_tests.py


示例16: setUp

    def setUp(self):
        super(StudentLabelsTest, self).setUp()
        actions.simple_add_course(COURSE_NAME, ADMIN_EMAIL, COURSE_TITLE)

        with common_utils.Namespace(NAMESPACE):
            self.foo_id = models.LabelDAO.save(models.LabelDTO(
                None, {'title': 'Foo',
                       'descripton': 'foo',
                       'type': models.LabelDTO.LABEL_TYPE_COURSE_TRACK}))
            self.bar_id = models.LabelDAO.save(models.LabelDTO(
                None, {'title': 'Bar',
                       'descripton': 'bar',
                       'type': models.LabelDTO.LABEL_TYPE_COURSE_TRACK}))
            self.baz_id = models.LabelDAO.save(models.LabelDTO(
                None, {'title': 'Baz',
                       'descripton': 'baz',
                       'type': models.LabelDTO.LABEL_TYPE_COURSE_TRACK}))
            self.quux_id = models.LabelDAO.save(models.LabelDTO(
                None, {'title': 'Quux',
                       'descripton': 'quux',
                       'type': models.LabelDTO.LABEL_TYPE_GENERAL}))

        actions.login(REGISTERED_STUDENT_EMAIL)
        actions.register(self, REGISTERED_STUDENT_NAME, COURSE_NAME)
        actions.logout()
开发者ID:barkinet,项目名称:course-builder,代码行数:25,代码来源:student_labels.py


示例17: test_get_news_some_old_some_new

    def test_get_news_some_old_some_new(self):
        user = actions.login(self.STUDENT_EMAIL)
        actions.register(self, 'John Smith')

        # Newsworthy thing happened beyond newsworthy time limit,
        then_ts = utc.now_as_timestamp() - news.NEWSWORTHINESS_SECONDS - 1
        then = utc.timestamp_to_datetime(then_ts)
        self._set_student_enroll_date(user, then)
        news_item = news.NewsItem('test:one', 'url_one', then)
        news.CourseNewsDao.add_news_item(news_item)
        news_item = news.NewsItem('test:two', 'url_two', then)
        news.CourseNewsDao.add_news_item(news_item)
        # But student has seen the thing, so it's marked as non-new.
        news.StudentNewsDao.mark_item_seen('test:one')

        response = self.get('course')
        soup = self.parse_html_string_to_soup(response.body)
        self.assertEquals(['has_new_news'],
                          self._get_news_title_styles(soup))
        self.assertEquals(
            [
                news_tests_lib.NewsItem('Test Item two', 'url_two', True),
                news_tests_lib.NewsItem('Test Item one', 'url_one', False),
            ],
            news_tests_lib.extract_news_items_from_soup(soup))
开发者ID:google,项目名称:coursebuilder-core,代码行数:25,代码来源:news_tests.py


示例18: test_multiple_course

    def test_multiple_course(self):
        """Tests when multiple courses are available."""
        sites.setup_courses('course:/test::ns_test, course:/:/')
        name = 'Test completed course'
        email = 'Student'

        # Make the course available.
        get_environ_old = sites.ApplicationContext.get_environ

        def get_environ_new(self):
            environ = get_environ_old(self)
            environ['course']['now_available'] = True
            return environ

        sites.ApplicationContext.get_environ = get_environ_new

        actions.login(email)
        actions.register(self, name)
        response = self.get('/explorer/courses')
        # Assert if 'View course list' text is shown on my course page.
        actions.assert_contains('View course list', response.body)

        # Clean up app_context.
        sites.ApplicationContext.get_environ = get_environ_old
        sites.reset_courses()
开发者ID:danieldalonzo,项目名称:coursebuilder-core,代码行数:25,代码来源:course_explorer_tests.py


示例19: test_jobs_run

    def test_jobs_run(self):
        COURSE = 'test'
        app_context = actions.simple_add_course(COURSE, ADMIN_EMAIL, 'Test')
        actions.register(self, 'Joe Admin', COURSE)
        config.set_report_allowed(True)
        response = self.get(usage_reporting.StartReportingJobs.URL,
                            headers={'X-AppEngine-Cron': 'True'})
        self.assertEquals(200, response.status_int)
        self.assertEquals('OK.', response.body)
        now = int(time.time())
        self.execute_all_deferred_tasks(
            models.StudentLifecycleObserver.QUEUE_NAME)
        self.execute_all_deferred_tasks()

        expected = [{
            messaging.Message._INSTALLATION: FAKE_INSTALLATION_ID,
            messaging.Message._COURSE: FAKE_COURSE_ID,
            messaging.Message._TIMESTAMP: FAKE_TIMESTAMP,
            messaging.Message._VERSION: os.environ['GCB_PRODUCT_VERSION'],
            messaging.Message._METRIC: messaging.Message.METRIC_STUDENT_COUNT,
            messaging.Message._VALUE: 1,
        }, {
            messaging.Message._INSTALLATION: FAKE_INSTALLATION_ID,
            messaging.Message._COURSE: FAKE_COURSE_ID,
            messaging.Message._TIMESTAMP: now - (now % 3600),
            messaging.Message._VERSION: os.environ['GCB_PRODUCT_VERSION'],
            messaging.Message._METRIC: messaging.Message.METRIC_ENROLLED,
            messaging.Message._VALUE: 1,
        }]
        actual = MockSender.get_sent()
        actual.sort(key=lambda x: x['timestamp'])
        self.assertEquals(expected, actual)
        sites.reset_courses()
开发者ID:barkinet,项目名称:course-builder,代码行数:33,代码来源:modules_usage_reporting.py


示例20: test_multiple_courses

    def test_multiple_courses(self):
        user = self.make_test_user(self.STUDENT_EMAIL)

        COURSE_TWO = 'course_two'
        COURSE_TWO_NS = 'ns_' + COURSE_TWO

        actions.simple_add_course(
            COURSE_TWO, self.ADMIN_EMAIL, 'Data Removal Test Two')

        actions.login(user.email())
        actions.register(self, user.email(), course=self.COURSE)
        actions.register(self, user.email(), course=COURSE_TWO)
        actions.unregister(self, self.COURSE, do_data_removal=True)

        self.execute_all_deferred_tasks(
            models.StudentLifecycleObserver.QUEUE_NAME)
        self.get(
            data_removal.DataRemovalCronHandler.URL,
            headers={'X-AppEngine-Cron': 'True'})
        self.execute_all_deferred_tasks()

        with common_utils.Namespace(self.NAMESPACE):
            self.assertIsNone(models.Student.get_by_user(user))
        with common_utils.Namespace(COURSE_TWO_NS):
            self.assertIsNotNone(
                models.Student.get_by_user(user))
开发者ID:kingctan,项目名称:course-builder,代码行数:26,代码来源:modules_data_removal.py



注:本文中的tests.functional.actions.register函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python actions.simple_add_course函数代码示例发布时间:2022-05-27
下一篇:
Python actions.logout函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap