def test_failing_advertise_should_raise(mock_server): mock_server.expect_call('ad', 'json').and_raise( Exception('great sadness') ) routers = [mock_server.tchannel.hostport] client = TChannelSyncClient('test-client') with pytest.raises(AdvertiseError): client.advertise(routers, timeout=0.1)
def test_advertise_should_result_in_peer_connections(mock_server): body = {"hello": "world"} mock_server.expect_call('ad', 'json').and_write( headers="", body=body, ) routers = [ mock_server.tchannel.hostport ] client = TChannelSyncClient('test-client') result = client.advertise(routers) assert result.header == "" # @todo https://github.com/uber/tchannel-python/issues/34 assert result.body == json.dumps(body) assert client._async_client.peers.hosts == routers