Skip to content

Commit

Permalink
fixes:methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravleen-Solulab committed Aug 27, 2024
1 parent dc7990a commit 27f79f9
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions packages/valory/skills/check_stop_trading_abci/tests/test_rounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,51 +137,51 @@ class BaseCheckStopTradingRoundTest(BaseVotingRoundTest):
test_class: Type[VotingRound]
test_payload: Type[CheckStopTradingPayload]

def test_positive_votes(self) -> None:
"""Test ValidateRound."""
def _test_voting_round(
self,
vote: bool,
expected_event: Any,
threshold_check: Callable
) -> None:
"""Helper method to test voting rounds with positive or negative votes."""

test_round = self.test_class(
synchronized_data=self.synchronized_data, context=MagicMock()
)
)

self._complete_run(
self._test_voting_round_positive(
self._test_round(
test_round=test_round,
round_payloads=get_participant_to_votes(self.participants, vote=True),
round_payloads=get_participant_to_votes(self.participants, vote=vote),
synchronized_data_update_fn=lambda _synchronized_data, _: _synchronized_data.update(
participant_to_votes=get_participant_to_votes_serialized(
self.participants, vote=True
self.participants, vote=vote
)
),
synchronized_data_attr_checks=[
lambda _synchronized_data: _synchronized_data.participant_to_votes.keys()
],
exit_event=self._event_class.SKIP_TRADING,
] if vote else [],
exit_event=expected_event,
threshold_check=threshold_check
)
)

def test_negative_votes(self) -> None:
"""Test ValidateRound."""

test_round = self.test_class(
synchronized_data=self.synchronized_data, context=MagicMock()
def test_positive_votes(self) -> None:
"""Test ValidateRound for positive votes."""
self._test_voting_round(
vote=True,
expected_event=self._event_class.SKIP_TRADING,
threshold_check=lambda x: x.positive_vote_threshold_reached
)

self._complete_run(
self._test_voting_round_negative(
test_round=test_round,
round_payloads=get_participant_to_votes(self.participants, vote=False),
synchronized_data_update_fn=lambda _synchronized_data, _: _synchronized_data.update(
participant_to_votes=get_participant_to_votes_serialized(
self.participants, vote=False
)
),
synchronized_data_attr_checks=[],
exit_event=self._event_class.DONE,
)
def test_negative_votes(self) -> None:
"""Test ValidateRound for negative votes."""
self._test_voting_round(
vote=False,
expected_event=self._event_class.DONE,
threshold_check=lambda x: x.negative_vote_threshold_reached
)


class TestCheckStopTradingRound(BaseCheckStopTradingRoundTest):
"""Tests for CheckStopTradingRound."""

Expand Down

0 comments on commit 27f79f9

Please sign in to comment.