当前位置: 首页>>代码示例>>Python>>正文


Python Request.body方法代码示例

本文整理汇总了Python中webob.request.Request.body方法的典型用法代码示例。如果您正苦于以下问题:Python Request.body方法的具体用法?Python Request.body怎么用?Python Request.body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webob.request.Request的用法示例。


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

示例1: test_bad_grade_decimal

# 需要导入模块: from webob.request import Request [as 别名]
# 或者: from webob.request.Request import body [as 别名]
 def test_bad_grade_decimal(self):
     """
     Grade returned from Tool Provider doesn't use a period as the decimal point.
     """
     self.xmodule.verify_oauth_body_sign = Mock()
     request = Request(self.environ)
     request.body = self.get_request_body(params={'grade': '0,5'})
     response = self.xmodule.grade_handler(request, '')
     real_response = self.get_response_values(response)
     expected_response = {
         'action': None,
         'code_major': 'failure',
         'description': 'Request body XML parsing error: invalid literal for float(): 0,5',
         'messageIdentifier': 'unknown',
     }
     self.assertEqual(response.status_code, 200)
     self.assertDictEqual(expected_response, real_response)
开发者ID:1amongus,项目名称:edx-platform,代码行数:19,代码来源:test_lti_unit.py

示例2: test_grade_not_in_range

# 需要导入模块: from webob.request import Request [as 别名]
# 或者: from webob.request.Request import body [as 别名]
 def test_grade_not_in_range(self):
     """
     Grade returned from Tool Provider is outside the range 0.0-1.0.
     """
     self.xmodule.verify_oauth_body_sign = Mock()
     request = Request(self.environ)
     request.body = self.get_request_body(params={"grade": "10"})
     response = self.xmodule.grade_handler(request, "")
     real_response = self.get_response_values(response)
     expected_response = {
         "action": None,
         "code_major": "failure",
         "description": "Request body XML parsing error: score value outside the permitted range of 0-1.",
         "messageIdentifier": "unknown",
     }
     self.assertEqual(response.status_code, 200)
     self.assertDictEqual(expected_response, real_response)
开发者ID:mrstephencollins,项目名称:edx-platform,代码行数:19,代码来源:test_lti_unit.py

示例3: test_grade_not_in_range

# 需要导入模块: from webob.request import Request [as 别名]
# 或者: from webob.request.Request import body [as 别名]
 def test_grade_not_in_range(self):
     """
     Grade returned from Tool Provider is outside the range 0.0-1.0.
     """
     self.xmodule.verify_oauth_body_sign = Mock()
     request = Request(self.environ)
     request.body = self.get_request_body(params={'grade': '10'})
     response = self.xmodule.grade_handler(request, '')
     real_response = self.get_response_values(response)
     expected_response = {
         'action': None,
         'code_major': 'failure',
         'description': 'Request body XML parsing error: score value outside the permitted range of 0-1.',
         'messageIdentifier': 'unknown',
     }
     self.assertEqual(response.status_code, 200)
     self.assertDictEqual(expected_response, real_response)
开发者ID:1amongus,项目名称:edx-platform,代码行数:19,代码来源:test_lti_unit.py

示例4: test_unsupported_action

# 需要导入模块: from webob.request import Request [as 别名]
# 或者: from webob.request.Request import body [as 别名]
 def test_unsupported_action(self):
     """
     Action returned from Tool Provider isn't supported.
     `replaceResultRequest` is supported only.
     """
     self.xmodule.verify_oauth_body_sign = Mock()
     request = Request(self.environ)
     request.body = self.get_request_body({'action': 'wrongAction'})
     response = self.xmodule.grade_handler(request, '')
     real_response = self.get_response_values(response)
     expected_response = {
         'action': None,
         'code_major': 'unsupported',
         'description': 'Target does not support the requested operation.',
         'messageIdentifier': self.DEFAULTS['messageIdentifier'],
     }
     self.assertEqual(response.status_code, 200)
     self.assertDictEqual(expected_response, real_response)
开发者ID:1amongus,项目名称:edx-platform,代码行数:20,代码来源:test_lti_unit.py

示例5: test_unsupported_action

