2022-07-25 23:45:44 +03:00
|
|
|
# Copyright (c) Microsoft Corporation.
|
|
|
|
# Licensed under the MIT License.
|
2022-07-08 19:28:41 +03:00
|
|
|
|
2023-03-09 20:29:30 +03:00
|
|
|
"""Test validate_assets script."""
|
|
|
|
|
2022-05-20 21:26:20 +03:00
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
import azureml.assets as assets
|
|
|
|
|
2022-06-14 00:06:50 +03:00
|
|
|
RESOURCES_DIR = Path("resources/validate")
|
2022-05-20 21:26:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
2023-03-09 20:29:30 +03:00
|
|
|
"test_subdir,check_images,expected",
|
|
|
|
[
|
|
|
|
("name-mismatch", False, False),
|
|
|
|
("version-mismatch", False, False),
|
|
|
|
("invalid-strings", False, False),
|
|
|
|
("env-with-underscores", False, False),
|
|
|
|
("framework-ver-missing", False, False),
|
|
|
|
("ubuntu-in-name", False, False),
|
|
|
|
("extra-gpu", False, False),
|
|
|
|
("incorrect-order", False, False),
|
|
|
|
("image-name-mismatch", True, False),
|
|
|
|
("publishing-disabled", True, False),
|
|
|
|
("good-validation", True, True),
|
|
|
|
("correct-order", True, True),
|
2023-04-07 23:24:52 +03:00
|
|
|
("missing-description-file", True, False),
|
2023-03-09 20:29:30 +03:00
|
|
|
]
|
2022-05-20 21:26:20 +03:00
|
|
|
)
|
2023-03-09 20:29:30 +03:00
|
|
|
def test_validate_assets(test_subdir: str, check_images: bool, expected: bool):
|
|
|
|
"""Test validate_assets function.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
test_subdir (str): Test subdirectory
|
|
|
|
check_images (bool): Check image build/publish info
|
|
|
|
expected (bool): Success expected
|
|
|
|
"""
|
2022-05-20 21:26:20 +03:00
|
|
|
this_dir = Path(__file__).parent
|
|
|
|
|
|
|
|
assert assets.validate_assets(
|
2023-03-09 20:29:30 +03:00
|
|
|
input_dirs=this_dir / RESOURCES_DIR / test_subdir,
|
|
|
|
asset_config_filename=assets.DEFAULT_ASSET_FILENAME,
|
|
|
|
check_images=check_images) == expected
|