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

Test/models #317

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
18 changes: 9 additions & 9 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
"contract/valory/mech_activity/0.1.0": "bafybeiec6nnvfs6captlncrtjfygpp275vkfajvj4frrnab7thsca6337e",
"contract/valory/staking_token/0.1.0": "bafybeig4fl35dn7d5gnprux2nwsqbirm7zkiujz3xvrwcjuktz6hkq4as4",
"contract/valory/relayer/0.1.0": "bafybeihzgjyvhtorugjw3yldznqsbwo3aqpxowm7k2nrvj6qtwpsc7jl7u",
"skill/valory/market_manager_abci/0.1.0": "bafybeiai6djelf6d4dkxgkv46l24q2gz7736b3jdhbxslvcydpvnvrse6e",
"skill/valory/decision_maker_abci/0.1.0": "bafybeieaenzaucsz7234gynswn7f2ufsvhkhbniuc4mhh3kvu7atvdjqwu",
"skill/valory/trader_abci/0.1.0": "bafybeidqh5nmjg6jk5hwqzf3abvjd4jiabs6eroisw5nh6d557isorxely",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiatr5y2qhqkqc7xtllwagk66wfnmbvdjmokb6ptlrhczzwwn76fce",
"skill/valory/staking_abci/0.1.0": "bafybeiduborfqevheegy3plk7bzhkl4fukwixvlb57tenijdepintubbdi",
"skill/valory/check_stop_trading_abci/0.1.0": "bafybeiepylk35n3faurvp7dskjkdovehftzfjrjxfkpekzuaovt5gojxne",
"agent/valory/trader/0.1.0": "bafybeifinxnuxu4ye2catrgrma7uyqm3f2hlurs4xsch27xftfo6im5ihm",
"service/valory/trader/0.1.0": "bafybeidgliu5ylcpznirtn6vfs3g4d74utzfciuo4yqgcuj3ux6iwz5v2y",
"service/valory/trader_pearl/0.1.0": "bafybeicrstlxew36hlxl7pzi73nmd44aibnhwxzkchzlec6t6yhvs7gvhy"
"skill/valory/market_manager_abci/0.1.0": "bafybeid5ne5o75g4lipoagsaw4elo63tlukn6litdghcygtcuxjvqoehq4",
"skill/valory/decision_maker_abci/0.1.0": "bafybeigrg3qrekuvqqegizifj3l323hemqtxd5i2jfw6blprsa4iyt75ha",
"skill/valory/trader_abci/0.1.0": "bafybeibp6qumpdewwsxl7crt4mahlbq72fn5ji52bnujz6khc2zkiiqtwy",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeieyzzoo7kg7nyoa35ezykbkecipvzf6as63zwdvvem2m2zbgj3vme",
"skill/valory/staking_abci/0.1.0": "bafybeicdmf7eqgnf7dyaau4jhvmsje7ueehiq5bhlekzslikntl5zomxmu",
"skill/valory/check_stop_trading_abci/0.1.0": "bafybeif6my6vcflbdki7okfhpote3szyywqi7ns5mb72j53vsy5k3pqlpy",
"agent/valory/trader/0.1.0": "bafybeiaxqyyyttr7uky44nfkovpbbalvulrzaryppishcmb6tvqpl63ob4",
"service/valory/trader/0.1.0": "bafybeicwisgz2ljub3raqxztlgnyh5zvrzytshncatux7xbhlcef2wtpdi",
"service/valory/trader_pearl/0.1.0": "bafybeibp3sccmcpq26jxfmgf75dv6ff4pucvkirvghosehoxmfyvbvidxq"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down
12 changes: 6 additions & 6 deletions packages/valory/agents/trader/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeiameewywqigpupy3u2iwnkfczeiiucue74x2l5lbge74rmw6bgaie
- valory/termination_abci:0.1.0:bafybeif2zim2de356eo3sipkmoev5emwadpqqzk3huwqarywh4tmqt3vzq
- valory/transaction_settlement_abci:0.1.0:bafybeic3tccdjypuge2lewtlgprwkbb53lhgsgn7oiwzyrcrrptrbeyote
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiatr5y2qhqkqc7xtllwagk66wfnmbvdjmokb6ptlrhczzwwn76fce
- valory/market_manager_abci:0.1.0:bafybeiai6djelf6d4dkxgkv46l24q2gz7736b3jdhbxslvcydpvnvrse6e
- valory/decision_maker_abci:0.1.0:bafybeieaenzaucsz7234gynswn7f2ufsvhkhbniuc4mhh3kvu7atvdjqwu
- valory/trader_abci:0.1.0:bafybeidqh5nmjg6jk5hwqzf3abvjd4jiabs6eroisw5nh6d557isorxely
- valory/staking_abci:0.1.0:bafybeiduborfqevheegy3plk7bzhkl4fukwixvlb57tenijdepintubbdi
- valory/check_stop_trading_abci:0.1.0:bafybeiepylk35n3faurvp7dskjkdovehftzfjrjxfkpekzuaovt5gojxne
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeieyzzoo7kg7nyoa35ezykbkecipvzf6as63zwdvvem2m2zbgj3vme
- valory/market_manager_abci:0.1.0:bafybeid5ne5o75g4lipoagsaw4elo63tlukn6litdghcygtcuxjvqoehq4
- valory/decision_maker_abci:0.1.0:bafybeigrg3qrekuvqqegizifj3l323hemqtxd5i2jfw6blprsa4iyt75ha
- valory/trader_abci:0.1.0:bafybeibp6qumpdewwsxl7crt4mahlbq72fn5ji52bnujz6khc2zkiiqtwy
- valory/staking_abci:0.1.0:bafybeicdmf7eqgnf7dyaau4jhvmsje7ueehiq5bhlekzslikntl5zomxmu
- valory/check_stop_trading_abci:0.1.0:bafybeif6my6vcflbdki7okfhpote3szyywqi7ns5mb72j53vsy5k3pqlpy
- valory/mech_interact_abci:0.1.0:bafybeih2cck5xu6yaibomwtm5zbcp6llghr3ighdnk56fzwu3ihu5xx35e
customs:
- valory/mike_strat:0.1.0:bafybeihjiol7f4ch4piwfikurdtfwzsh6qydkbsztpbwbwb2yrqdqf726m
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/services/trader/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq
fingerprint_ignore_patterns: []
agent: valory/trader:0.1.0:bafybeifinxnuxu4ye2catrgrma7uyqm3f2hlurs4xsch27xftfo6im5ihm
agent: valory/trader:0.1.0:bafybeiaxqyyyttr7uky44nfkovpbbalvulrzaryppishcmb6tvqpl63ob4
number_of_agents: 4
deployment:
agent:
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/services/trader_pearl/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeibg7bdqpioh4lmvknw3ygnllfku32oca4eq5pqtvdrdsgw6buko7e
fingerprint_ignore_patterns: []
agent: valory/trader:0.1.0:bafybeifinxnuxu4ye2catrgrma7uyqm3f2hlurs4xsch27xftfo6im5ihm
agent: valory/trader:0.1.0:bafybeiaxqyyyttr7uky44nfkovpbbalvulrzaryppishcmb6tvqpl63ob4
number_of_agents: 1
deployment:
agent:
Expand Down
3 changes: 2 additions & 1 deletion packages/valory/skills/check_stop_trading_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fingerprint:
rounds.py: bafybeigqkzikghmzjj2ceqrnvmiiagtris3livgvn6r5z5ossk73xcfqfy
tests/__init__.py: bafybeihv2cjk4va5bc5ncqtppqg2xmmxcro34bma36trtvk32gtmhdycxu
tests/test_handlers.py: bafybeigpmtx2hyunzn6nxk2x4bvvybek7jvuhbk34fqlj7fgfsszcoqhxy
tests/test_models.py: bafybeiadfcrmmfpoyxdlds7l5pnvrxvimwrzbkefnbxj6sppuih7uaq564
tests/test_payloads.py: bafybeih7q7kdfxsf4ejxxqwjumwglfwwcrbqcjnuy42mkhnfwccxuhiviy
fingerprint_ignore_patterns: []
connections: []
Expand All @@ -25,7 +26,7 @@ contracts:
protocols: []
skills:
- valory/abstract_round_abci:0.1.0:bafybeiar2yhzxacfe3qqamqhaihtlcimquwedffctw55sowx6rac3cm3ui
- valory/staking_abci:0.1.0:bafybeiduborfqevheegy3plk7bzhkl4fukwixvlb57tenijdepintubbdi
- valory/staking_abci:0.1.0:bafybeicdmf7eqgnf7dyaau4jhvmsje7ueehiq5bhlekzslikntl5zomxmu
behaviours:
main:
args: {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2023-2024 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------------

"""Test the models.py module of the CheckStopTrading skill."""

from packages.valory.skills.abstract_round_abci.test_tools.base import DummyContext
from packages.valory.skills.abstract_round_abci.tests.test_models import (
BASE_DUMMY_PARAMS,
)
from packages.valory.skills.check_stop_trading_abci.models import (
CheckStopTradingParams,
SharedState,
)


class TestCheckStopTradingParams:
"""Test CheckStopTradingParams of CheckStopTrading."""

def test_initialization(self) -> None:
"""Test initialization."""

CheckStopTradingParams(
disable_trading=True,
stop_trading_if_staking_kpi_met=True,
staking_contract_address="",
staking_interaction_sleep_time=1,
mech_activity_checker_contract="",
**BASE_DUMMY_PARAMS,
)


class TestSharedState:
"""Test SharedState of CheckStopTrading."""

def test_initialization(self) -> None:
"""Test initialization."""
SharedState(name="", skill_context=DummyContext())
6 changes: 5 additions & 1 deletion packages/valory/skills/decision_maker_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ fingerprint:
tests/behaviours/dummy_strategy/dummy_strategy.py: bafybeig5e3xfr7gxsakfj4stbxqcwdiljl7klvgahkuwe3obzxgkg3qt2e
tests/behaviours/test_base.py: bafybeif6pglmr7pvojylatfzaxtlk65igx6a2omyrbxfihnnft6o7p75p4
tests/conftest.py: bafybeidy5hw56kw5mxudnfbhvogofn6k4rqb4ux2bd45baedrrhmgyrude
tests/io_/__init__.py: bafybeicjlliuugqissa5vxqubqtkq4veyt5ksmqsgilc7zge3uvjkb5vbe
tests/test_handlers.py: bafybeihpkgtjjm3uegpup6zkznpoaxqpu6kmp3ujiggrzbe73p5fzlq7im
tests/test_loader.py: bafybeighetz2cls333d5xci2pdai4i7r5kyu7nr5mpajpddls6klos6yc4
tests/test_models.py: bafybeibnc46fj5e4clf2ox2jtq3tgpbfknkh3cqo5o6hyrwkrw2r7l4jv4
tests/test_payloads.py: bafybeigsftkoc7ursy7okfznbwfiy3pk2kitndfgbn35ebbz4yoptkw3zy
tests/test_redeem_info.py: bafybeihigyydjtvldajuoqalnxxas6qpjbju4o4swiu2wmdwsigt2wyu2m
utils/__init__.py: bafybeiazrfg3kwfdl5q45azwz6b6mobqxngxpf4hazmrnkhinpk4qhbbf4
utils/nevermined.py: bafybeigallaqxhqopznhjhefr6bukh4ojkz5vdtqyzod5dksshrf24fjgi
utils/scaling.py: bafybeialr3z4zogp4k3l2bzcjfi4igvxzjexmlpgze2bai2ufc3plaow4y
Expand All @@ -85,7 +89,7 @@ protocols:
- valory/http:1.0.0:bafybeifugzl63kfdmwrxwphrnrhj7bn6iruxieme3a4ntzejf6kmtuwmae
skills:
- valory/abstract_round_abci:0.1.0:bafybeiar2yhzxacfe3qqamqhaihtlcimquwedffctw55sowx6rac3cm3ui
- valory/market_manager_abci:0.1.0:bafybeiai6djelf6d4dkxgkv46l24q2gz7736b3jdhbxslvcydpvnvrse6e
- valory/market_manager_abci:0.1.0:bafybeid5ne5o75g4lipoagsaw4elo63tlukn6litdghcygtcuxjvqoehq4
- valory/transaction_settlement_abci:0.1.0:bafybeic3tccdjypuge2lewtlgprwkbb53lhgsgn7oiwzyrcrrptrbeyote
- valory/mech_interact_abci:0.1.0:bafybeih2cck5xu6yaibomwtm5zbcp6llghr3ighdnk56fzwu3ihu5xx35e
behaviours:
Expand Down
20 changes: 20 additions & 0 deletions packages/valory/skills/decision_maker_abci/tests/io_/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2024 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------------

"""Tests for _io pakage of decision_maker skill."""
95 changes: 95 additions & 0 deletions packages/valory/skills/decision_maker_abci/tests/test_loader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2024 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------------
"""This module contains the tests for the loader for the decision maker abci."""

from dataclasses import dataclass
from typing import Any, Dict, Optional

import pytest

from packages.valory.skills.decision_maker_abci.io_.loader import ComponentPackageLoader


@dataclass
class LoaderTestCase:
"""Test case for Loader."""

name: str
serialized_objects: Dict
error: Optional[Any]


class TestComponentPackageLoader:
"""Test ComponentPackageLoader."""

@pytest.mark.parametrize(
"test_case",
[
LoaderTestCase(
name="happy path",
serialized_objects={
"component.yaml": """
entry_point: entry_point.py
callable: dummy_callable
""",
"entry_point.py": "dummy_function()",
},
error=None,
),
LoaderTestCase(
name="missing component.yaml",
serialized_objects={"entry_point.py": "dummy_function()"},
error="Invalid component package. The package MUST contain a component.yaml.",
),
LoaderTestCase(
name="missing entry_point",
serialized_objects={
"component.yaml": """
not_entry_point: none
""",
"entry_point.py": "dummy_function()",
},
error="Invalid component package. The component.yaml file MUST contain the 'entry_point' and 'callable' keys.",
),
LoaderTestCase(
name="happy path",
serialized_objects={
"component.yaml": """
entry_point: entry_point.py
callable: dummy_callable
""",
},
error="Invalid component package. entry_point.py is not present in the component package.",
),
],
)
def test_load(self, test_case: LoaderTestCase) -> None:
"""Test load."""

if test_case.error:
with pytest.raises(ValueError, match=test_case.error):
ComponentPackageLoader.load(test_case.serialized_objects)
else:
loader = ComponentPackageLoader.load(test_case.serialized_objects)

assert loader == (
{"entry_point": "entry_point.py", "callable": "dummy_callable"},
"dummy_function()",
"dummy_callable",
)
Comment on lines +91 to +95
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, introduce this as an attribute above, e.g., expected_loader, instead of hardcoding here.

Loading
Loading