Skip to content

Commit

Permalink
make simple tests
Browse files Browse the repository at this point in the history
Signed-off-by: rashidakanchwala <[email protected]>
  • Loading branch information
rashidakanchwala committed Oct 31, 2024
1 parent a6791ed commit 8b01927
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
23 changes: 9 additions & 14 deletions package/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def example_pipeline_with_node_namespaces():
inputs=["raw_transaction_data", "cleaned_transaction_data"],
outputs="validated_transaction_data",
name="validation_node",
tags=["validation"],
),
node(
func=lambda validated_data, enrichment_data: (
Expand Down Expand Up @@ -381,25 +382,19 @@ def edge_case_example_pipelines(


@pytest.fixture
def edge_case_example_pipelines_with_tags(
example_pipeline_with_dataset_as_input_and_output,
example_pipeline_with_dataset_as_input_to_outer_namespace,
def example_pipelines_with_additional_tags(
example_pipeline_with_node_namespaces
):
"""
Fixture to mock the use cases mentioned in
https://github.com/kedro-org/kedro-viz/issues/2106
"""

pipelines_dict = {
"customer_pipeline": example_pipeline_with_dataset_as_input_and_output,
"car_pipeline": example_pipeline_with_dataset_as_input_to_outer_namespace,
"pipeline": example_pipeline_with_node_namespaces,
"pipeline_with_tags": pipeline(example_pipeline_with_node_namespaces, tags=["tag1", "tag2"]),
}

pipelines_dict["__default__"] = pipeline(
sum(pipeline for pipeline in pipelines_dict.values()),
tags=["default_tag1", "default_tag2"],
)


yield pipelines_dict


Expand Down Expand Up @@ -562,9 +557,9 @@ def example_api_for_edge_case_pipelines(


@pytest.fixture
def example_api_for_edge_case_pipelines_with_tags(
def example_api_for_pipelines_with_additional_tags(
data_access_manager: DataAccessManager,
edge_case_example_pipelines_with_tags: Dict[str, Pipeline],
example_pipelines_with_additional_tags: Dict[str, Pipeline],
example_catalog: DataCatalog,
session_store: BaseSessionStore,
mocker,
Expand All @@ -581,7 +576,7 @@ def example_api_for_edge_case_pipelines_with_tags(
populate_data(
data_access_manager,
example_catalog,
edge_case_example_pipelines_with_tags,
example_pipelines_with_additional_tags,
session_store,
{},
)
Expand Down
12 changes: 7 additions & 5 deletions package/tests/test_api/test_rest/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,15 +594,17 @@ def test_endpoint_main_for_edge_case_pipelines(
actual_modular_pipelines_tree, expected_modular_pipeline_tree_for_edge_cases
)

def test_endpoint_main_for_edge_case_pipelines_with_tags(
def test_endpoint_main_for_pipelines_with_additional_tags(
self,
example_api_for_edge_case_pipelines_with_tags,
example_api_for_pipelines_with_additional_tags,
):
expected_tags = [
{"id": "default_tag1", "name": "default_tag1"},
{"id": "default_tag2", "name": "default_tag2"},
{"id": "tag1", "name": "tag1"},
{"id": "tag2", "name": "tag2"},
{"id": "validation", "name": "validation"},

]
client = TestClient(example_api_for_edge_case_pipelines_with_tags)
client = TestClient(example_api_for_pipelines_with_additional_tags)
response = client.get("/api/main")
actual_tags = response.json()["tags"]
assert actual_tags == expected_tags
Expand Down

0 comments on commit 8b01927

Please sign in to comment.