From 559ec334eda6f45fcb9e2f9b38f1937b16e5fda6 Mon Sep 17 00:00:00 2001 From: Martin Stancsics Date: Fri, 19 Apr 2024 15:42:58 +0200 Subject: [PATCH] Make tests nicer --- live_bargaining/tests.py | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/live_bargaining/tests.py b/live_bargaining/tests.py index 03980db..b86931b 100644 --- a/live_bargaining/tests.py +++ b/live_bargaining/tests.py @@ -197,27 +197,21 @@ def play_round(self): yield Submission(Bargain, timeout_happened=True, check_html=False) num_real_rounds = 4 - - if self.round_number == 1: - expect(self.player.payoff, c(0)) - - if self.round_number == 2: - if self.player.id_in_group == 1: - expect(self.player.payoff, c(50 / num_real_rounds)) - else: - expect(self.player.payoff, c(25 / num_real_rounds)) - - if self.round_number == 3: - expect(self.player.payoff, c(0)) - - if self.round_number == 4: - if self.player.id_in_group in [1, 2]: - expect(self.player.payoff, c(5 / num_real_rounds)) - else: - expect(self.player.payoff, c(0)) - - if self.round_number == 5: - expect(self.player.payoff, c(0)) + expected_payoffs = { + 1: [0, 0, 0], + 2: [50, 25, 25], + 3: [0, 0, 0], + 4: [5, 5, 0], + 5: [0, 0, 0], + } + + expect( + self.player.payoff, + c( + expected_payoffs[self.round_number][self.player.id_in_group - 1] + / num_real_rounds + ), + ) print(f"Player {self.player.id_in_group} received payoff: {self.player.payoff}")