def test_tcurl(mock_server): endpoint = b"tcurltest" mock_server.expect_call(endpoint).and_write(headers=endpoint, body="hello") hostport = "localhost:%d" % mock_server.port response = yield tcurl.main(["--host", hostport, "--endpoint", endpoint, "--service", "mock-server", "--raw"]) assert response.headers == endpoint assert response.body == "hello"
def test_tcurl_health(): server = TChannel(name='server') server.listen() response = yield main([ '-s', 'server', '--host', server.hostport, '--health', ]) assert response.body.ok
def test_tcurl(mock_server): endpoint = b'tcurltest' mock_server.expect_call(endpoint).and_write(headers=endpoint, body="hello") hostport = 'localhost:%d/%s' % (mock_server.port, endpoint.decode('ascii')) responses = yield tcurl.main(['--host', hostport, '-d', '']) # TODO: get multiple requests working here assert len(responses) == 1 for response in responses: header = yield response.get_header() body = yield response.get_body() assert header == endpoint assert body == "hello"
def test_tcurl(tchannel_server): endpoint = b"tcurltest" tchannel_server.expect_call(endpoint).and_write(headers=endpoint, body="hello") hostport = "localhost:%d/%s" % (tchannel_server.port, endpoint.decode("ascii")) responses = yield tcurl.main(["--host", hostport, "-d", ""]) # TODO: get multiple requests working here assert len(responses) == 1 for response in responses: header = yield response.get_header() body = yield response.get_body() assert header == endpoint assert body == "hello"
def test_tcurl_json(): server = TChannel(name='server') @server.json.register def test(request): return request.body server.listen() response = yield main([ '-s', 'server', '--host', server.hostport, '--body', '{"thing": "foo"}', '--endpoint', 'test', ]) assert response.body == {"thing": "foo"}
def test_tcurl(mock_server): endpoint = b'tcurltest' mock_server.expect_call(endpoint).and_write( headers=endpoint, body="hello" ) hostport = 'localhost:%d' % mock_server.port response = yield tcurl.main([ '--host', hostport, '--endpoint', endpoint, '--service', 'mock-server', '--raw', ]) assert response.headers == endpoint assert response.body == "hello"
def test_tcurl(mock_server): endpoint = b'tcurltest' mock_server.expect_call(endpoint).and_write(headers=endpoint, body="hello") hostport = 'localhost:%d' % mock_server.port response = yield tcurl.main([ '--host', hostport, '--endpoint', endpoint, '--service', 'mock-server', '--raw', ]) assert response.headers == endpoint assert response.body == "hello"
def test_tcurl_thrift(): server = TChannel(name='server') @server.thrift.register(service.ThriftTest) def testString(request): return request.body.thing server.listen() response = yield main([ '-s', 'server', '--host', server.hostport, '--thrift', 'tests/data/idls/ThriftTest.thrift', '--body', '{"thing": "foo"}', '--endpoint', 'ThriftTest::testString', ]) assert response.body == 'foo'
def test_tcurl(mock_server): endpoint = b'tcurltest' mock_server.expect_call(endpoint).and_write( headers=endpoint, body="hello" ) hostport = 'localhost:%d/%s' % ( mock_server.port, endpoint.decode('ascii') ) responses = yield tcurl.main(['--host', hostport, '-d', '']) # TODO: get multiple requests working here assert len(responses) == 1 for response in responses: header = yield response.get_header() body = yield response.get_body() assert header == endpoint assert body == "hello"