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
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"
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"]
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
def del_work_experience_page(w_id): del_user_work_experiences(w_id) result = Result(ResultCode.SUCCESS, msg=u'删除成功!').recall() return result
def test_throws_typeerror_on_empty_result(self): with pytest.raises(TypeError): Result()
def test_result_works_with_default_type_and_encoding(self): result = Result("") assert result.content_encoding == "utf-8" assert result.content_type == "application/json"
def test_can_create_result_with_no_type_or_encoding(self): Result("")