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 17, 2024
1 parent ec92a7f commit 50ef2a4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package/kedro_viz/api/rest/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class DeployerConfiguration(BaseModel):
"""Credentials for Deployers."""

platform: str
is_datasets_previewed: bool
are_datasets_previewable: bool = False
endpoint: str
bucket_name: str
2 changes: 1 addition & 1 deletion package/kedro_viz/api/rest/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def deploy_kedro_viz(input_values: DeployerConfiguration):
deployer = DeployerFactory.create_deployer(
input_values.platform, input_values.endpoint, input_values.bucket_name
)
deployer.deploy(input_values.is_datasets_previewed)
deployer.deploy(input_values.are_datasets_previewable)
response = {
"message": "Website deployed on "
f"{input_values.platform and input_values.platform.upper()}",
Expand Down
19 changes: 13 additions & 6 deletions package/tests/test_api/test_rest/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,32 @@ class MockDeployer:
def __init__(self, platform, endpoint, bucket_name):
pass

def deploy(self):
def deploy(self, are_datasets_previewable):
pass


@pytest.mark.parametrize(
"platform, endpoint, bucket_name",
"platform, endpoint, bucket_name, are_datasets_previewable",
[
("aws", "http://mocked-url.com", "s3://shareableviz"),
("azure", "http://mocked-url.com", "abfs://shareableviz"),
("aws", "http://mocked-url.com", "s3://shareableviz", True),
("azure", "http://mocked-url.com", "abfs://shareableviz", False),
],
)
def test_deploy_kedro_viz(client, platform, endpoint, bucket_name, mocker):
def test_deploy_kedro_viz(
client, platform, endpoint, bucket_name, are_datasets_previewable, mocker
):
mocker.patch(
"kedro_viz.api.rest.router.DeployerFactory.create_deployer",
return_value=MockDeployer(platform, endpoint, bucket_name),
)
response = client.post(
"/api/deploy",
json={"platform": platform, "endpoint": endpoint, "bucket_name": bucket_name},
json={
"platform": platform,
"endpoint": endpoint,
"bucket_name": bucket_name,
"are_datasets_previewable": are_datasets_previewable,
},
)

assert response.status_code == 200
Expand Down

0 comments on commit 50ef2a4

Please sign in to comment.