Exemple #1
0
 def test_ActionRequest(self):
     """Test ActionRequest class"""
     request = ActionRequest(ActionRequest.ANTE_REQUEST, 10)
     self.assertIsNotNone(request)
     self.assertTrue(request.is_ante_request())
     self.assertEqual(request.amount, 10)
     self.assertEqual(str(request), "ante request for 10")
     request.validate_action(Action.new_ante(10))
Exemple #2
0
 def test_option_ActionRequest(self):
     """Test ActionRequest for option"""
     amount = 50
     request = ActionRequest.new_option_request(amount)
     self.assertIsNotNone(request)
     self.assertTrue(request.is_option_request())
     self.assertEqual(request.raise_amount, amount)
     request.validate_action(Action.new_check())
     request.validate_action(Action.new_raise(amount))
     with self.assertRaises(InvalidActionException):
         request.validate_action(Action.new_blind(amount+1))
     with self.assertRaises(InvalidActionException):
         request.validate_action(Action.new_call(amount))
     with self.assertRaises(InvalidActionException):
         request.validate_action(Action.new_bet(amount))
     with self.assertRaises(InvalidActionException):
         request.validate_action(Action.new_fold())
Exemple #3
0
 def test_ante_ActionRequest(self):
     """Test ActionRequest for ante"""
     amount = 20
     request = ActionRequest.new_ante_request(amount)
     self.assertIsNotNone(request)
     self.assertTrue(request.is_ante_request())
     self.assertEqual(request.amount, amount)
     request.validate_action(Action.new_ante(amount))
     request.validate_action(Action.new_fold())
     with self.assertRaises(InvalidActionException):
         request.validate_action(Action.new_ante(amount+1))
     with self.assertRaises(InvalidActionException):
         request.validate_action(Action.new_call(amount))
     with self.assertRaises(InvalidActionException):
         request.validate_action(Action.new_bet(amount))
     with self.assertRaises(InvalidActionException):
         request.validate_action(Action.new_raise(amount))
Exemple #4
0
 def test_call_ActionRequest(self):
     """Test ActionRequest for call"""
     amount = 50
     request = ActionRequest.new_call_request(amount, raise_amount=amount*2)
     self.assertIsNotNone(request)
     self.assertTrue(request.is_call_request())
     self.assertEqual(request.amount, amount)
     self.assertEqual(request.raise_amount, amount*2)
     self.assertEqual(str(request), "call request for 50 or raise of 100")
     request.validate_action(Action.new_call(amount))
     request.validate_action(Action.new_raise(amount*2))
     request.validate_action(Action.new_fold())
     with self.assertRaises(InvalidActionException):
         request.validate_action(Action.new_ante(amount))
     with self.assertRaises(InvalidActionException):
         request.validate_action(Action.new_blind(amount))
     with self.assertRaises(InvalidActionException):
         request.validate_action(Action.new_call(amount+1))
     with self.assertRaises(InvalidActionException):
         request.validate_action(Action.new_bet(amount))
     with self.assertRaises(InvalidActionException):
         request.validate_action(Action.new_raise(amount*2-1))