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
|
|
|
|
2022-08-30 02:37:22 +03:00
|
|
|
"""Test azureml.assets.test_assets() function."""
|
|
|
|
|
2022-07-08 20:01:50 +03:00
|
|
|
import os
|
2022-05-20 20:19:53 +03:00
|
|
|
import pytest
|
2022-12-29 00:25:12 +03:00
|
|
|
import subprocess
|
|
|
|
from pathlib import Path
|
2022-05-20 20:19:53 +03:00
|
|
|
|
2022-05-27 17:26:42 +03:00
|
|
|
RESOURCES_DIR = Path("resources/pytest")
|
2022-12-29 00:25:12 +03:00
|
|
|
SCRIPTS_DIR = Path("../scripts/test")
|
|
|
|
TEST_ASSETS_SCRIPT = SCRIPTS_DIR / "test_assets.py"
|
|
|
|
TEST_REQUIREMENTS_FILE = SCRIPTS_DIR / "requirements.txt"
|
2022-05-20 20:19:53 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"test_subdir,expected",
|
2023-12-15 19:47:34 +03:00
|
|
|
[
|
|
|
|
("good-assets-with-conda-environment", True),
|
|
|
|
("good-assets-with-requirements", True),
|
|
|
|
("bad-assets", False),
|
|
|
|
("mixed-assets", False)
|
|
|
|
]
|
2022-05-20 20:19:53 +03:00
|
|
|
)
|
|
|
|
def test_test_assets(test_subdir: str, expected: bool):
|
2022-08-30 02:37:22 +03:00
|
|
|
"""Test azureml.assets.test_assets() function."""
|
2022-05-20 20:19:53 +03:00
|
|
|
this_dir = Path(__file__).parent
|
|
|
|
|
2022-08-30 02:37:22 +03:00
|
|
|
subscription_id = os.environ.get("subscription_id")
|
2022-07-08 20:01:50 +03:00
|
|
|
resource_group = os.environ.get("resource_group")
|
|
|
|
workspace_name = os.environ.get("workspace")
|
|
|
|
|
|
|
|
assert subscription_id is not None
|
|
|
|
assert resource_group is not None
|
|
|
|
assert workspace_name is not None
|
2022-12-29 00:25:12 +03:00
|
|
|
|
|
|
|
completed_process = subprocess.run([
|
|
|
|
"python",
|
|
|
|
this_dir / TEST_ASSETS_SCRIPT,
|
|
|
|
"-i", this_dir / RESOURCES_DIR / test_subdir,
|
|
|
|
"-p", this_dir / TEST_REQUIREMENTS_FILE,
|
|
|
|
])
|
|
|
|
assert (completed_process.returncode == 0) == expected
|