-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added additional testing to trigger file validator
- Loading branch information
Showing
3 changed files
with
115 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
from pathlib import Path | ||
import pytest | ||
|
||
import src.image.prepare_single_image_build_matrix as prep_matrix | ||
from src.image.utils.schema.triggers import ImageTriggerValidationError | ||
from glob import glob | ||
from pathlib import Path | ||
|
||
|
||
def test_existing_image_trigger_files(): | ||
|
||
for oci_path in glob("oci/*"): | ||
prep_matrix.load_trigger_yaml(Path(oci_path)) | ||
|
||
|
||
def test_image_trigger_validator_missing_channel_risks(): | ||
|
||
image_trigger = { | ||
"version": 1, | ||
"release": { | ||
"latest": { | ||
"end-of-life": "2030-05-01T00:00:00Z", | ||
}, | ||
}, | ||
"upload": [], | ||
} | ||
with pytest.raises(ImageTriggerValidationError): | ||
prep_matrix.validate_image_trigger(image_trigger) | ||
|
||
|
||
def test_image_trigger_validator_missing_release_risks(): | ||
|
||
image_trigger = { | ||
"version": 1, | ||
"release": { | ||
"latest": { | ||
"end-of-life": "2030-05-01T00:00:00Z", | ||
"candidate": "1.0-22.04_candidate", | ||
}, | ||
}, | ||
"upload": [ | ||
{ | ||
"source": "canonical/rocks-toolbox", | ||
"commit": "17916dd5de270e61a6a3fd3f4661a6413a50fd6f", | ||
"directory": "mock_rock/1.2", | ||
"release": { | ||
"1.2-22.04": { | ||
"end-of-life": "2030-05-01T00:00:00Z", | ||
"risks": [], | ||
} | ||
}, | ||
}, | ||
], | ||
} | ||
with pytest.raises(ImageTriggerValidationError): | ||
prep_matrix.validate_image_trigger(image_trigger) | ||
|
||
|
||
def test_image_trigger_validator_minimal_input(): | ||
|
||
image_trigger = { | ||
"version": 1, | ||
"release": { | ||
"latest": { | ||
"end-of-life": "2030-05-01T00:00:00Z", | ||
"candidate": "1.0-22.04_candidate", | ||
}, | ||
}, | ||
"upload": [ | ||
{ | ||
"source": "canonical/rocks-toolbox", | ||
"commit": "17916dd5de270e61a6a3fd3f4661a6413a50fd6f", | ||
"directory": "mock_rock/1.2", | ||
"release": { | ||
"1.2-22.04": { | ||
"end-of-life": "2030-05-01T00:00:00Z", | ||
"risks": ["beta"], | ||
} | ||
}, | ||
}, | ||
], | ||
} | ||
|
||
prep_matrix.validate_image_trigger(image_trigger) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters