-
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 script for check_stop_trading_abci #308
Closed
Ravleen-Solulab
wants to merge
12
commits into
valory-xyz:main
from
Ravleen-Solulab:Test-scripts-check_stop_trading_abci
Closed
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
25a954e
test script for check_stop_trading_abci
Ravleen-Solulab f065bbe
test scripts for rounds and dialogues
Ravleen-Solulab e23a7d6
test scripts for rounds and dialogues for decision_maker_abci
Ravleen-Solulab 7053bba
changes in test_rounds
Ravleen-Solulab 6f91626
changes in test_rounds
Ravleen-Solulab 43e4321
changes in test_rounds
Ravleen-Solulab 3673e67
fixed test_round of check_stop_trading_abci
Ravleen-Solulab 27a9009
changes in test_round of market_manager_abci
Ravleen-Solulab 14ffdc6
changes in test_round of market_manager_abci
Ravleen-Solulab 3fc2e46
test_rounds of check_stop_trading_abci
Ravleen-Solulab fcf65ae
fixes:copyright
Ravleen-Solulab 031f776
fixes:copyright
Ravleen-Solulab 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
28 changes: 28 additions & 0 deletions
28
packages/valory/skills/check_stop_trading_abci/tests/test_dialogues.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,28 @@ | ||
# -*- coding: utf-8 -*- | ||
# ------------------------------------------------------------------------------ | ||
# | ||
# Copyright 2021-2022 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 dialogues.py module of the skill.""" | ||
|
||
# pylint: skip-file | ||
|
||
import packages.valory.skills.check_stop_trading_abci.dialogues # noqa | ||
|
||
|
||
def test_import() -> None: | ||
"""Test that the 'dialogues.py' Python module can be imported.""" |
134 changes: 134 additions & 0 deletions
134
packages/valory/skills/check_stop_trading_abci/tests/test_rounds.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,134 @@ | ||
# -*- 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 check stop trading ABCI application.""" | ||
|
||
import pytest | ||
import logging # noqa: F401 | ||
from unittest.mock import MagicMock | ||
from typing import Set | ||
from packages.valory.skills.abstract_round_abci.base import ( | ||
AbciApp, | ||
AbciAppTransitionFunction, | ||
AbstractRound, | ||
AppState, | ||
BaseSynchronizedData, | ||
CollectionRound, | ||
DegenerateRound, | ||
DeserializedCollection, | ||
VotingRound, | ||
get_name, | ||
) | ||
|
||
from packages.valory.skills.check_stop_trading_abci.rounds import ( | ||
CheckStopTradingRound, | ||
Event, | ||
FinishedCheckStopTradingRound, | ||
FinishedWithSkipTradingRound, | ||
SynchronizedData, | ||
CheckStopTradingAbciApp | ||
) | ||
|
||
|
||
from packages.valory.skills.check_stop_trading_abci.payloads import ( | ||
CheckStopTradingPayload, | ||
) | ||
|
||
@pytest.fixture | ||
def synchronized_data(): | ||
"""Get the synchronized data""" | ||
return SynchronizedData(db=dict()) | ||
|
||
|
||
@pytest.fixture | ||
def abci_app(): | ||
"""Fixture to get the ABCI app with necessary parameters.""" | ||
# Create mocks for the required parameters | ||
synchronized_data = MagicMock() | ||
logger = MagicMock() | ||
context = MagicMock() | ||
|
||
# Instantiate CheckStopTradingAbciApp with mocked parameters | ||
return CheckStopTradingAbciApp(synchronized_data=synchronized_data, logger=logger, context=context) | ||
|
||
|
||
|
||
def test_check_stop_trading_round_initialization(synchronized_data): | ||
"""Test the initialization of CheckStopTradingRound.""" | ||
round_ = CheckStopTradingRound( | ||
synchronized_data=synchronized_data, context=MagicMock() | ||
) | ||
assert round_.payload_class is CheckStopTradingPayload | ||
assert round_.synchronized_data_class is SynchronizedData | ||
assert round_.done_event == Event.SKIP_TRADING | ||
assert round_.negative_event == Event.DONE | ||
assert round_.none_event == Event.NONE | ||
assert round_.no_majority_event == Event.NO_MAJORITY | ||
assert round_.collection_key == "participant_to_votes" | ||
|
||
|
||
def test_finished_check_stop_trading_round_initialization(): | ||
"""Test the initialization of FinishedCheckStopTradingRound.""" | ||
round_ = FinishedCheckStopTradingRound( | ||
synchronized_data=MagicMock(), context=MagicMock() | ||
) | ||
assert isinstance(round_, FinishedCheckStopTradingRound) | ||
|
||
|
||
def test_finished_with_skip_trading_round_initialization(): | ||
"""Test the initialization of FinishedWithSkipTradingRound.""" | ||
round_ = FinishedWithSkipTradingRound( | ||
synchronized_data=MagicMock(), context=MagicMock() | ||
) | ||
assert isinstance(round_, FinishedWithSkipTradingRound) | ||
|
||
|
||
def test_abci_app_initialization(abci_app): | ||
"""Test the initialization of CheckStopTradingAbciApp.""" | ||
assert abci_app.initial_round_cls is CheckStopTradingRound | ||
assert abci_app.final_states == { | ||
FinishedCheckStopTradingRound, | ||
FinishedWithSkipTradingRound, | ||
} | ||
assert abci_app.transition_function == { | ||
CheckStopTradingRound: { | ||
Event.DONE: FinishedCheckStopTradingRound, | ||
Event.NONE: CheckStopTradingRound, | ||
Event.ROUND_TIMEOUT: CheckStopTradingRound, | ||
Event.NO_MAJORITY: CheckStopTradingRound, | ||
Event.SKIP_TRADING: FinishedWithSkipTradingRound, | ||
}, | ||
FinishedCheckStopTradingRound: {}, | ||
FinishedWithSkipTradingRound: {}, | ||
} | ||
assert abci_app.event_to_timeout == { | ||
Event.ROUND_TIMEOUT: 30.0, | ||
} | ||
assert abci_app.db_pre_conditions == {CheckStopTradingRound: set()} | ||
assert abci_app.db_post_conditions == { | ||
FinishedCheckStopTradingRound: set(), | ||
FinishedWithSkipTradingRound: set(), | ||
} | ||
def test_synchronized_data_initialization(): | ||
"""Test the initialization and attributes of SynchronizedData.""" | ||
# Initialize SynchronizedData | ||
data = SynchronizedData(db=dict()) | ||
|
||
# Test initial attributes | ||
assert data.db == {} |
28 changes: 28 additions & 0 deletions
28
packages/valory/skills/decision_maker_abci/tests/test_dialogues.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,28 @@ | ||
# -*- coding: utf-8 -*- | ||
# ------------------------------------------------------------------------------ | ||
# | ||
# Copyright 2021-2022 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 dialogues.py module of the skill.""" | ||
|
||
# pylint: skip-file | ||
|
||
import packages.valory.skills.decision_maker_abci.dialogues # noqa | ||
|
||
|
||
def test_import() -> None: | ||
"""Test that the 'dialogues.py' Python module can be imported.""" |
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.
These tests should also check whether we can run the rounds and that for every potential execution branch we get the expected data and event. Check this for some inspiration: https://github.com/valory-xyz/IEKit/blob/main/packages/valory/skills/dynamic_nft_abci/tests/test_rounds.py#L125