2 # -*- coding: utf-8 -*-
4 #Copyright 2009-2011 Matt Turnbull
5 #This program is free software: you can redistribute it and/or modify
6 #it under the terms of the GNU Affero General Public License as published by
7 #the Free Software Foundation, version 3 of the License.
9 #This program is distributed in the hope that it will be useful,
10 #but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 #GNU General Public License for more details.
14 #You should have received a copy of the GNU Affero General Public License
15 #along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #In the "official" distribution you can find the license in agpl-3.0.txt.
18 import PokerStarsToFpdb
27 config
= Configuration
.Config(file = "HUD_config.test.xml")
28 db
= Database
.Database(config
)
29 sql
= SQL
.Sql(db_server
= 'sqlite')
32 settings
.update(config
.get_db_parameters())
33 settings
.update(config
.get_import_parameters())
34 settings
.update(config
.get_default_paths())
36 #regression-test-files/stars/badugi/ring-fl-badugi.txt
37 # s0rrow: input: $30.00 end: $22.65 total: ($7.35)
38 #regression-test-files/stars/plo/PLO-6max.txt
39 # s0rrow: input: $18.35 end: $0 total: ($18.35)
40 # Notes: last hand #25975302416 s0rrow aifp against 2 players
42 gametype
= {'type':'ring', 'base':'draw', 'category':'badugi', 'limitType':'fl', 'sb':'0.25', 'bb':'0.50','currency':'USD'}
45 hhc
= PokerStarsToFpdb
.PokerStars(config
, autostart
=False)
47 h
= HoldemOmahaHand(config
, None, "PokerStars", gametype
, text
, builtFrom
= "Test")
48 h
.addPlayer("1", "s0rrow", "100000")
50 hhc
.compilePlayerRegexs(h
)
53 def checkGameInfo(hhc
, header
, info
):
54 assert hhc
.determineGameType(header
) == info
57 hhc
= PokerStarsToFpdb
.PokerStars(config
, autostart
=False)
59 (u
"PokerStars Game #20461877044: Hold'em No Limit ($1/$2) - 2008/09/16 18:58:01 ET",
60 {'type':'ring', 'base':"hold", 'category':'holdem', 'limitType':'nl', 'sb':'1', 'bb':'2', 'currency':'USD'}),
62 (u
"PokerStars Game #5999635897: HORSE (Omaha Hi/Lo Limit, $2/$4) - 2006/08/21 - 13:59:19 (ET)",
63 {'type':'ring', 'base':'hold', 'category':'omahahilo', 'limitType':'fl', 'sb':'2', 'bb':'4','currency':'USD'}),
65 (u
"PokerStars Game #25923772706: Badugi Limit ($0.25/$0.50) - 2009/03/13 16:40:58 ET",
66 {'type':'ring', 'base':'draw', 'category':'badugi', 'limitType':'fl', 'sb':'0.25', 'bb':'0.50','currency':'USD'}),
68 (u
"PokerStars Game #22073591924: Hold'em No Limit ($0.50/$1.00) - 2008/11/16 1:22:21 CET [2008/11/15 19:22:21 ET]",
69 {'type':'ring', 'base':'hold', 'category':'holdem', 'limitType':'nl', 'sb':'0.50', 'bb':'1.00','currency':'USD'}),
71 (u
"PokerStars Game #25974627364: Omaha Pot Limit ($0.05/$0.10) - 2009/03/15 0:29:00 ET",
72 {'type':'ring', 'base':'hold', 'category':'omahahi', 'limitType':'pl', 'sb':'0.05', 'bb':'0.10','currency':'USD'})
74 for (header
, info
) in pairs
:
75 yield checkGameInfo
, hhc
, header
, info
80 importer
= fpdb_import
.Importer(False, settings
, config
)
81 importer
.setDropIndexes("don't drop")
82 importer
.setFailOnError(True)
83 importer
.setThreads(-1)
84 importer
.addBulkImportImportFileOrDir(
85 """regression-test-files/cash/Stars/Flop/NLHE-6max-EUR-0.05-0.10-200911.txt""", site
="PokerStars")
86 importer
.addBulkImportImportFileOrDir(
87 """regression-test-files/cash/Stars/Flop/NLHE-6max-USD-0.05-0.10-200911.txt""", site
="PokerStars")
88 #importer.addBulkImportImportFileOrDir(
89 # """regression-test-files/tour/Stars/Flop/NLHE-USD-MTT-5r-200710.txt""", site="PokerStars")
90 importer
.addBulkImportImportFileOrDir(
91 """regression-test-files/cash/Stars/Flop/PLO8-6max-USD-0.01-0.02-200911.txt""", site
="PokerStars")
93 # Besides the horrible play it contains lots of useful cases
94 # Preflop: raise, then 3bet chance for seat 2
95 # Flop: Checkraise by hero, 4bet chance not taken by villain
96 # Turn: Turn continuation bet by hero, called
97 # River: hero (continuation bets?) all-in and is not called
98 importer
.addBulkImportImportFileOrDir(
99 """regression-test-files/cash/Stars/Flop/NLHE-6max-USD-0.05-0.10-200912.Stats-comparision.txt""", site
="PokerStars")
100 importer
.addBulkImportImportFileOrDir(
101 """regression-test-files/cash/Stars/Flop/NLHE-6max-USD-0.05-0.10-200912.Allin-pre.txt""", site
="PokerStars")
102 importer
.setCallHud(False)
103 (stored
, dups
, partial
, errs
, ttime
) = importer
.runImport()
104 print "DEBUG: stored: %s dups: %s partial: %s errs: %s ttime: %s" %(stored
, dups
, partial
, errs
, ttime
)
105 importer
.clearFileList()
107 col
= { 'sawShowdown': 2, 'street0Aggr':3
122 h.siteHandNo = 36185273365
123 and g.id = h.gametypeid
125 and p.id = hp.playerid
126 and s.id = p.siteid"""
129 result
= c
.fetchall()
130 for row
, data
in enumerate(result
):
131 print "DEBUG: result[%s]: %s" %(row
, result
[row
])
132 # Assert if any sawShowdown = True
133 assert result
[row
][col
['sawShowdown']] == 0
147 h.siteHandNo = 37165169101
148 and g.id = h.gametypeid
150 and p.id = hp.playerid
151 and s.id = p.siteid"""
154 result
= c
.fetchall()
155 pstats
= { u
'Kinewma':0, u
'Arbaz':0, u
's0rrow':1, u
'bys7':0, u
'AAALISAAAA':1, u
'Bl\xe5veis':0 }
156 for row
, data
in enumerate(result
):
157 print "DEBUG: result[%s]: %s == %s" %(row
, result
[row
], pstats
[data
[1]])
158 assert result
[row
][col
['sawShowdown']] == pstats
[data
[1]]
162 def testStudImport():
164 importer
= fpdb_import
.Importer(False, settings
, config
)
165 importer
.setDropIndexes("don't drop")
166 importer
.setFailOnError(True)
167 importer
.setThreads(-1)
168 importer
.addBulkImportImportFileOrDir(
169 """regression-test-files/cash/Stars/Stud/7-Stud-USD-0.04-0.08-200911.txt""", site
="PokerStars")
170 importer
.addBulkImportImportFileOrDir(
171 """regression-test-files/cash/Stars/Stud/7-StudHL-USD-0.04-0.08-200911.txt""", site
="PokerStars")
172 importer
.addBulkImportImportFileOrDir(
173 """regression-test-files/cash/Stars/Stud/Razz-USD-0.04-0.08-200911.txt""", site
="PokerStars")
174 importer
.setCallHud(False)
175 (stored
, dups
, partial
, errs
, ttime
) = importer
.runImport()
176 importer
.clearFileList()
178 # Should actually do some testing here
181 def testDrawImport():
184 importer
= fpdb_import
.Importer(False, settings
, config
)
185 importer
.setDropIndexes("don't drop")
186 importer
.setFailOnError(True)
187 importer
.setThreads(-1)
188 importer
.addBulkImportImportFileOrDir(
189 """regression-test-files/cash/Stars/Draw/3-Draw-Limit-USD-0.10-0.20-200911.txt""", site
="PokerStars")
190 importer
.addBulkImportImportFileOrDir(
191 """regression-test-files/cash/Stars/Draw/5-Carddraw-USD-0.10-0.20-200911.txt""", site
="PokerStars")
192 importer
.setCallHud(False)
193 (stored
, dups
, partial
, errs
, ttime
) = importer
.runImport()
194 importer
.clearFileList()
198 # Should actually do some testing here