Skip to content

Commit

Permalink
test: adds invalid ssp index test to test_ssp.py
Browse files Browse the repository at this point in the history
Signed-off-by: Jennifer Power <[email protected]>
  • Loading branch information
jpower432 committed Jan 30, 2024
1 parent 1f84696 commit a2d1fe9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/data/json/invalid_test_ssp_index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ssp-name":
{
"profile": "profile"
}
}
1 change: 1 addition & 0 deletions tests/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
JSON_TEST_DATA_PATH = pathlib.Path("tests/data/json/").resolve()
YAML_TEST_DATA_PATH = pathlib.Path("tests/data/yaml/").resolve()
TEST_SSP_INDEX = JSON_TEST_DATA_PATH / "test_ssp_index.json"
INVALID_TEST_SSP_INDEX = JSON_TEST_DATA_PATH / "invalid_test_ssp_index.json"

# E2E test constants
TRESTLEBOT_TEST_IMAGE_NAME = "localhost/trestlebot:latest"
Expand Down
16 changes: 16 additions & 0 deletions tests/trestlebot/tasks/authored/test_ssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,22 @@ def test_reload(tmp_trestle_dir: str) -> None:
ssp_index.get_profile_by_ssp("new_ssp")


def test_invalid_ssp_index(tmp_trestle_dir: str) -> None:
"""Test to trigger failure for invalid SSP index"""
ssp_index_path = os.path.join(tmp_trestle_dir, "ssp-index.json")
ssp_index: SSPIndex = SSPIndex(ssp_index_path)

# Copy over a new index
shutil.copy2(testutils.INVALID_TEST_SSP_INDEX, ssp_index_path)

# Reread the ssp index from JSON
with pytest.raises(
AuthoredObjectException,
match="SSP .* entry is missing profile or component data",
):
ssp_index.reload()


def test_create_new_with_filter(tmp_trestle_dir: str) -> None:
"""Test to create new SSP with filtering by profile"""
# Prepare the workspace and input ssp
Expand Down

0 comments on commit a2d1fe9

Please sign in to comment.