# Path: tests/base_unittest.py
# class BaseUnitTest(unittest.TestCase):
# 
#   def eq(self, expected, target):
#     return self.assertEqual(expected, target)
# 
#   def neq(self, expected, target):
#     return self.assertNotEqual(expected, target)
# 
#   def true(self, target):
#     return self.assertTrue(target)
# 
#   def false(self, target):
#     return self.assertFalse(target)
# 
# Path: pypokerengine/engine/dealer.py
# class MessageSummarizer(object):
# 
#     def __init__(self, verbose):
#         self.verbose = verbose
# 
#     def print_message(self, message):
#         print(message)
# 
#     def summarize_messages(self, raw_messages):
#         if self.verbose == 0: return
# 
#         summaries = [self.summarize(raw_message[1]) for raw_message in raw_messages]
#         summaries = [summary for summary in summaries if summary is not None]
#         summaries = list(OrderedDict.fromkeys(summaries))
#         for summary in summaries: self.print_message(summary)
# 
#     def summarize(self, message):
#         if self.verbose == 0: return None
# 
#         content = message["message"]
#         message_type = content["message_type"]
#         if MessageBuilder.GAME_START_MESSAGE == message_type:
#             return self.summarize_game_start(content)
#         if MessageBuilder.ROUND_START_MESSAGE == message_type:
#             return self.summarize_round_start(content)
#         if MessageBuilder.STREET_START_MESSAGE == message_type:
#             return self.summarize_street_start(content)
#         if MessageBuilder.GAME_UPDATE_MESSAGE == message_type:
#             return self.summarize_player_action(content)
#         if MessageBuilder.ROUND_RESULT_MESSAGE == message_type:
#             return self.summarize_round_result(content)
#         if MessageBuilder.GAME_RESULT_MESSAGE == message_type:
#             return self.summarize_game_result(content)
# 
#     def summarize_game_start(self, message):
#         base = "Started the game with player %s for %d round. (start stack=%s, small blind=%s)"
#         names = [player["name"] for player in message["game_information"]["seats"]]
#         rule = message["game_information"]["rule"]
#         return base % (names, rule["max_round"], rule["initial_stack"], rule["small_blind_amount"])
# 
#     def summarize_round_start(self, message):
#         base = "Started the round %d"
#         return base % message["round_count"]
# 
#     def summarize_street_start(self, message):
#         base = 'Street "%s" started. (community card = %s)'
#         return base % (message["street"], message["round_state"]["community_card"])
# 
#     def summarize_player_action(self, message):
#         base = '"%s" declared "%s:%s"'
#         players = message["round_state"]["seats"]
#         action = message["action"]
#         player_name = [player["name"] for player in players if player["uuid"] == action["player_uuid"]][0]
#         return base % (player_name, action["action"], action["amount"])
# 
#     def summarize_round_result(self, message):
#         base = '"%s" won the round %d (stack = %s)'
#         winners = [player["name"] for player in message["winners"]]
#         stack = { player["name"]:player["stack"] for player in message["round_state"]["seats"] }
#         return base % (winners, message["round_count"], stack)
# 
#     def summarize_game_result(self, message):
#         base = 'Game finished. (stack = %s)'
#         stack = { player["name"]:player["stack"] for player in message["game_information"]["seats"] }
#         return base % stack
# 
#     def summairze_blind_level_update(self, round_count, old_ante, new_ante, old_sb_amount, new_sb_amount):
#         base = 'Blind level update at round-%d : Ante %s -> %s, SmallBlind %s -> %s'
#         return base % (round_count, old_ante, new_ante, old_sb_amount, new_sb_amount)


import sys
    from StringIO import StringIO
    from io import StringIO
from tests.base_unittest import BaseUnitTest
from pypokerengine.engine.dealer import MessageSummarizer
try:
except ImportError:


class MessageSummarizerTest(BaseUnitTest):

    def setUp(self):

