Tweak tests to handle changes to .utils

This commit is contained in:
Jeremy Singer-Vine
2016-03-05 14:06:51 -05:00
parent efe7967812
commit 88b4cc2c94
2 changed files with 7 additions and 9 deletions
+5 -7
View File
@@ -24,12 +24,10 @@ def parse_results_line(chars):
return { "text": left, "aff": mid, "votes": right }
class PrecinctPage(object):
def __init__(self, pdf, pageid):
z = lambda objs: pd.DataFrame([ x
for x in objs if x["pageid"] == pageid])
self.chars = z(pdf.chars)
self.lines = z(pdf.lines)
self.rects = z(pdf.rects)
def __init__(self, page):
self.chars = pd.DataFrame(page.chars)
self.lines = pd.DataFrame(page.lines)
self.rects = pd.DataFrame(page.rects)
self.bboxes = self.get_bboxes()
def get_bboxes(self):
@@ -115,7 +113,7 @@ class Test(unittest.TestCase):
pass
def test_pandas(self):
p1 = PrecinctPage(self.pdf, 1).to_dict()
p1 = PrecinctPage(self.pdf.pages[0]).to_dict()
assert(p1["registered_voters"] == 1100)
assert(p1["ballots_cast"] == 327)
assert(p1["precinct"] == "0050003A|ACTON")
+2 -2
View File
@@ -67,7 +67,7 @@ class Test(unittest.TestCase):
colsum = sum(row[c] or 0 for row in parsed_table)
assert(colsum == (total * 2))
month_chars = within_bbox(chars, (0, 35, self.PDF_WIDTH, 60))
month_chars = within_bbox(chars, (0, 35, self.PDF_WIDTH, 65))
month_text = collate_chars(month_chars, x_tolerance=2)
assert(month_text == "November - 2015")
@@ -89,6 +89,6 @@ class Test(unittest.TestCase):
colsum = table[c].sum()
assert(colsum == (total * 2))
month_chars = within_bbox(chars, (0, 35, self.PDF_WIDTH, 60))
month_chars = within_bbox(chars, (0, 35, self.PDF_WIDTH, 65))
month_text = collate_chars(month_chars, x_tolerance=2)
assert(month_text == "November - 2015")