# 需要导入模块: from webob.request import Request [as 别名]
# 或者: from webob.request.Request import body [as 别名]
 def test_unsupported_action(self):
     """
     Action returned from Tool Provider isn't supported.
     `replaceResultRequest` is supported only.
     """
     self.xmodule.verify_oauth_body_sign = Mock()
     request = Request(self.environ)
     request.body = self.get_request_body({"action": "wrongAction"})
     response = self.xmodule.grade_handler(request, "")
     real_response = self.get_response_values(response)
     expected_response = {
         "action": None,
         "code_major": "unsupported",
         "description": "Target does not support the requested operation.",
         "messageIdentifier": self.defaults["messageIdentifier"],
     }
     self.assertEqual(response.status_code, 200)
     self.assertDictEqual(expected_response, real_response)
开发者ID:mrstephencollins,项目名称:edx-platform,代码行数:20,代码来源:test_lti_unit.py

示例6: test_authorization_header_not_present

# 需要导入模块: from webob.request import Request [as 别名]
# 或者: from webob.request.Request import body [as 别名]
    def test_authorization_header_not_present(self):
        """
        Request has no Authorization header.
        This is an unknown service request, i.e., it is not a part of the original service specification.
        """
        request = Request(self.environ)
        request.body = self.get_request_body()
        response = self.xmodule.grade_handler(request, '')
        real_response = self.get_response_values(response)
        expected_response = {
            'action': None,
            'code_major': 'failure',
            'description': 'The request has failed.',
            'messageIdentifier': self.DEFAULTS['messageIdentifier'],
        }

        self.assertEqual(response.status_code, 200)
        self.assertDictEqual(expected_response, real_response)
开发者ID:DavidGrahamFL,项目名称:edx-platform,代码行数:20,代码来源:test_lti_unit.py

示例7: test_real_user_is_none

# 需要导入模块: from webob.request import Request [as 别名]
# 或者: from webob.request.Request import body [as 别名]
 def test_real_user_is_none(self):
     """
     If we have no real user, we should send back failure response.
     """
     self.xmodule.verify_oauth_body_sign = Mock()
     self.xmodule.has_score = True
     self.system.get_real_user = Mock(return_value=None)
     request = Request(self.environ)
     request.body = self.get_request_body()
     response = self.xmodule.grade_handler(request, '')
     real_response = self.get_response_values(response)
     expected_response = {
         'action': None,
         'code_major': 'failure',
         'description': 'User not found.',
         'messageIdentifier': self.DEFAULTS['messageIdentifier'],
     }
     self.assertEqual(response.status_code, 200)
     self.assertDictEqual(expected_response, real_response)
开发者ID:1amongus,项目名称:edx-platform,代码行数:21,代码来源:test_lti_unit.py

示例8: test_authorization_header_empty

# 需要导入模块: from webob.request import Request [as 别名]
# 或者: from webob.request.Request import body [as 别名]
    def test_authorization_header_empty(self, get_key_secret):
        """
        Request Authorization header has no value.

        This is an unknown service request, i.e., it is not a part of the original service specification.
        """
        request = Request(self.environ)
        request.authorization = "bad authorization header"
        request.body = self.get_request_body()
        response = self.xmodule.grade_handler(request, '')
        real_response = self.get_response_values(response)
        expected_response = {
            'action': None,
            'code_major': 'failure',
            'description': 'OAuth verification error: Malformed authorization header',
            'messageIdentifier': self.DEFAULTS['messageIdentifier'],
        }
        self.assertEqual(response.status_code, 200)
        self.assertDictEqual(expected_response, real_response)
开发者ID:1amongus,项目名称:edx-platform,代码行数:21,代码来源:test_lti_unit.py

示例9: test_grade_past_due

# 需要导入模块: from webob.request import Request [as 别名]
# 或者: from webob.request.Request import body [as 别名]
 def test_grade_past_due(self):
     """
     Should fail if we do not accept past due grades, and it is past due.
     """
     self.xmodule.accept_grades_past_due = False
     self.xmodule.due = datetime.datetime.now(UTC)
     self.xmodule.graceperiod = Timedelta().from_json("0 seconds")
     request = Request(self.environ)
     request.body = self.get_request_body()
     response = self.xmodule.grade_handler(request, '')
     real_response = self.get_response_values(response)
     expected_response = {
         'action': None,
         'code_major': 'failure',
         'description': 'Grade is past due',
         'messageIdentifier': 'unknown',
     }
     self.assertEqual(response.status_code, 200)
     self.assertEqual(expected_response, real_response)
