-
Notifications
You must be signed in to change notification settings - Fork 19
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
annasambrook
wants to merge
14
commits into
develop
Choose a base branch
from
test/models
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Test/models #317
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ccbb6fc
test: check stop trading models tests
annasambrook ce19b0e
test: test_loader
annasambrook 2961948
test: test_loader completed
annasambrook 43a8e4e
test: models added
annasambrook c1d63a5
Merge branch 'refs/heads/main' into test/models
annasambrook 7546df8
chore: generators
annasambrook 63e2724
Merge branch 'refs/heads/test/test' into test/models
annasambrook 6313a07
add models tests
annasambrook 071de1e
code checks fixes and generators
annasambrook 7d3d66c
revert models changes
annasambrook 5ea7238
generators
annasambrook 460a6e1
generators
annasambrook 28825af
reformatting and generators
annasambrook bc93c24
lock packages
annasambrook File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
53 changes: 53 additions & 0 deletions
53
packages/valory/skills/check_stop_trading_abci/tests/test_models.py
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,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()) |
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
20 changes: 20 additions & 0 deletions
20
packages/valory/skills/decision_maker_abci/tests/io_/__init__.py
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,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
95
packages/valory/skills/decision_maker_abci/tests/test_loader.py
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,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", | ||
) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.