Skip to content

Commit

Permalink
feat: add unit test for null config file
Browse files Browse the repository at this point in the history
  • Loading branch information
aimxhaisse committed Nov 21, 2023
1 parent 2be0482 commit e423d10
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion eth_validator_watcher/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def load_config(config_file: str) -> Config:
The effective configuration used by the watcher
"""
with open(config_file, 'r') as fh:
config = yaml.safe_load(fh)
config = yaml.safe_load(fh) or dict()

from_env = Config().model_dump()
from_yaml = Config(**config).model_dump()
Expand Down
10 changes: 0 additions & 10 deletions tests/config/assets/config.empty.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
beacon_url: ~
beacon_type: other
execution_url: ~
web3signer_url: ~
default_fee_recipient: ~
slack_channel: ~
slack_token: ~
relays: ~
liveness_file: ~
watched_keys: ~
10 changes: 10 additions & 0 deletions tests/config/assets/config.null.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
beacon_url: ~
beacon_type: other
execution_url: ~
web3signer_url: ~
default_fee_recipient: ~
slack_channel: ~
slack_token: ~
relays: ~
liveness_file: ~
watched_keys: ~
16 changes: 16 additions & 0 deletions tests/config/test_load_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
from tests.config import assets


def test_null_config() -> None:
path = Path(assets.__file__).parent / "config.null.yaml"
config = load_config(path)

assert config.beacon_url is None
assert config.execution_url is None
assert config.web3signer_url is None
assert config.default_fee_recipient is None
assert config.slack_channel is None
assert config.slack_token is None
assert config.beacon_type == BeaconType.OTHER
assert config.relays is None
assert config.liveness_file is None
assert config.watched_keys is None


def test_empty_config() -> None:
path = Path(assets.__file__).parent / "config.empty.yaml"
config = load_config(path)
Expand Down

0 comments on commit e423d10

Please sign in to comment.