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

Python views._cert_info函数代码示例

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

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



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

示例1: test_cert_grade_no_grades

    def test_cert_grade_no_grades(self):
        """
        Tests that the default cert info is returned
        when the learner has no persisted grade or grade
        in the certs table.
        """
        user = Mock(username="fred", id="1")
        survey_url = "http://a_survey.com"
        course = Mock(
            end_of_course_survey_url=survey_url,
            certificates_display_behavior='end',
            id=CourseLocator(org="x", course="y", run="z"),
        )
        course_mode = 'honor'
        cert_status = {'status': 'generating', 'mode': 'honor'}

        with patch('lms.djangoapps.grades.new.course_grade_factory.CourseGradeFactory.read') as patch_persisted_grade:
            patch_persisted_grade.return_value = None
            self.assertEqual(
                _cert_info(user, course, cert_status, course_mode),
                {
                    'status': 'processing',
                    'show_disabled_download_button': False,
                    'show_download_url': False,
                    'show_survey_button': False,
                    'can_unenroll': True,
                }
            )
开发者ID:Stanford-Online,项目名称:edx-platform,代码行数:28,代码来源:tests.py


示例2: test_cert_grade

    def test_cert_grade(self, persisted_grade, cert_grade):
        """
        Tests that the higher of the persisted grade and the grade
        from the certs table is used on the learner dashboard.
        """
        expected_grade = max(persisted_grade, cert_grade)
        user = Mock(username="fred", id="1")
        survey_url = "http://a_survey.com"
        course = Mock(
            end_of_course_survey_url=survey_url,
            certificates_display_behavior='end',
            id=CourseLocator(org="x", course="y", run="z"),
        )
        course_mode = 'honor'

        if cert_grade is not None:
            cert_status = {'status': 'generating', 'grade': unicode(cert_grade), 'mode': 'honor'}
        else:
            cert_status = {'status': 'generating', 'mode': 'honor'}

        with patch('lms.djangoapps.grades.new.course_grade_factory.CourseGradeFactory.read') as patch_persisted_grade:
            patch_persisted_grade.return_value = Mock(percent=persisted_grade)
            self.assertEqual(
                _cert_info(user, course, cert_status, course_mode),
                {
                    'status': 'generating',
                    'show_disabled_download_button': True,
                    'show_download_url': False,
                    'show_survey_button': True,
                    'survey_url': survey_url,
                    'grade': unicode(expected_grade),
                    'mode': 'honor',
                    'linked_in_url': None,
                    'can_unenroll': False,
                }
            )
开发者ID:Stanford-Online,项目名称:edx-platform,代码行数:36,代码来源:tests.py


