def test_parse_with_complex_includes(): mapped = MappedAST.from_file( utils.test_resource_path("thrifts/include_complex_main.thrift")) assert len(mapped.structs) == 1 assert mapped.structs['Xtruct'] != None assert len(mapped.services) == 1 assert len(mapped.services['ThriftTest'].functions) == 1
def test_parse(): mapped = MappedAST.from_file( utils.test_resource_path("thrifts/thrift_test.thrift")) assert len(mapped.namespaces) == 17 assert len(mapped.structs) == 23 assert len(mapped.services) == 2 assert len(mapped.enums) == 1 assert len(mapped.typedefs) == 1 assert len(mapped.consts) == 1
def test_delegate_simple_param_return(): filename = utils.test_resource_path("thrifts/echo.thrift") ast = MappedAST.from_file(filename) thriftpy_module = thriftpy.load(filename, module_name="echo_thrift") contract = Contract(Provider("provider"), Consumer("consumer"), [ Interaction("provider state", "description", "Echo", Request("echo", ["hello"]), Response("hello")) ]) Delegate = build_delegate( ptcdt.server._ServiceExecutionContext(ast, thriftpy_module, contract, "Echo")) assert Delegate().echo("hello") == "hello"
def thrift_test_ast(): filename = utils.test_resource_path("thrifts/thrift_test.thrift") return MappedAST.from_file(filename)
def thriftpy_test_module(): filename = utils.test_resource_path("thrifts/thrift_test.thrift") return thriftpy.load(filename, module_name="thrift_test_thrift")
def simple_contract(): filename = utils.test_resource_path("contracts/simple.tpact") return parse_contract(filename)
def thriftpy_module(): return thriftpy.load( utils.test_resource_path("thrifts/thrift_test.thrift"), module_name="thrift_test_thrift")
def mapped_ast(): return MappedAST.from_file( utils.test_resource_path("thrifts/thrift_test.thrift"))
def _start_server(): logging.info("Starting server for tests") serve_config(utils.test_resource_path("configs/test-config.ini"))