-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from bluesliverx/main
Prepare to use pydantic config
- Loading branch information
Showing
11 changed files
with
491 additions
and
894 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
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,32 @@ | ||
import os | ||
from typing import List, Union | ||
|
||
import pytest | ||
import yaml | ||
|
||
from buildrunner.validation.config import generate_and_validate_config, Errors | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def set_cwd(): | ||
# Some of the validation tests rely on loading the Dockerfiles in the correct directories, so set the path to the | ||
# top-level project folder (i.e. the root of the repository) | ||
os.chdir(os.path.realpath(os.path.join(os.path.dirname(__file__), "../.."))) | ||
|
||
|
||
@pytest.fixture() | ||
def assert_generate_and_validate_config_errors(): | ||
def _func(config_data: Union[str, dict], error_matches: List[str]): | ||
if isinstance(config_data, str): | ||
config_data = yaml.load(config_data, Loader=yaml.Loader) | ||
config, errors = generate_and_validate_config(**config_data) | ||
if error_matches: | ||
assert not config | ||
assert isinstance(errors, Errors) | ||
for index, error_match in enumerate(error_matches): | ||
assert error_match in errors.errors[index].message | ||
else: | ||
assert config | ||
assert not errors | ||
|
||
return _func |
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
Oops, something went wrong.