I think this attached patch is close to working but I still have some
test failures. It's sitting on r5211 of poker-prizes branch.
I have one failure on the pokerservice tests:
__main__.PokerServiceTestCase.test16_runTourney_freeroll ... [FAILURE]
===============================================================================
[FAIL]: __main__.PokerServiceTestCase.test16_runTourney_freeroll
Traceback (most recent call last):
File "./test-pokerservice.py", line 1197, in checkTourneys
self.assertEquals(prize, self.service.getMoney(self.user2_serial, 2),
"bailor user2")
twisted.trial.unittest.FailTest: bailor user2
-------------------------------------------------------------------------------
diff --git a/poker-network/ChangeLog b/poker-network/ChangeLog
index 6a7ecfb..e255fe3 100644
--- a/poker-network/ChangeLog
+++ b/poker-network/ChangeLog
@@ -1,3 +1,13 @@
+2008-12-08 Bradley M. Kuhn <[EMAIL PROTECTED]>
+
+ * pokernetwork/pokerservice.py (PokerService.tourneyManager):
+ prizesTable() => prizes() for PokerTournament; added condition to
+ properly fill rank2prize when no tourney object.
+
+ * tests/test-pokerservice.py.in
+ (TourneyManagerTestCase.test06_tourneyInDB): Wrote test to show
+ sr#2207.
+
2008-12-08 Loic Dachary <[EMAIL PROTECTED]>
* Release 1.7.1
diff --git a/poker-network/pokernetwork/pokerservice.py b/poker-network/pokernetwork/pokerservice.py
index db8545d..51ac55c 100644
--- a/poker-network/pokernetwork/pokerservice.py
+++ b/poker-network/pokernetwork/pokerservice.py
@@ -1028,8 +1028,19 @@ class PokerService(service.Service):
packet.tourney["registered"] = len(user2tourney)
packet.tourney["rank2prize"] = None
if self.tourneys.has_key(tourney_serial):
- packet.tourney["rank2prize"] = self.tourneys[tourney_serial].prizesTable()
-
+ packet.tourney["rank2prize"] = self.tourneys[tourney_serial].prizes()
+ else:
+ # What follows really a complete hack. Since prizes_specs
+ # isn't stored in the database, we don't really know if we
+ # should use "Table" lookup. There are no checks being done
+ # or anything like that to see if these ranks were actually
+ # payed these amounts. But it might be good enough to solve
+ # an immediate problem.
+ from pokerengine.pokerprizes import PokerPrizesFactory
+ packet.tourney["rank2prize"] = PokerPrizesFactory().getClass("Table")(
+ buyInAmount = packet.tourney['buy_in'],
+ playerCount = packet.tourney["registered"],
+ configDirs = self.dirs).getPrizes()
cursor.close()
user2properties = {}
diff --git a/poker-network/tests/test-pokerservice.py.in b/poker-network/tests/test-pokerservice.py.in
index 4f0f16f..d9c47e1 100644
--- a/poker-network/tests/test-pokerservice.py.in
+++ b/poker-network/tests/test-pokerservice.py.in
@@ -1543,6 +1543,24 @@ class TourneyManagerTestCase(PokerServiceTestCaseBase):
# just a self.message() anyway and converage can wait; I'm in a
# hurry.
pass
+ # ------------------------------------------------------------------------
+ def test06_tourneyInDB(self):
+ self.service.startService()
+ self.createUsers()
+ db = self.service.db.db
+ tourney_serial = 11791
+ db.query("INSERT INTO tourneys (serial, state, buy_in) VALUES (%d, '%s', %d)" % (tourney_serial, 'complete', 1000))
+ db.query("INSERT INTO user2tourney (tourney_serial, user_serial, table_serial, rank) VALUES (11791, 1, 1, 1)")
+ db.query("INSERT INTO user2tourney (tourney_serial, user_serial, table_serial, rank) VALUES (11791, 2, 1, 2)")
+ db.query("INSERT INTO user2tourney (tourney_serial, user_serial, table_serial, rank) VALUES (11791, 3, 1, 3)")
+ db.query("INSERT INTO user2tourney (tourney_serial, user_serial, table_serial, rank) VALUES (11791, 4, 1, 4)")
+ packet = self.service.tourneyManager(tourney_serial)
+ self.assertEquals(packet.type, PACKET_POKER_TOURNEY_MANAGER)
+ rank2prize = packet.tourney['rank2prize']
+ self.assertEquals(len(rank2prize), 2)
+ self.assertEquals(int(rank2prize[0]), 2800)
+ self.assertEquals(int(rank2prize[1]), 1200)
+ self.assertEquals(packet.tourney['registered'], 4)
###########################################################################
class TourneyMovePlayerTestCase(PokerServiceTestCaseBase):
@@ -2527,7 +2545,7 @@ class PokerServiceCoverageTests(unittest.TestCase):
# ----------------------------------------------------------------
def Run():
loader = runner.TestLoader()
-# loader.methodPrefix = "test04"
+# loader.methodPrefix = "test06"
suite = loader.suiteFactory()
suite.addTest(loader.loadClass(PokerServiceTestCase))
suite.addTest(loader.loadClass(RefillTestCase))
--
-- bkuhn
_______________________________________________
Pokersource-users mailing list
[email protected]
https://mail.gna.org/listinfo/pokersource-users