def test_get_displayed_information_deyployment(self, monkeypatch): monkeypatch.setattr( settings.k8s, "displayed_information", [ { "name": "Labels", "key": "metadata.labels" }, { "name": "Pipeline", "key": "metadata.labels.pipeline" }, ], ) k8s_app = get_streaming_app_deployment( "streaming-app1", "input-topic1", "output-topic1", "error-topic1", pipeline="pipeline1", ) output = get_displayed_information_deployment( K8sAppDeployment(k8s_app)) assert len(output) == 2 value = output[0].value assert "pipeline" in value assert output[1] == NodeInfoListItem(name="Pipeline", value="pipeline1", type=NodeInfoType.BASIC)
def test_multiple_inputs(self): k8s_app = K8sAppDeployment( get_streaming_app_deployment( name="test-app", input_topics="input-topic1,input-topics2", output_topic="output-topic", error_topic="error-topic", )) assert k8s_app.input_topics == ["input-topic1", "input-topics2"]
def test_is_streams_bootstrap_app(self): streams_app = K8sAppDeployment( get_streaming_app_deployment( name="test-app", input_topics="input-topic", output_topic="output-topic", error_topic=None, )) assert streams_app.is_streams_bootstrap_app() non_streams_app = K8sAppDeployment( get_streaming_app_deployment( name="test-app", input_topics=None, output_topic=None, error_topic=None, )) assert not non_streams_app.is_streams_bootstrap_app()
def test_extra_input_topics(self): k8s_app = K8sAppDeployment( get_streaming_app_deployment( name="test-app", input_topics="input-topic", output_topic="output-topic", error_topic="error-topic", multiple_inputs="0=test1,1=test2", env_prefix="TEST_", )) assert k8s_app.extra_input_topics == ["test1", "test2"]
def test_error_topic_undefined(self): k8s_app = K8sAppDeployment( get_streaming_app_deployment( name="test-app", input_topics="input-topic", output_topic="output-topic", error_topic=None, )) assert k8s_app.name == "test-app" assert k8s_app.error_topic is None assert k8s_app.output_topic == "output-topic" assert k8s_app.input_topics == ["input-topic"]
def test_env_prefix_support(self): k8s_app = K8sAppDeployment( get_streaming_app_deployment( name="test-app", input_topics="input-topic", output_topic="output-topic", error_topic="error-topic", env_prefix="TEST_", )) assert k8s_app.name == "test-app" assert k8s_app.error_topic == "error-topic" assert k8s_app.output_topic == "output-topic" assert k8s_app.input_topics == ["input-topic"]
def test_attributes(self): k8s_app = K8sAppDeployment( get_streaming_app_deployment( name="test-app", input_topics="input-topic", output_topic="output-topic", error_topic="error-topic", multiple_outputs="0=test1,1=test2", env_prefix="TEST_", pipeline="pipeline1", )) assert k8s_app.attributes["pipeline"] == "pipeline1" assert len(k8s_app.attributes) == 1
def get_k8s_app( name="test-app", input_topics="input-topic", output_topic="output-topic", error_topic="error-topic", multiple_inputs=None, multiple_outputs=None, pipeline=None, ): return K8sAppDeployment( get_streaming_app_deployment( name, input_topics, output_topic, error_topic, multiple_inputs, multiple_outputs, pipeline=pipeline, ) )