def test_table_type(self): hand = get_hands_in_list(TEST_RANDOM_HAND_HISTORIES_FOLDER, [ "HH20210122 SITGOID-G23889488T1 TN-$3 Hold'Em Turbo - On Demand GAMETYPE-Hold'em LIMIT-no CUR-REAL OND-T BUYIN-0.txt" ]) hand = hand[0] # convert list of length 1 to str hand = hand.replace("'", '"') expected_table_type = '9-max' self.assertEqual(table_type(hand), expected_table_type)
def test_tournament_id(self): hands = get_hands_in_list(TEST_RANDOM_HAND_HISTORIES_FOLDER, [ "HH20201217 SITGOID-G23140753T3 TN-$0{FULLSTOP}50 Hold'Em Turbo - On Demand GAMETYPE-Hold'em LIMIT-no CUR-REAL OND-T BUYIN-0.txt" ]) expected_tournament_id = [ 23140753, 23140753, 23140753, 23140753, 23140753, 23140753, 23140753, 23140753, 23140753, 23140753, 23140753 ] for idx, h in enumerate(hands): self.assertEqual(tournament_id(h), expected_tournament_id[idx])
def test_nb_occupied_seats(self): hands = get_hands_in_list(TEST_RANDOM_HAND_HISTORIES_FOLDER, ["HH20210122 SITGOID-G23889488T1 TN-$3 Hold'Em Turbo - On Demand GAMETYPE-Hold'em LIMIT-no CUR-REAL OND-T BUYIN-0.txt"]) expected_my_cards = [ 7, 7, 7, 8, 9, 9, 5 ] for idx, h in enumerate(hands): self.assertEqual(nb_occupied_seats(h), expected_my_cards[idx])
def test_level(self): # open up all hands and have them in a list hands = get_hands_in_list(TEST_RANDOM_HAND_HISTORIES_FOLDER, [ "HH20201217 SITGOID-G23140753T3 TN-$0{FULLSTOP}50 Hold'Em Turbo - On Demand GAMETYPE-Hold'em LIMIT-no CUR-REAL OND-T BUYIN-0.txt" ]) expected_levels = [ "6 (1250.00/2500.00)", "6 (1250.00/2500.00)", "7 (1500.00/3000.00)", "7 (1500.00/3000.00)", "7 (1500.00/3000.00)", "7 (1500.00/3000.00)", "7 (1500.00/3000.00)", "7 (1500.00/3000.00)", "7 (1500.00/3000.00)", "7 (1500.00/3000.00)", "7 (1500.00/3000.00)" ] for idx, h in enumerate(hands): self.assertEqual(level(h), expected_levels[idx])
def test_time(self): hands = get_hands_in_list(TEST_RANDOM_HAND_HISTORIES_FOLDER, [ "HH20201217 SITGOID-G23140753T3 TN-$0{FULLSTOP}50 Hold'Em Turbo - On Demand GAMETYPE-Hold'em LIMIT-no CUR-REAL OND-T BUYIN-0.txt" ]) expected_time = [ "2020/12/17 22:17:35 UTC", "2020/12/17 22:19:14 UTC", "2020/12/17 22:19:55 UTC", "2020/12/17 22:20:12 UTC", "2020/12/17 22:20:37 UTC", "2020/12/17 22:21:21 UTC", "2020/12/17 22:21:36 UTC", "2020/12/17 22:22:29 UTC", "2020/12/17 22:22:51 UTC", "2020/12/17 22:23:08 UTC", "2020/12/17 22:23:47 UTC" ] for idx, h in enumerate(hands): # print('"' + time(h) + '",') self.assertEqual(time(h), expected_time[idx])
def test_side_pot_n_size_bb(self): hands = get_hands_in_list(TEST_HH_FOR_SIDE_POTS_FOLDER, [ "HH20210112 SITGOID-G99999999T3 TN-$1{FULLSTOP}50 Hold'Em Turbo - On Demand GAMETYPE-Hold'em LIMIT-no CUR-REAL OND-T BUYIN-0 ---- for side pot.txt" ]) expected_side_pot_1_size_bb = [0, 1.59, 2.05, 1.93, 5.83] expected_side_pot_2_size_bb = [0, 0, 0, 0, 8.13] expected_side_pot_3_size_bb = [0, 0, 0, 0, 1.67] for idx, h in enumerate(hands): self.assertEqual(side_pot_n_size_bb(h, n=1), expected_side_pot_1_size_bb[idx]) self.assertEqual(side_pot_n_size_bb(h, n=2), expected_side_pot_2_size_bb[idx]) self.assertEqual(side_pot_n_size_bb(h, n=3), expected_side_pot_3_size_bb[idx])
def test_level(self): hands = get_hands_in_list(TEST_RANDOM_HAND_HISTORIES_FOLDER, ["HH20201217 SITGOID-G23140753T3 TN-$0{FULLSTOP}50 Hold'Em Turbo - On Demand GAMETYPE-Hold'em LIMIT-no CUR-REAL OND-T BUYIN-0.txt"]) expected_main_pot_winner = [ "bacchus5555", "WBRoy", "PotNoodle99912", "OffMyMedz", "PotNoodle99912", "PotNoodle99912", "Burn Card", "WBRoy", "bacchus5555", "WBRoy", "OffMyMedz", ] for idx, h in enumerate(hands): self.assertEqual(main_pot_winner(h), expected_main_pot_winner[idx])
def test_board_cards(self): hands = get_hands_in_list(TEST_RANDOM_HAND_HISTORIES_FOLDER, ["HH20201217 SITGOID-G23140753T3 TN-$0{FULLSTOP}50 Hold'Em Turbo - On Demand GAMETYPE-Hold'em LIMIT-no CUR-REAL OND-T BUYIN-0.txt"]) expected_board_cards = [ "Jd 5h 6d 3h Kh", "4s 5h 4d Qd 6h", "no-board", "Th 5c Kc", "8h 2h 4s 2s Kc", "no-board", "5d Kd Ad", "no-board", "no-board", "Ad 2s 6h Qc 9s", "4s Jh 9s Kh Td" ] for idx, h in enumerate(hands): self.assertEqual(board_cards(h), expected_board_cards[idx])
def test_side_pot_n_winner(self): hands = get_hands_in_list(TEST_HH_FOR_SIDE_POTS_FOLDER, [ "HH20210112 SITGOID-G99999999T3 TN-$1{FULLSTOP}50 Hold'Em Turbo - On Demand GAMETYPE-Hold'em LIMIT-no CUR-REAL OND-T BUYIN-0 ---- for side pot.txt" ]) expected_side_pot_1_winner = [ None, "Bubbazinitty", "slbetters", "GABI22", "Diamond JJ" ] expected_side_pot_2_winner = [None, None, None, None, "Diamond JJ"] expected_side_pot_3_winner = [None, None, None, None, "drail0073"] for idx, h in enumerate(hands): self.assertEqual(side_pot_n_winner(h, n=1), expected_side_pot_1_winner[idx]) self.assertEqual(side_pot_n_winner(h, n=2), expected_side_pot_2_winner[idx]) self.assertEqual(side_pot_n_winner(h, n=3), expected_side_pot_3_winner[idx])
def test_level(self): hands = get_hands_in_list(TEST_RANDOM_HAND_HISTORIES_FOLDER, [ "HH20201217 SITGOID-G23140753T3 TN-$0{FULLSTOP}50 Hold'Em Turbo - On Demand GAMETYPE-Hold'em LIMIT-no CUR-REAL OND-T BUYIN-0.txt" ]) expected_pot_size_bb = [ 24.6, 22.8, 3.1, 3.1, 2.6, 2.6, 3.1, 3.1, 8.1, 31.7, 22.17, ] for idx, h in enumerate(hands): self.assertEqual(main_pot_size_bb(h), expected_pot_size_bb[idx])
def test_my_cards(self): hands = get_hands_in_list(TEST_RANDOM_HAND_HISTORIES_FOLDER, [ "HH20201217 SITGOID-G23140753T3 TN-$0{FULLSTOP}50 Hold'Em Turbo - On Demand GAMETYPE-Hold'em LIMIT-no CUR-REAL OND-T BUYIN-0.txt" ]) expected_my_cards = [ "4s Qs", "7d Js", "8c 8h", "6h 9s", "Qd Td", "8d 7d", "6c Tc", "6h Kh", "Th Kd", "Qh 7s", "8d Js", ] for idx, h in enumerate(hands): self.assertEqual(my_cards(h), expected_my_cards[idx])
def test_starting_stack_size_bb(self): hands = get_hands_in_list(TEST_RANDOM_HAND_HISTORIES_FOLDER, [ "HH20201217 SITGOID-G23140753T3 TN-$0{FULLSTOP}50 Hold'Em Turbo - On Demand GAMETYPE-Hold'em LIMIT-no CUR-REAL OND-T BUYIN-0.txt" ]) expected_starting_stack_size_bb = [ 7.3, 7.2, 5.9, 7.9, 7.8, 9.3, 10.8, 10.7, 10.6, 10.5, 10.4, ] for idx, h in enumerate(hands): # print(str(starting_stack_size_bb(h)) + ',') self.assertEqual(starting_stack_size_bb(h), expected_starting_stack_size_bb[idx])
def test_get_id(self): # open up all hands and have them in a list hands = get_hands_in_list(TEST_RANDOM_HAND_HISTORIES_FOLDER, [ "HH20201217 SITGOID-G23140753T3 TN-$0{FULLSTOP}50 Hold'Em Turbo - On Demand GAMETYPE-Hold'em LIMIT-no CUR-REAL OND-T BUYIN-0.txt" ]) expected_ids = [ 627325357, 627327620, 627328481, 627328893, 627329469, 627330445, 627330797, 627331964, 627332459, 627332818, 627333718, ] for idx, h in enumerate(hands): self.assertEqual(get_id(h), expected_ids[idx])
def test_Hand(self): hands = get_hands_in_list(TEST_RANDOM_HAND_HISTORIES_FOLDER, [ "HH20201217 SITGOID-G23140753T3 TN-$0{FULLSTOP}50\xa0Hold'Em Turbo - On Demand GAMETYPE-Hold'em LIMIT-no CUR-REAL OND-T BUYIN-0.txt" ]) hand = hands[0] myH = Hand(hand_txt=hand) myH.build_hand() expected_attributes = [ "board_cards", "build_hand", "hand_txt", "id", "level", "main_pot_size_bb", "main_pot_winner", "my_cards", "nb_occupied_seats", "side_pot_1_size_bb", "side_pot_1_winner", "side_pot_2_size_bb", "side_pot_2_winner", "side_pot_3_size_bb", "side_pot_3_winner", "starting_stack_size_bb", "time", "tournament_id", "table_type", 'BTN_player_name', 'SB_player_name', 'BB_player_name', 'UTG_player_name', 'UTGp1_player_name', 'MP_player_name', 'MPp1_player_name', 'MPp2_player_name', 'CO_player_name', 'BTN_stack', 'SB_stack', 'BB_stack', 'UTG_stack', 'UTGp1_stack', 'MP_stack', 'MPp1_stack', 'MPp2_stack', 'CO_stack', 'BTN_cards', 'SB_cards', 'BB_cards', 'UTG_cards', 'UTGp1_cards', 'MP_cards', 'MPp1_cards', 'MPp2_cards', 'CO_cards' ] all_attributes = [] for attribute in dir(myH): if attribute[0] is not '_': all_attributes.append(attribute) self.assertCountEqual(all_attributes, expected_attributes) self.assertEqual(myH.time, '2020/12/17 22:17:35 UTC') self.assertEqual(myH.level, '6 (1250.00/2500.00)') self.assertEqual(myH.my_cards, '4s Qs') self.assertEqual(myH.board_cards, 'Jd 5h 6d 3h Kh') self.assertEqual(myH.tournament_id, 23140753) self.assertEqual(myH.id, 627325357) self.assertEqual(myH.starting_stack_size_bb, 7.3) self.assertEqual(myH.main_pot_winner, 'bacchus5555') self.assertEqual(myH.side_pot_1_winner, None) self.assertEqual(myH.side_pot_2_winner, None) self.assertEqual(myH.side_pot_3_winner, None) self.assertEqual(myH.main_pot_size_bb, 24.6) self.assertEqual(myH.side_pot_1_size_bb, 0) self.assertEqual(myH.side_pot_2_size_bb, 0) self.assertEqual(myH.side_pot_3_size_bb, 0) self.assertEqual(myH.nb_occupied_seats, 5) self.assertEqual(myH.table_type, '9-max') self.assertEqual(myH.BTN_player_name, 'PotNoodle99912') self.assertEqual(myH.SB_player_name, 'rldes') self.assertEqual(myH.BB_player_name, 'bacchus5555') self.assertEqual(myH.UTG_player_name, 'WBRoy') self.assertEqual(myH.UTGp1_player_name, None) self.assertEqual(myH.MP_player_name, None) self.assertEqual(myH.MPp1_player_name, None) self.assertEqual(myH.MPp2_player_name, None) self.assertEqual(myH.CO_player_name, 'Naruba80') self.assertEqual(myH.BTN_stack, 18150.0) self.assertEqual(myH.SB_stack, 20790.0) self.assertEqual(myH.BB_stack, 108315.0) self.assertEqual(myH.UTG_stack, 27000.0) self.assertEqual(myH.UTGp1_stack, None) self.assertEqual(myH.MP_stack, None) self.assertEqual(myH.MPp1_stack, None) self.assertEqual(myH.MPp2_stack, None) self.assertEqual(myH.CO_stack, 29750.0) self.assertEqual(myH.BTN_cards, '4s Qs') self.assertEqual(myH.SB_cards, None) self.assertEqual(myH.BB_cards, 'Js Ad') self.assertEqual(myH.UTG_cards, None) self.assertEqual(myH.UTGp1_cards, None) self.assertEqual(myH.MP_cards, None) self.assertEqual(myH.MPp1_cards, None) self.assertEqual(myH.MPp2_cards, None) self.assertEqual(myH.CO_cards, 'Ah Tc')