-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replace deprecated ruamel.yaml.safe_load (#161)
- Loading branch information
Showing
7 changed files
with
64 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ exclude_tags: [] | |
pve: | ||
server: | ||
user: | ||
password | ||
password: | ||
auth_timeout: 5 | ||
verify_ssl: true | ||
|
||
|
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,24 @@ | ||
--- | ||
logging: | ||
level: warning | ||
format: console | ||
|
||
metrics: | ||
enabled: true | ||
address: "127.0.0.1" | ||
port: 8000 | ||
|
||
output_file: dummy | ||
loop_delay: 300 | ||
service: true | ||
|
||
exclude_state: [] | ||
exclude_vmid: [] | ||
exclude_tags: [] | ||
|
||
pve: | ||
server: proxmox.example.com | ||
user: root | ||
password: secure | ||
auth_timeout: 5 | ||
verify_ssl: true |
This file was deleted.
Oops, something went wrong.
Empty file.
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,35 @@ | ||
"""Test Config class.""" | ||
import pytest | ||
import ruamel.yaml | ||
|
||
import prometheuspvesd.exception | ||
from prometheuspvesd.config import Config | ||
|
||
pytest_plugins = [ | ||
"prometheuspvesd.test.fixtures.fixtures", | ||
] | ||
|
||
|
||
def test_yaml_config(mocker, defaults): | ||
mocker.patch( | ||
"prometheuspvesd.config.default_config_file", "./prometheuspvesd/test/data/config.yml" | ||
) | ||
config = Config() | ||
|
||
defaults["pve"]["user"] = "root" | ||
defaults["pve"]["password"] = "secure" | ||
defaults["pve"]["server"] = "proxmox.example.com" | ||
|
||
assert config.config == defaults | ||
|
||
|
||
def test_yaml_config_error(mocker, capsys): | ||
mocker.patch( | ||
"prometheuspvesd.config.default_config_file", "./prometheuspvesd/test/data/config.yml" | ||
) | ||
mocker.patch.object(ruamel.yaml.YAML, "load", side_effect=ruamel.yaml.composer.ComposerError) | ||
|
||
with pytest.raises(prometheuspvesd.exception.ConfigError) as e: | ||
Config() | ||
|
||
assert "Unable to read config file ./prometheuspvesd/test/data/config.yml" in str(e.value) |