コード例 #1
0
    def test_construct_response_msg_works(self):
        resp = Response(self.request, Result({"result1key": "result1val"}))
        response_msg = resp._construct_response_msg()

        assert response_msg["request"] == self.request
        assert response_msg["response"]["cacheable"] == True
        assert response_msg["response"]["error"] == False
コード例 #2
0
    def test_result_works_with_custom_type_and_encoding(self):
        result = Result("",
                        content_type="image/svg+xml",
                        content_encoding="base64")

        assert result.content_encoding == "base64"
        assert result.content_type == "image/svg+xml"
コード例 #3
0
    def test_upload_returns_etag_as_key_when_uploading(self, mocked_client):
        stubbed_client = botocore.session.get_session().create_client(
            "s3", **config.BOTO_RESOURCE_KWARGS)
        stubber = Stubber(stubbed_client)
        stubber.activate()

        r = Result({})
        resp = Response(self.request, r)
        key = resp._upload(r)

        assert key == self.request["ETag"]
コード例 #4
0
    def _(*args, **kwargs):
        try:
            ret = func(*args, **kwargs)
            if isinstance(ret, Response):
                if ret.status_code == 302:
                    result = Result(ResultCode.LOGIN, msg=u'请先登录!!').recall()
                    # result = jsonify(result)
                    result = json.dumps(result)
                else:
                    result = ret
            else:
                # result = jsonify(ret)
                result = json.dumps(ret)
        except:
            if PLATFORM in DEV_MACHINES:
                print traceback.format_exc()

            ret = Result(ResultCode.ERROR, msg=u'服务器错误').recall()
            result = json.dumps(ret)

        return result
コード例 #5
0
def del_work_experience_page(w_id):

    del_user_work_experiences(w_id)
    result = Result(ResultCode.SUCCESS, msg=u'删除成功!').recall()

    return result
コード例 #6
0
 def test_throws_typeerror_on_empty_result(self):
     with pytest.raises(TypeError):
         Result()
コード例 #7
0
    def test_result_works_with_default_type_and_encoding(self):
        result = Result("")

        assert result.content_encoding == "utf-8"
        assert result.content_type == "application/json"
コード例 #8
0
 def test_can_create_result_with_no_type_or_encoding(self):
     Result("")