Skip to content

Commit

Permalink
Removed unneeded leftovers and added validate dockstring
Browse files Browse the repository at this point in the history
  • Loading branch information
eorituz committed Aug 21, 2019
1 parent 64ab9a9 commit b9d96b1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions scenario_player/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ def name(self) -> str:
return self.path.stem

def validate(self):
# The amount of Tokens minted need to be greater than the amount of tokens
# that will be deposited into the UDC
"""Validate cross-config section requirements of the scenario.
:raises InsufficientMintingAmount:
If token.min_balance < settings.services.udc.token.max_funding
"""

# Check that the amount of minted tokens is >= than the amount of deposited tokens
try:
assert self.token.min_balance >= self.settings.services.udc.token.max_funding
except AssertionError:
Expand Down
2 changes: 1 addition & 1 deletion scenario_player/utils/configuration/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def assert_option(cls, expression, err: Optional[Union[str, Exception]] = None):
exception = err
raise exception from e

def validate(self, **args):
def validate(self):
"""Validate the configuration.
Assert that all required keys are present, and no mutually exclusive
Expand Down
4 changes: 2 additions & 2 deletions scenario_player/utils/configuration/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class UDCTokenSettings(ConfigMapping):
def __init__(self, loaded_yaml: dict):
udc_settings = ((loaded_yaml.get("settings") or {}).get("services") or {}).get("udc") or {}
super(UDCTokenSettings, self).__init__(udc_settings.get("token"))
self.validate(loaded_yaml)
self.validate()
print(self.dict)

def validate(self, loaded_yaml):
def validate(self):
self.assert_option(self.max_funding >= self.balance_per_node, UDCTokenConfigError)

@property
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/utils/configuration/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_attributes_whose_key_is_absent_return_expected_default(
MISSING = object()
assert getattr(config, key, MISSING) == expected

def test_balance_per_node_bigger_than_max_funding(self, minimal_yaml_dict):
def test_balance_per_node_must_not_be_greater_than_max_funding(self, minimal_yaml_dict):
minimal_yaml_dict["settings"] = {
"services": {"udc": {"token": {"max_funding": 6000, "balance_per_node": 6001}}}
}
Expand Down

0 comments on commit b9d96b1

Please sign in to comment.