def test_returns_env_var_if_provided(self): zeebe_address = str(uuid4()) os.environ["ZEEBE_ADDRESS"] = zeebe_address address = create_address() assert address == zeebe_address
def create_insecure_channel( hostname: Optional[str] = None, port: Optional[int] = None, channel_options: Optional[Dict] = None) -> grpc.aio.Channel: """ Create an insecure channel Args: hostname (Optional[str], optional): Zeebe gateway hostname port (Optional[int], optional): Zeebe gateway port channel_options (Optional[Dict], optional): GRPC channel options. See https://grpc.github.io/grpc/python/glossary.html#term-channel_arguments Returns: grpc.aio.Channel: A GRPC Channel connected to the Zeebe gateway. """ address = create_address(hostname, port) return grpc.aio.insecure_channel( address, options=get_channel_options(channel_options))
def create_secure_channel( hostname: Optional[str] = None, port: Optional[int] = None, channel_options: Optional[Dict] = None, channel_credentials: Optional[grpc.ChannelCredentials] = None, ) -> grpc.aio.Channel: """ Create a secure channel Args: hostname (Optional[str], optional): Zeebe gateway hostname port (Optional[int], optional): Zeebe gateway port channel_options (Optional[Dict], optional): GRPC channel options. See https://grpc.github.io/grpc/python/glossary.html#term-channel_arguments channel_credentials (Optional[grpc.ChannelCredentials]): Channel credentials to use. Will use grpc.ssl_channel_credentials() if not provided. Returns: grpc.aio.Channel: A GRPC Channel connected to the Zeebe gateway. """ address = create_address(hostname, port) credentials = channel_credentials or grpc.ssl_channel_credentials() return grpc.aio.secure_channel( address, credentials, options=get_channel_options(channel_options))
def test_uses_default_address(self, insecure_channel_mock: Mock): create_insecure_channel() insecure_channel_call = insecure_channel_mock.mock_calls[0] assert insecure_channel_call.args[0] == create_address()
def test_returns_default_address(self): address = create_address() assert address == DEFAULT_ADDRESS
def test_default_hostname_is_localhost(self): address = create_address(port=12) assert address.split(":")[0] == "localhost"
def test_default_port_is_26500(self): address = create_address(hostname=str(uuid4())) assert address.split(":")[1] == "26500"