Fix Everleaf GameInfo regex to detect FL
Added regression test mechanism while at it
This commit is contained in:
parent
3fba85456c
commit
c0400f6c66
|
@ -28,7 +28,7 @@ class Everleaf(HandHistoryConverter):
|
|||
|
||||
# Static regexes
|
||||
re_SplitHands = re.compile(r"\n\n+")
|
||||
re_GameInfo = re.compile(r".*Blinds \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (?P<LTYPE>(NL|PL)) (?P<GAME>(Hold\'em|Omaha|7 Card Stud))")
|
||||
re_GameInfo = re.compile(r"^(Blinds )?\$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) ((?P<LTYPE>NL|PL) )?(?P<GAME>(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE)
|
||||
re_HandInfo = re.compile(r".*#(?P<HID>[0-9]+)\n.*\nBlinds \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (?P<GAMETYPE>.*) - (?P<DATETIME>\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P<TABLE>[- a-zA-Z]+)")
|
||||
re_Button = re.compile(r"^Seat (?P<BUTTON>\d+) is the button", re.MULTILINE)
|
||||
re_PlayerInfo = re.compile(r"^Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\s+(\$ (?P<CASH>[.0-9]+) USD|new player|All-in) \)", re.MULTILINE)
|
||||
|
|
|
@ -30,6 +30,7 @@ import fpdb_db
|
|||
import fpdb_import
|
||||
import fpdb_simple
|
||||
import FpdbSQLQueries
|
||||
import EverleafToFpdb
|
||||
import Tables
|
||||
|
||||
import unittest
|
||||
|
@ -52,6 +53,8 @@ class TestSequenceFunctions(unittest.TestCase):
|
|||
self.mysqlimporter = fpdb_import.Importer(self, self.mysql_settings, self.c)
|
||||
self.mysqlimporter.setCallHud(False)
|
||||
|
||||
self.everleaf = EverleafToFpdb.Everleaf(self.c, "Nofile")
|
||||
|
||||
# """Configure Postgres settings/database and establish connection"""
|
||||
# self.pg_settings={ 'db-host':"localhost", 'db-backend':3, 'db-databaseName':"fpdbtest", 'db-user':"fpdb", 'db-password':"fpdb"}
|
||||
# self.pg_db = fpdb_db.fpdb_db()
|
||||
|
@ -110,12 +113,57 @@ class TestSequenceFunctions(unittest.TestCase):
|
|||
self.failUnless(result == "French", "French (deep) parsed incorrectly. Expected 'French' got: " + str(result))
|
||||
# result = ("French (deep) - $0.25/$0.50 - No Limit Hold'em - Logged In As xxxx")
|
||||
|
||||
def testImportHandHistoryFiles(self):
|
||||
"""Test import of single HH file"""
|
||||
self.mysqlimporter.addImportFile("regression-test-files/hand-histories/ps-lhe-ring-3hands.txt")
|
||||
self.mysqlimporter.runImport()
|
||||
self.mysqlimporter.addImportDirectory("regression-test-files/hand-histories")
|
||||
self.mysqlimporter.runImport()
|
||||
def testEverleafGameInfoRegex(self):
|
||||
cash_nlhe = """Everleaf Gaming Game #55198191
|
||||
***** Hand history for game #55198191 *****
|
||||
Blinds $0.50/$1 NL Hold'em - 2008/09/01 - 10:02:11
|
||||
Table Speed Kuala
|
||||
Seat 8 is the button
|
||||
Total number of players: 10"""
|
||||
cash_plo = """Everleaf Gaming Game #65295370
|
||||
***** Hand history for game #65295370 *****
|
||||
Blinds $0.50/$1 PL Omaha - 2008/12/07 - 21:59:48
|
||||
Table Guanajuato
|
||||
Seat 5 is the button
|
||||
Total number of players: 6"""
|
||||
cash_flhe = """Everleaf Gaming Game #55809022
|
||||
***** Hand history for game #55809022 *****
|
||||
$1/$2 Hold'em - 2008/09/07 - 08:04:36
|
||||
Table Jeonju
|
||||
Seat 4 is the button
|
||||
Total number of players: 5
|
||||
"""
|
||||
#NLHE
|
||||
m = self.everleaf.re_GameInfo.search(cash_nlhe)
|
||||
sb = m.group('SB')
|
||||
bb = m.group('BB')
|
||||
ltype = m.group('LTYPE')
|
||||
game = m.group('GAME')
|
||||
|
||||
self.failUnless(sb == "0.50", "SB incorrect, expected: 0.50 got: '" + sb + "'")
|
||||
self.failUnless(bb == "1", "BB incorrect, expected: 1 got: '" + bb + "'")
|
||||
self.failUnless(ltype == "NL", "LTYPE incorrect, expected: NL got: '" + ltype + "'")
|
||||
self.failUnless(game == "Hold\'em", "GAME incorrect, expected: Hold\'em got: '" + game + "'")
|
||||
|
||||
#FLHE
|
||||
m = self.everleaf.re_GameInfo.search(cash_flhe)
|
||||
sb = m.group('SB')
|
||||
bb = m.group('BB')
|
||||
ltype = m.group('LTYPE')
|
||||
game = m.group('GAME')
|
||||
print m.groups()
|
||||
|
||||
self.failUnless(sb == "1", "SB incorrect, expected: 1 got: '" + sb + "'")
|
||||
self.failUnless(bb == "2", "BB incorrect, expected: 2 got: '" + bb + "'")
|
||||
self.failUnless(ltype == None, "LTYPE incorrect, expected: NL got: '%s'" %(ltype))
|
||||
self.failUnless(game == "Hold\'em", "GAME incorrect, expected: Hold\'em got: '" + game + "'")
|
||||
|
||||
# def testImportHandHistoryFiles(self):
|
||||
# """Test import of single HH file"""
|
||||
# self.mysqlimporter.addImportFile("regression-test-files/hand-histories/ps-lhe-ring-3hands.txt")
|
||||
# self.mysqlimporter.runImport()
|
||||
# self.mysqlimporter.addImportDirectory("regression-test-files/hand-histories")
|
||||
# self.mysqlimporter.runImport()
|
||||
|
||||
# def testPostgresSQLRecreateTables(self):
|
||||
# """Test droping then recreating fpdb table schema"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user