from pd.helpers import calculate_and_store_profit from settings import SESSION_CONFIG_DEFAULTS class DummySession: config = SESSION_CONFIG_DEFAULTS class DummyParticipant: def __init__(self, subs, sft, crt, raven, delay): self.nr_correct_answers_subtractions = subs self.sft_pay = sft self.crt_score = crt self.raven_selection = raven self.num_correct_words_delay = delay class DummyPlayer: def __init__(self, participant): self.participant = participant self.session = DummySession() def test_calculate_and_store_profit(): lowest_profit_part = DummyParticipant(0, 0, 0, False, 0) medium_profit_part = DummyParticipant(3, 2, 4, True, 7) highest_profit_part = DummyParticipant(5, 2, 7, True, 10) lowest_play = DummyPlayer(lowest_profit_part) medium_play = DummyPlayer(medium_profit_part) highers_play = DummyPlayer(highest_profit_part) for player in (lowest_play, medium_play, highers_play): calculate_and_store_profit(player) assert lowest_play.participant.payoff_performance == 0 assert lowest_play.payoff == 1 assert highers_play.participant.payoff_performance == 4.25 assert highers_play.payoff == 5.25 assert medium_play.participant.payoff_performance == 2.375 assert medium_play.payoff == 3.375