示例3: test_cert_info

    def test_cert_info(self):
        user = Mock(username="fred", id="1")
        survey_url = "http://a_survey.com"
        course = Mock(
            end_of_course_survey_url=survey_url,
            certificates_display_behavior='end',
            id=CourseLocator(org="x", course="y", run="z"),
        )
        course_mode = 'honor'

        self.assertEqual(
            _cert_info(user, course, None, course_mode),
            {
                'status': 'processing',
                'show_disabled_download_button': False,
                'show_download_url': False,
                'show_survey_button': False,
                'can_unenroll': True,
            }
        )

        cert_status = {'status': 'unavailable'}
        self.assertEqual(
            _cert_info(user, course, cert_status, course_mode),
            {
                'status': 'processing',
                'show_disabled_download_button': False,
                'show_download_url': False,
                'show_survey_button': False,
                'mode': None,
                'linked_in_url': None,
                'can_unenroll': True,
            }
        )

        cert_status = {'status': 'generating', 'grade': '0.67', 'mode': 'honor'}
        with patch('lms.djangoapps.grades.new.course_grade_factory.CourseGradeFactory.read') as patch_persisted_grade:
            patch_persisted_grade.return_value = Mock(percent=1.0)
            self.assertEqual(
                _cert_info(user, course, cert_status, course_mode),
                {
                    'status': 'generating',
                    'show_disabled_download_button': True,
                    'show_download_url': False,
                    'show_survey_button': True,
                    'survey_url': survey_url,
                    'grade': '1.0',
                    'mode': 'honor',
                    'linked_in_url': None,
                    'can_unenroll': False,
                }
            )

        cert_status = {'status': 'generating', 'grade': '0.67', 'mode': 'honor'}
        self.assertEqual(
            _cert_info(user, course, cert_status, course_mode),
            {
                'status': 'generating',
                'show_disabled_download_button': True,
                'show_download_url': False,
                'show_survey_button': True,
                'survey_url': survey_url,
                'grade': '0.67',
                'mode': 'honor',
                'linked_in_url': None,
                'can_unenroll': False,
            }
        )

        download_url = 'http://s3.edx/cert'
        cert_status = {
            'status': 'downloadable', 'grade': '0.67',
            'download_url': download_url,
            'mode': 'honor'
        }

        self.assertEqual(
            _cert_info(user, course, cert_status, course_mode),
            {
                'status': 'ready',
                'show_disabled_download_button': False,
                'show_download_url': True,
                'download_url': download_url,
                'show_survey_button': True,
                'survey_url': survey_url,
                'grade': '0.67',
                'mode': 'honor',
                'linked_in_url': None,
                'can_unenroll': False,
            }
        )

        cert_status = {
            'status': 'notpassing', 'grade': '0.67',
            'download_url': download_url,
            'mode': 'honor'
        }
        self.assertEqual(
            _cert_info(user, course, cert_status, course_mode),
            {
#.........这里部分代码省略.........
开发者ID:Stanford-Online,项目名称:edx-platform,代码行数:101,代码来源:tests.py


示例4: test_cert_info

    def test_cert_info(self):
        user = Mock(username="fred")
        survey_url = "http://a_survey.com"
        course = Mock(end_of_course_survey_url=survey_url)

        self.assertEqual(_cert_info(user, course, None),
                         {'status': 'processing',
                          'show_disabled_download_button': False,
                          'show_download_url': False,
                          'show_survey_button': False,
                          })

        cert_status = {'status': 'unavailable'}
        self.assertEqual(_cert_info(user, course, cert_status),
                         {'status': 'processing',
                          'show_disabled_download_button': False,
                          'show_download_url': False,
                          'show_survey_button': False,
                          'mode': None
                          })

        cert_status = {'status': 'generating', 'grade': '67', 'mode': 'honor'}
        self.assertEqual(_cert_info(user, course, cert_status),
                         {'status': 'generating',
                          'show_disabled_download_button': True,
                          'show_download_url': False,
                          'show_survey_button': True,
                          'survey_url': survey_url,
                          'grade': '67',
                          'mode': 'honor'
                          })

        cert_status = {'status': 'regenerating', 'grade': '67', 'mode': 'verified'}
        self.assertEqual(_cert_info(user, course, cert_status),
                         {'status': 'generating',
                          'show_disabled_download_button': True,
                          'show_download_url': False,
                          'show_survey_button': True,
                          'survey_url': survey_url,
                          'grade': '67',
                          'mode': 'verified'
                          })

        download_url = 'http://s3.edx/cert'
        cert_status = {'status': 'downloadable', 'grade': '67',
                       'download_url': download_url, 'mode': 'honor'}
        self.assertEqual(_cert_info(user, course, cert_status),
                         {'status': 'ready',
                          'show_disabled_download_button': False,
                          'show_download_url': True,
                          'download_url': download_url,
                          'show_survey_button': True,
                          'survey_url': survey_url,
                          'grade': '67',
                          'mode': 'honor'
                          })

        cert_status = {'status': 'notpassing', 'grade': '67',
                       'download_url': download_url, 'mode': 'honor'}
        self.assertEqual(_cert_info(user, course, cert_status),
                         {'status': 'notpassing',
                          'show_disabled_download_button': False,
                          'show_download_url': False,
                          'show_survey_button': True,
                          'survey_url': survey_url,
                          'grade': '67',
                          'mode': 'honor'
                          })

        # Test a course that doesn't have a survey specified
        course2 = Mock(end_of_course_survey_url=None)
        cert_status = {'status': 'notpassing', 'grade': '67',
                       'download_url': download_url, 'mode': 'honor'}
        self.assertEqual(_cert_info(user, course2, cert_status),
                         {'status': 'notpassing',
                          'show_disabled_download_button': False,
                          'show_download_url': False,
                          'show_survey_button': False,
                          'grade': '67',
                          'mode': 'honor'
                          })
开发者ID:DavidGrahamFL,项目名称:edx-platform,代码行数:81,代码来源:tests.py


示例5: test_cert_info

    def test_cert_info(self):
        user = Mock(username="fred")
        survey_url = "http://a_survey.com"
        course = Mock(end_of_course_survey_url=survey_url, certificates_display_behavior='end')

        self.assertEqual(_cert_info(user, course, None),
                         {'status': 'processing',
                          'show_disabled_download_button': False,
                          'show_download_url': False,
                          'show_survey_button': False,
                          })

        cert_status = {'status': 'unavailable'}
        self.assertEqual(_cert_info(user, course, cert_status),
                         {'status': 'processing',
                          'show_disabled_download_button': False,
                          'show_download_url': False,
                          'show_survey_button': False,
                          'mode': None
                          })

        cert_status = {'status': 'generating', 'grade': '67', 'mode': 'honor'}
        self.assertEqual(_cert_info(user, course, cert_status),
                         {'status': 'generating',
                          'show_disabled_download_button': True,
                          'show_download_url': False,
                          'show_survey_button': True,
                          'survey_url': survey_url,
                          'grade': '67',
                          'mode': 'honor'
                          })

        cert_status = {'status': 'regenerating', 'grade': '67', 'mode': 'verified'}
        self.assertEqual(_cert_info(user, course, cert_status),
                         {'status': 'generating',
                          'show_disabled_download_button': True,
                          'show_download_url': False,
                          'show_survey_button': True,
                          'survey_url': survey_url,
                          'grade': '67',
                          'mode': 'verified'
                          })

        download_url = 'http://s3.edx/cert'
        cert_status = {'status': 'downloadable', 'grade': '67',
                       'download_url': download_url, 'mode': 'honor'}
        self.assertEqual(_cert_info(user, course, cert_status),
                         {'status': 'ready',
                          'show_disabled_download_button': False,
                          'show_download_url': True,
                          'download_url': download_url,
                          'show_survey_button': True,
                          'survey_url': survey_url,
                          'grade': '67',
                          'mode': 'honor'
                          })

        cert_status = {'status': 'notpassing', 'grade': '67',
                       'download_url': download_url, 'mode': 'honor'}
        self.assertEqual(_cert_info(user, course, cert_status),
                         {'status': 'notpassing',
                          'show_disabled_download_button': False,
                          'show_download_url': False,
                          'show_survey_button': True,
                          'survey_url': survey_url,
                          'grade': '67',
                          'mode': 'honor'
                          })

        # Test a course that doesn't have a survey specified
        course2 = Mock(end_of_course_survey_url=None)
        cert_status = {'status': 'notpassing', 'grade': '67',
                       'download_url': download_url, 'mode': 'honor'}
        self.assertEqual(_cert_info(user, course2, cert_status),
                         {'status': 'notpassing',
                          'show_disabled_download_button': False,
                          'show_download_url': False,
                          'show_survey_button': False,
                          'grade': '67',
                          'mode': 'honor'
                          })

        # test when the display is unavailable or notpassing, we get the correct results out
        course2.certificates_display_behavior = 'early_no_info'
        cert_status = {'status': 'unavailable'}
        self.assertIsNone(_cert_info(user, course2, cert_status))

        cert_status = {'status': 'notpassing', 'grade': '67',
                       'download_url': download_url, 'mode': 'honor'}
        self.assertIsNone(_cert_info(user, course2, cert_status))
开发者ID:AdityaKashyap,项目名称:edx-platform,代码行数:90,代码来源:tests.py


示例6: test_cert_info

    def test_cert_info(self):
        user = Mock(username="fred")
        survey_url = "http://a_survey.com"
        course = Mock(end_of_course_survey_url=survey_url, certificates_display_behavior="end")
        course_mode = "honor"

        self.assertEqual(
            _cert_info(user, course, None, course_mode),
            {
                "status": "processing",
                "show_disabled_download_button": False,
                "show_download_url": False,
                "show_survey_button": False,
            },
        )

        cert_status = {"status": "unavailable"}
        self.assertEqual(
            _cert_info(user, course, cert_status, course_mode),
            {
                "status": "processing",
                "show_disabled_download_button": False,
                "show_download_url": False,
                "show_survey_button": False,
                "mode": None,
                "linked_in_url": None,
            },
        )

        cert_status = {"status": "generating", "grade": "67", "mode": "honor"}
        self.assertEqual(
            _cert_info(user, course, cert_status, course_mode),
            {
                "status": "generating",
                "show_disabled_download_button": True,
                "show_download_url": False,
                "show_survey_button": True,
                "survey_url": survey_url,
                "grade": "67",
                "mode": "honor",
                "linked_in_url": None,
            },
        )

        cert_status = {"status": "regenerating", "grade": "67", "mode": "verified"}
        self.assertEqual(
            _cert_info(user, course, cert_status, course_mode),
            {
                "status": "generating",
                "show_disabled_download_button": True,
                "show_download_url": False,
                "show_survey_button": True,
                "survey_url": survey_url,
                "grade": "67",
                "mode": "verified",
                "linked_in_url": None,
            },
        )

        download_url = "http://s3.edx/cert"
        cert_status = {"status": "downloadable", "grade": "67", "download_url": download_url, "mode": "honor"}

        self.assertEqual(
            _cert_info(user, course, cert_status, course_mode),
            {
                "status": "ready",
                "show_disabled_download_button": False,
                "show_download_url": True,
                "download_url": download_url,
                "show_survey_button": True,
                "survey_url": survey_url,
                "grade": "67",
                "mode": "honor",
                "linked_in_url": None,
            },
        )

        cert_status = {"status": "notpassing", "grade": "67", "download_url": download_url, "mode": "honor"}
        self.assertEqual(
            _cert_info(user, course, cert_status, course_mode),
            {
                "status": "notpassing",
                "show_disabled_download_button": False,
                "show_download_url": False,
                "show_survey_button": True,
                "survey_url": survey_url,
                "grade": "67",
                "mode": "honor",
                "linked_in_url": None,
            },
        )

        # Test a course that doesn't have a survey specified
        course2 = Mock(end_of_course_survey_url=None)
        cert_status = {"status": "notpassing", "grade": "67", "download_url": download_url, "mode": "honor"}
        self.assertEqual(
            _cert_info(user, course2, cert_status, course_mode),
            {
                "status": "notpassing",
                "show_disabled_download_button": False,
#.........这里部分代码省略.........
开发者ID:Geekathon,项目名称:edx-platform,代码行数:101,代码来源:tests.py


示例7: test_cert_info

    def test_cert_info(self):
        user = Mock(username="fred")
        survey_url = "http://a_survey.com"
        course = Mock(end_of_course_survey_url=survey_url)

        self.assertEqual(
            _cert_info(user, course, None),
            {
                "status": "processing",
                "show_disabled_download_button": False,
                "show_download_url": False,
                "show_survey_button": False,
            },
        )

        cert_status = {"status": "unavailable"}
        self.assertEqual(
            _cert_info(user, course, cert_status),
            {
                "status": "processing",
                "show_disabled_download_button": False,
                "show_download_url": False,
                "show_survey_button": False,
            },
        )

        cert_status = {"status": "generating", "grade": "67"}
        self.assertEqual(
            _cert_info(user, course, cert_status),
            {
                "status": "generating",
                "show_disabled_download_button": True,
                "show_download_url": False,
                "show_survey_button": True,
                "survey_url": survey_url,
                "grade": "67",
            },
        )

        cert_status = {"status": "regenerating", "grade": "67"}
        self.assertEqual(
            _cert_info(user, course, cert_status),
            {
                "status": "generating",
                "show_disabled_download_button": True,
                "show_download_url": False,
                "show_survey_button": True,
                "survey_url": survey_url,
                "grade": "67",
            },
        )

        download_url = "http://s3.edx/cert"
        cert_status = {"status": "downloadable", "grade": "67", "download_url": download_url}
        self.assertEqual(
            _cert_info(user, course, cert_status),
            {
                "status": "ready",
                "show_disabled_download_button": False,
                "show_download_url": True,
                "download_url": download_url,
                "show_survey_button": True,
                "survey_url": survey_url,
                "grade": "67",
            },
        )

        cert_status = {"status": "notpassing", "grade": "67", "download_url": download_url}
        self.assertEqual(
            _cert_info(user, course, cert_status),
            {
                "status": "notpassing",
                "show_disabled_download_button": False,
                "show_download_url": False,
                "show_survey_button": True,
                "survey_url": survey_url,
                "grade": "67",
            },
        )

        # Test a course that doesn't have a survey specified
        course2 = Mock(end_of_course_survey_url=None)
        cert_status = {"status": "notpassing", "grade": "67", "download_url": download_url}
        self.assertEqual(
            _cert_info(user, course2, cert_status),
            {
                "status": "notpassing",
                "show_disabled_download_button": False,
                "show_download_url": False,
                "show_survey_button": False,
                "grade": "67",
            },
        )
开发者ID:nealmcb,项目名称:edx-platform,代码行数:93,代码来源:tests.py


示例8: test_cert_info

    def test_cert_info(self):
        user = Mock(username="fred", id="1")
        survey_url = "http://a_survey.com"
        course = Mock(
            end_of_course_survey_url=survey_url,
            certificates_display_behavior="end",
            id=CourseLocator(org="x", course="y", run="z"),
        )
        course_mode = "honor"

        self.assertEqual(
            _cert_info(user, course, None, course_mode),
            {
                "status": "processing",
                "show_disabled_download_button": False,
                "show_download_url": False,
                "show_survey_button": False,
                "can_unenroll": True,
            },
        )

        cert_status = {"status": "unavailable"}
        self.assertEqual(
            _cert_info(user, course, cert_status, course_mode),
            {
                "status": "processing",
                "show_disabled_download_button": False,
                "show_download_url": False,
                "show_survey_button": False,
                "mode": None,
                "linked_in_url": None,
                "can_unenroll": True,
            },
        )

        cert_status = {"status": "generating", "grade": "67", "mode": "honor"}
        with patch("lms.djangoapps.grades.new.course_grade.CourseGradeFactory.get_persisted") as patch_persisted_grade:
            patch_persisted_grade.return_value = Mock(percent=100)
            self.assertEqual(
                _cert_info(user, course, cert_status, course_mode),
                {
                    "status": "generating",
                    "show_disabled_download_button": True,
                    "show_download_url": False,
                    "show_survey_button": True,
                    "survey_url": survey_url,
                    "grade": "100",
                    "mode": "honor",
                    "linked_in_url": None,
                    "can_unenroll": False,
                },
            )

        cert_status = {"status": "generating", "grade": "67", "mode": "honor"}
        self.assertEqual(
            _cert_info(user, course, cert_status, course_mode),
            {
                "status": "generating",
                "show_disabled_download_button": True,
                "show_download_url": False,
                "show_survey_button": True,
                "survey_url": survey_url,
                "grade": "67",
                "mode": "honor",
                "linked_in_url": None,
                "can_unenroll": False,
            },
        )

        download_url = "http://s3.edx/cert"
        cert_status = {"status": "downloadable", "grade": "67", "download_url": download_url, "mode": "honor"}

        self.assertEqual(
            _cert_info(user, course, cert_status, course_mode),
            {
                "status": "ready",
                "show_disabled_download_button": False,
                "show_download_url": True,
                "download_url": download_url,
                "show_survey_button": True,
                "survey_url": survey_url,
                "grade": "67",
                "mode": "honor",
                "linked_in_url": None,
                "can_unenroll": False,
            },
        )

        cert_status = {"status": "notpassing", "grade": "67", "download_url": download_url, "mode": "honor"}
        self.assertEqual(
            _cert_info(user, course, cert_status, course_mode),
            {
                "status": "notpassing",
                "show_disabled_download_button": False,
                "show_download_url": False,
                "show_survey_button": True,
                "survey_url": survey_url,
                "grade": "67",
                "mode": "honor",
                "linked_in_url": None,
#.........这里部分代码省略.........
开发者ID:Colin-Fredericks,项目名称:edx-platform,代码行数:101,代码来源:tests.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python views.change_enrollment函数代码示例发布时间:2022-05-27
下一篇:
Python factories.UserFactory类代码示例发布时间: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