From 88b4cc2c94082b9aa665b7abd2ce992f2bf57442 Mon Sep 17 00:00:00 2001 From: Jeremy Singer-Vine Date: Sat, 5 Mar 2016 14:06:51 -0500 Subject: [PATCH] Tweak tests to handle changes to .utils --- tests/test-la-precinct-bulletin-2014-p1.py | 12 +++++------- tests/test-nics-background-checks-2015-11.py | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/test-la-precinct-bulletin-2014-p1.py b/tests/test-la-precinct-bulletin-2014-p1.py index 3cda9e8..dbd2f3b 100644 --- a/tests/test-la-precinct-bulletin-2014-p1.py +++ b/tests/test-la-precinct-bulletin-2014-p1.py @@ -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") diff --git a/tests/test-nics-background-checks-2015-11.py b/tests/test-nics-background-checks-2015-11.py index 1f5fb17..0f8b4e9 100644 --- a/tests/test-nics-background-checks-2015-11.py +++ b/tests/test-nics-background-checks-2015-11.py @@ -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")