-testing number of parsed rectangles -testing range of table coordinates (where to find a table)
30 lines
700 B
Python
30 lines
700 B
Python
import pytest
|
|
from vidocp.table_parsing import parse_table
|
|
import numpy as np
|
|
import pdf2image
|
|
|
|
|
|
@pytest.fixture()
|
|
def rects():
|
|
page_index = 0
|
|
pdf_path = "/home/lillian/vidocp/tests/VV-313450.pdf"
|
|
page = pdf2image.convert_from_path(pdf_path, first_page=page_index + 1, last_page=page_index + 1)[0]
|
|
page = np.array(page)
|
|
rectangles = parse_table(page)
|
|
return rectangles
|
|
|
|
|
|
def test_num_of_rects(rects):
|
|
assert len(rects) == 49
|
|
|
|
|
|
def test_range_of_rects(rects):
|
|
expected_range = ((210, 605), (1430, 1620))
|
|
topleft = min(rects)
|
|
x,y,w,h = max(rects)
|
|
bottomright = (x+w, y+h)
|
|
|
|
assert topleft >= expected_range[0]
|
|
assert bottomright <= expected_range[1]
|
|
|