Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix implicit conversion of data from YAML files #40

Merged
merged 1 commit into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/data/configs/dnf7/rhel-atomic-host.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ modules:
# for nodejs:10, ship all profiles
- name: nodejs
stream: 10
- name: something-else
stream: 1.10
6 changes: 6 additions & 0 deletions tests/ubiconfig/test_ubi.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ def test_load_from_local():
assert isinstance(config, UbiConfig)


def test_load_from_local_decimal_integrity():
loader = ubi.get_loader(TEST_DATA_DIR)
config = loader.load('configs/dnf7/rhel-atomic-host.yaml')
assert config.modules.whitelist[2].stream == '1.10'


def test_load_from_nonyaml(tmpdir):
somefile = tmpdir.join('some-file.txt')
somefile.write('[oops, this is not valid yaml')
Expand Down
2 changes: 1 addition & 1 deletion ubiconfig/_impl/loaders/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def load(self, file_name):
response = self._session.get(config_file_url)
response.raise_for_status()

config_dict = yaml.safe_load(response.content)
config_dict = yaml.load(response.content, Loader=yaml.BaseLoader)
# validate input data
validate_config(config_dict)

Expand Down
2 changes: 1 addition & 1 deletion ubiconfig/_impl/loaders/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def load(self, file_name):
LOG.info("Loading configuration file locally: %s", file_path)

with open(file_path, 'r') as f:
config_dict = yaml.safe_load(f)
config_dict = yaml.load(f, Loader=yaml.BaseLoader)
# validate input data
validate_config(config_dict)

Expand Down