Skip to content

Commit

Permalink
test: update tests related to the dict overrides changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamantios committed Aug 22, 2024
1 parent dc5c4ad commit 351dce2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
9 changes: 5 additions & 4 deletions tests/test_cli/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def test_set_nested_attribute_not_allowed(self):
assert result.exit_code == 1
assert (
result.exception.message
== "Attribute `behaviours.dummy.config.behaviour_arg_1` is not allowed to be updated!"
== "Attribute `behaviours.dummy.config` is not allowed to be updated!"
)

def test_no_recognized_root(self):
Expand Down Expand Up @@ -542,10 +542,11 @@ def test_attribute_not_found(self):
catch_exceptions=False,
)

def test_set_fails_when_setting_non_primitive_type(self):
def test_incorrect_data_type(self):
"""Test that setting the 'dummy' skill behaviours fails because not a primitive type."""
with pytest.raises(
ClickException, match="Attribute `behaviours` is not allowed to be updated!"
ClickException,
match="For attribute `behaviours` `dict` data type is expected, but `str` was provided!",
):
self.runner.invoke(
cli,
Expand All @@ -558,7 +559,7 @@ def test_get_fails_when_setting_nested_object(self):
"""Test that setting a nested object in 'dummy' skill fails because path is not valid."""
with pytest.raises(
ClickException,
match=r"Attribute `non_existing_attribute.dummy` is not allowed to be updated!",
match=r"Attribute `non_existing_attribute` is not allowed to be updated!",
):
self.runner.invoke(
cli,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_configurations/test_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2022-2023 Valory AG
# Copyright 2022-2024 Valory AG
# Copyright 2018-2021 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -298,7 +298,7 @@ def test_update_method_raises_error_if_skill_component_not_allowed(self):

with pytest.raises(
ValueError,
match="Attribute `behaviours.new_behaviour.args` is not allowed to be updated!",
match="Attribute `behaviours.new_behaviour` is not allowed to be updated!",
):
skill_config.update(new_configurations)

Expand Down
7 changes: 4 additions & 3 deletions tests/test_configurations/test_validation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2022 Valory AG
# Copyright 2022-2024 Valory AG
# Copyright 2018-2021 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -46,14 +46,15 @@ def test_compare_data_pattern():
assert not validate_data_with_pattern(
{"a": "${var}"}, {"a": "string"}, skip_env_vars=True
)
assert not validate_data_with_pattern({"a": {}}, {"a": {"b": 12}})

errors = validate_data_with_pattern({"a": 12}, {"b": 12})
assert errors
assert errors[0] == "Attribute `a` is not allowed to be updated!"

errors = validate_data_with_pattern({"a": {}}, {"a": {"b": 12}})
errors = validate_data_with_pattern({"a": {"b": 12}}, {"a": {}})
assert errors
assert errors[0] == "Attribute `a` is not allowed to be updated!"
assert errors[0] == "Attribute `a.b` is not allowed to be updated!"


def test_filter_data():
Expand Down

0 comments on commit 351dce2

Please sign in to comment.