# Path: tests/base_unittest.py
# class BaseUnitTest(unittest.TestCase):
# 
#   def eq(self, expected, target):
#     return self.assertEqual(expected, target)
# 
#   def neq(self, expected, target):
#     return self.assertNotEqual(expected, target)
# 
#   def true(self, target):
#     return self.assertTrue(target)
# 
#   def false(self, target):
#     return self.assertFalse(target)
# 
# Path: pypokerengine/engine/dealer.py
# class MessageSummarizer(object):
# 
#     def __init__(self, verbose):
#         self.verbose = verbose
# 
#     def print_message(self, message):
#         print(message)
# 
#     def summarize_messages(self, raw_messages):
#         if self.verbose == 0: return
# 
#         summaries = [self.summarize(raw_message[1]) for raw_message in raw_messages]
#         summaries = [summary for summary in summaries if summary is not None]
#         summaries = list(OrderedDict.fromkeys(summaries))
#         for summary in summaries: self.print_message(summary)
# 
#     def summarize(self, message):
#         if self.verbose == 0: return None
# 
#         content = message["message"]
#         message_type = content["message_type"]
#         if MessageBuilder.GAME_START_MESSAGE == message_type:
#             return self.summarize_game_start(content)
#         if MessageBuilder.ROUND_START_MESSAGE == message_type:
#             return self.summarize_round_start(content)
#         if MessageBuilder.STREET_START_MESSAGE == message_type:
#             return self.summarize_street_start(content)
#         if MessageBuilder.GAME_UPDATE_MESSAGE == message_type:
#             return self.summarize_player_action(content)
#         if MessageBuilder.ROUND_RESULT_MESSAGE == message_type:
#             return self.summarize_round_result(content)
#         if MessageBuilder.GAME_RESULT_MESSAGE == message_type:
#             return self.summarize_game_result(content)
# 
#     def summarize_game_start(self, message):
#         base = "Started the game with player %s for %d round. (start stack=%s, small blind=%s)"
#         names = [player["name"] for player in message["game_information"]["seats"]]
#         rule = message["game_information"]["rule"]
#         return base % (names, rule["max_round"], rule["initial_stack"], rule["small_blind_amount"])
# 
#     def summarize_round_start(self, message):
#         base = "Started the round %d"
#         return base % message["round_count"]
# 
#     def summarize_street_start(self, message):
#         base = 'Street "%s" started. (community card = %s)'
#         return base % (message["street"], message["round_state"]["community_card"])
# 
#     def summarize_player_action(self, message):
#         base = '"%s" declared "%s:%s"'
#         players = message["round_state"]["seats"]
#         action = message["action"]
#         player_name = [player["name"] for player in players if player["uuid"] == action["player_uuid"]][0]
#         return base % (player_name, action["action"], action["amount"])
# 
#     def summarize_round_result(self, message):
#         base = '"%s" won the round %d (stack = %s)'
#         winners = [player["name"] for player in message["winners"]]
#         stack = { player["name"]:player["stack"] for player in message["round_state"]["seats"] }
#         return base % (winners, message["round_count"], stack)
# 
#     def summarize_game_result(self, message):
#         base = 'Game finished. (stack = %s)'
#         stack = { player["name"]:player["stack"] for player in message["game_information"]["seats"] }
#         return base % stack
# 
#     def summairze_blind_level_update(self, round_count, old_ante, new_ante, old_sb_amount, new_sb_amount):
#         base = 'Blind level update at round-%d : Ante %s -> %s, SmallBlind %s -> %s'
#         return base % (round_count, old_ante, new_ante, old_sb_amount, new_sb_amount)


# Path: tests/pypokerengine/engine/dealer_message_summarizer_test.py
import sys
    from StringIO import StringIO
    from io import StringIO
from tests.base_unittest import BaseUnitTest
from pypokerengine.engine.dealer import MessageSummarizer

try:
except ImportError:


class MessageSummarizerTest(BaseUnitTest):

    def setUp(self):

        self.summarizer = MessageSummarizer(verbose=2)