Skip to content

Commit

Permalink
fix random choice in test
Browse files Browse the repository at this point in the history
  • Loading branch information
rdnfn committed Oct 31, 2024
1 parent 120864f commit b4aadf7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/inverse_cai/algorithm/main_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
from unittest.mock import Mock, patch, MagicMock
import pandas as pd
import pathlib
from inverse_cai.experiment.config import ExpConfig
from inverse_cai.algorithm.main import run

Expand Down Expand Up @@ -188,10 +187,19 @@ def test_run_skip_voting(


@patch("inverse_cai.models.get_model")
def test_run_integration(mock_get_model, mock_feedback_df, mock_config, mock_save_path):
@patch("inverse_cai.algorithm.voting.random.choice") # Add mock for random.choice
def test_run_integration(
mock_random_choice, mock_get_model, mock_feedback_df, mock_config, mock_save_path
):
# Setup mock model with different responses for different calls
mock_model = Mock()

# Set random.choice to return False only when choosing between booleans
def random_choice_side_effect(seq):
return seq[0]

mock_random_choice.side_effect = random_choice_side_effect

def side_effect(messages):
message_text = str(messages)
if "Given the data above, why do you think" in message_text:
Expand Down

0 comments on commit b4aadf7

Please sign in to comment.