Skip to content

Commit

Permalink
check runs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravleen-Solulab committed Oct 15, 2024
1 parent e7f700d commit a351372
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@

import pytest

from packages.valory.skills.decision_maker_abci.policy import EGreedyPolicy
from packages.valory.skills.decision_maker_abci.policy import (
AccuracyInfo,
EGreedyPolicy,
)
from packages.valory.skills.decision_maker_abci.states.base import (
Event,
SynchronizedData,
TxPreparationRound,
)
from packages.valory.skills.market_manager_abci.rounds import (
SynchronizedData as MarketManagerSyncedData,
)
from packages.valory.skills.mech_interact_abci.states.base import MechMetadata


Expand Down Expand Up @@ -193,15 +193,17 @@ def test_mech_requests(sync_data, mocked_db):

def test_weighted_accuracy(sync_data, mocked_db):
"""Test the weighted_accuracy property."""
mocked_db.get_strict.return_value = json.dumps(
{"epsilon": 0.1, "weighted_accuracy": {"tool1": 0.8}}
selected_mech_tool = "tool1"
policy_db_name = "policy"
policy_mock = EGreedyPolicy(
eps=0.1, accuracy_store={selected_mech_tool: AccuracyInfo(requests=1)}
).serialize()
mocked_db.get_strict = lambda name: (
policy_mock if name == policy_db_name else selected_mech_tool
)
mocked_db.get.return_value = "tool1"
sync_data._policy = None # Reset cached value
policy = EGreedyPolicy.deserialize(mocked_db.get_strict.return_value)

# Access the weighted accuracy correctly
assert sync_data.weighted_accuracy == policy.weighted_accuracy["tool1"]
policy = EGreedyPolicy.deserialize(policy_mock)
assert selected_mech_tool in policy.weighted_accuracy
assert sync_data.weighted_accuracy == policy.weighted_accuracy[selected_mech_tool]


def test_end_block(mocked_db):
Expand All @@ -223,4 +225,4 @@ def test_end_block(mocked_db):
TxPreparationRound, "end_block", return_value=(mocked_sync_data, Event.NONE)
):
result = round_instance.end_block()
assert result == (mocked_sync_data, Event.NONE)
assert result == (mocked_sync_data, Event.NONE)
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from typing import Any, Callable, Dict, FrozenSet, Hashable, List, Mapping, Optional
from unittest import mock


import pytest

from packages.valory.skills.abstract_round_abci.base import BaseTxPayload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"""This package contains the tests for Decision Maker"""

import json
from typing import Any, Callable, Dict, FrozenSet, List, Mapping, Type
from typing import Any, Callable, Dict, FrozenSet, Type
from unittest.mock import MagicMock

import pytest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@

# Dummy values for testing
class MockSynchronizedData(BaseSynchronizedData):
"""The class for testing """
"""The class for testing"""

def __init__(self, db):
"""Mock"""
super().__init__(db=db)
self.agreement_id = "dummy_agreement_id"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self):

class TestRandomnessRound:
"""The class for testing Randomness Round"""

@pytest.fixture
def setup_randomness_round(self):
"""Fixture to set up a RandomnessRound instance."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(self):

class TestSamplingRound:
"""The class for testing Sampling Round"""

@pytest.fixture
def setup_sampling_round(self):
"""Fixture to set up a SamplingRound instance."""
Expand Down

0 comments on commit a351372

Please sign in to comment.