Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
Signed-off-by: ravi-kumar-pilla <[email protected]>
  • Loading branch information
ravi-kumar-pilla committed May 16, 2024
1 parent defbf66 commit 9195150
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 9 deletions.
4 changes: 3 additions & 1 deletion package/tests/test_api/test_rest/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,9 @@ def test_save_api_responses_to_fs(
f"{file_path}/api/main", mock_filesystem.return_value
)
mock_api_node_response_to_fs.assert_called_once_with(
f"{file_path}/api/nodes", mock_filesystem.return_value
f"{file_path}/api/nodes",
mock_filesystem.return_value,
is_datasets_previewed,
)
mock_api_pipeline_response_to_fs.assert_called_once_with(
f"{file_path}/api/pipelines", mock_filesystem.return_value
Expand Down
4 changes: 3 additions & 1 deletion package/tests/test_integrations/test_base_deployer.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def test_upload_api_responses(self, mocker):
build = ConcreteBaseDeployer()
build._upload_api_responses(False)

save_api_responses_to_fs_mock.assert_called_once_with(build._path, build._fs)
save_api_responses_to_fs_mock.assert_called_once_with(
build._path, build._fs, False
)

def test_upload_static_files(self, mocker):
mocker.patch("fsspec.filesystem")
Expand Down
45 changes: 41 additions & 4 deletions package/tests/test_launchers/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,26 @@ def test_viz_command_group(mocker, mock_click_echo):
"include_hooks": True,
},
),
(
[
"viz",
"deploy",
"--platform",
"aws",
"--endpoint",
"http://example-bucket.s3-website.us-east-2.amazonaws.com/",
"--bucket-name",
"example-bucket",
"--preview",
"true",
],
{
"platform": "aws",
"endpoint": "http://example-bucket.s3-website.us-east-2.amazonaws.com/",
"bucket_name": "example-bucket",
"preview": True,
},
),
],
)
def test_viz_deploy_valid_endpoint_and_bucket(command_options, deployer_args, mocker):
Expand All @@ -461,6 +481,7 @@ def test_viz_deploy_valid_endpoint_and_bucket(command_options, deployer_args, mo

create_shareableviz_process_mock.assert_called_once_with(
deployer_args.get("platform"),
deployer_args.get("preview", False),
deployer_args.get("endpoint"),
deployer_args.get("bucket_name"),
deployer_args.get("include_hooks", False),
Expand Down Expand Up @@ -539,6 +560,10 @@ def test_viz_deploy_invalid_endpoint(mocker, mock_click_echo):
["viz", "build", "--include-hooks"],
{"platform": "local", "include_hooks": True},
),
(
["viz", "build", "--preview", "true"],
{"platform": "local", "preview": True},
),
],
)
def test_successful_build_with_existing_static_files(
Expand All @@ -557,61 +582,70 @@ def test_successful_build_with_existing_static_files(

create_shareableviz_process_mock.assert_called_once_with(
build_args.get("platform"),
build_args.get("preview", False),
include_hooks=build_args.get("include_hooks", False),
)


@pytest.mark.parametrize(
"platform, endpoint, bucket_name, include_hooks, process_completed_value",
"platform, is_datasets_previewed, endpoint, bucket_name,"
"include_hooks, process_completed_value",
[
(
"azure",
True,
"https://example-bucket.web.core.windows.net",
"example-bucket",
True,
1,
),
(
"aws",
True,
"http://example-bucket.s3-website.us-east-2.amazonaws.com/",
"example-bucket",
True,
1,
),
(
"gcp",
False,
"http://34.120.87.227/",
"example-bucket",
False,
1,
),
("local", None, None, False, 1),
("local", False, None, None, False, 1),
(
"azure",
True,
"https://example-bucket.web.core.windows.net",
"example-bucket",
False,
0,
),
(
"aws",
False,
"http://example-bucket.s3-website.us-east-2.amazonaws.com/",
"example-bucket",
False,
0,
),
(
"gcp",
True,
"http://34.120.87.227/",
"example-bucket",
True,
0,
),
("local", None, None, True, 0),
("local", True, None, None, True, 0),
],
)
def test_create_shareableviz_process(
platform,
is_datasets_previewed,
endpoint,
bucket_name,
include_hooks,
Expand All @@ -624,13 +658,16 @@ def test_create_shareableviz_process(
mock_click_echo,
):
mock_process_completed.return_value.value = process_completed_value
cli.create_shareableviz_process(platform, endpoint, bucket_name, include_hooks)
cli.create_shareableviz_process(
platform, is_datasets_previewed, endpoint, bucket_name, include_hooks
)

# Assert the mocks were called as expected
mock_viz_deploy_process.assert_called_once_with(
target=mock_viz_load_and_deploy,
args=(
platform,
is_datasets_previewed,
endpoint,
bucket_name,
include_hooks,
Expand Down
6 changes: 4 additions & 2 deletions package/tests/test_models/test_flowchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ def test_preview_data_node_metadata(self, example_data_node):
[12345, "80%", "Barbados"],
],
}

DataNodeMetadata.set_is_datasets_previewed(True)
preview_node_metadata = DataNodeMetadata(data_node=example_data_node)

assert preview_node_metadata.preview == expected_preview_data
Expand Down Expand Up @@ -444,10 +446,10 @@ def test_preview_default_data_node_metadata(
assert preview_node_metadata.preview == expected_preview_data

def test_preview_data_node_metadata_not_exist(self, example_data_node, mocker):
mocker.patch("kedro_datasets.pandas.CSVDataset.preview", return_value=False)
mocker.patch("kedro_datasets.pandas.CSVDataset.preview", return_value=None)

preview_node_metadata = DataNodeMetadata(data_node=example_data_node)
assert preview_node_metadata.preview is False
assert preview_node_metadata.preview is None

def test_transcoded_data_node_metadata(self):
dataset = CSVDataset(filepath="/tmp/dataset.csv")
Expand Down
2 changes: 1 addition & 1 deletion package/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,5 @@ def test_save_file(self, tmp_path, mocker):
save_file = tmp_path / "save.json"
run_server(save_file=save_file)
save_api_responses_to_fs_mock.assert_called_once_with(
save_file, mock_filesystem.return_value
save_file, mock_filesystem.return_value, True
)

0 comments on commit 9195150

Please sign in to comment.