Add regression test for clean_title function and revert regex change

This commit is contained in:
Worros 2008-12-12 20:12:45 +09:00
parent ff1a2c42b8
commit 6afe8f0240
2 changed files with 8 additions and 3 deletions

View File

@ -30,6 +30,7 @@ import fpdb_db
import fpdb_import
import fpdb_simple
import FpdbSQLQueries
import Tables
import unittest
@ -89,6 +90,10 @@ class TestSequenceFunctions(unittest.TestCase):
self.failUnless(result==datetime.datetime(2008,8,17,6,14,43),
"Date incorrect, expected: 2008-08-17 01:14:43 got: " + str(result))
def testTableDetection(self):
result = Tables.clean_title("French (deep)")
self.failUnless(result == "French", "French (deep) parsed incorrectly. Expected 'French' got: " + str(result))
def testImportHandHistoryFiles(self):
"""Test import of single HH file"""
self.mysqlimporter.addImportFile("regression-test-files/hand-histories/ps-lhe-ring-3hands.txt")

View File

@ -339,9 +339,9 @@ def fulltilt_decode_table(tw):
def clean_title(name):
"""Clean the little info strings from the table name."""
# these strings could go in a config file
for pattern in [' (6 max)', ' (heads up)', ' (deep)',
' (deep hu)', ' (deep 6)', ' (2)',
' (edu)', ' (edu, 6 max)', ' (6)',
for pattern in [' \(6 max\)', ' \(heads up\)', ' \(deep\)',
' \(deep hu\)', ' \(deep 6\)', ' \(2\)',
' \(edu\)', ' \(edu, 6 max\)', ' \(6\)',
' no all-in', ' fast', ',', ' 50BB min', '\s+$']:
name = re.sub(pattern, '', name)
name = name.rstrip()