开发者ID:dehamzah,项目名称:edx-platform,代码行数:21,代码来源:test_lti_unit.py

示例10: test_real_user_is_none

# 需要导入模块: from webob.request import Request [as 别名]
# 或者: from webob.request.Request import body [as 别名]
 def test_real_user_is_none(self):
     """
     If we have no real user, we should send back failure response.
     """
     self.xmodule.verify_oauth_body_sign = Mock()
     self.xmodule.has_score = True
     self.system.get_real_user = Mock(return_value=None)
     request = Request(self.environ)
     request.body = self.get_request_body()
     response = self.xmodule.grade_handler(request, "")
     real_response = self.get_response_values(response)
     expected_response = {
         "action": None,
         "code_major": "failure",
         "description": "User not found.",
         "messageIdentifier": self.defaults["messageIdentifier"],
     }
     self.assertEqual(response.status_code, 200)
     self.assertDictEqual(expected_response, real_response)
开发者ID:mrstephencollins,项目名称:edx-platform,代码行数:21,代码来源:test_lti_unit.py

示例11: test_authorization_header_empty

# 需要导入模块: from webob.request import Request [as 别名]
# 或者: from webob.request.Request import body [as 别名]
    def test_authorization_header_empty(self, _get_key_secret):
        """
        Request Authorization header has no value.

        This is an unknown service request, i.e., it is not a part of the original service specification.
        """
        request = Request(self.environ)
        request.authorization = "bad authorization header"
        request.body = self.get_request_body()
        response = self.xmodule.grade_handler(request, "")
        real_response = self.get_response_values(response)
        expected_response = {
            "action": None,
            "code_major": "failure",
            "description": "OAuth verification error: Malformed authorization header",
            "messageIdentifier": self.defaults["messageIdentifier"],
        }
        self.assertEqual(response.status_code, 200)
        self.assertDictEqual(expected_response, real_response)
开发者ID:mrstephencollins,项目名称:edx-platform,代码行数:21,代码来源:test_lti_unit.py

示例12: test_good_request

# 需要导入模块: from webob.request import Request [as 别名]
# 或者: from webob.request.Request import body [as 别名]
    def test_good_request(self):
        """
        Response from Tool Provider is correct.
        """
        self.xmodule.verify_oauth_body_sign = Mock()
        self.xmodule.has_score = True
        request = Request(self.environ)
        request.body = self.get_request_body()
        response = self.xmodule.grade_handler(request, '')
        description_expected = 'Score for {sourcedId} is now {score}'.format(
                sourcedId=self.DEFAULTS['sourcedId'],
                score=self.DEFAULTS['grade'],
            )
        real_response = self.get_response_values(response)
        expected_response = {
            'action': 'replaceResultResponse',
            'code_major': 'success',
            'description': description_expected,
            'messageIdentifier': self.DEFAULTS['messageIdentifier'],
        }

        self.assertEqual(response.status_code, 200)
        self.assertDictEqual(expected_response, real_response)
开发者ID:Bachmann1234,项目名称:edx-platform,代码行数:25,代码来源:test_lti_unit.py

示例13: test_good_request

# 需要导入模块: from webob.request import Request [as 别名]
# 或者: from webob.request.Request import body [as 别名]
    def test_good_request(self):
        """
        Response from Tool Provider is correct.
        """
        self.xmodule.verify_oauth_body_sign = Mock()
        self.xmodule.has_score = True
        request = Request(self.environ)
        request.body = self.get_request_body()
        response = self.xmodule.grade_handler(request, "")
        description_expected = "Score for {sourcedId} is now {score}".format(
            sourcedId=self.defaults["sourcedId"], score=self.defaults["grade"]
        )
        real_response = self.get_response_values(response)
        expected_response = {
            "action": "replaceResultResponse",
            "code_major": "success",
            "description": description_expected,
            "messageIdentifier": self.defaults["messageIdentifier"],
        }

        self.assertEqual(response.status_code, 200)
        self.assertDictEqual(expected_response, real_response)
        self.assertEqual(self.xmodule.module_score, float(self.defaults["grade"]))
开发者ID:mrstephencollins,项目名称:edx-platform,代码行数:25,代码来源:test_lti_unit.py


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