added two tests for table_parsing.py
-testing number of parsed rectangles -testing range of table coordinates (where to find a table)
This commit is contained in:
parent
6fb34735a2
commit
496957051c
7
.gitignore
vendored
7
.gitignore
vendored
@ -8,4 +8,9 @@
|
||||
/.idea/vcs.xml
|
||||
/results/
|
||||
/data
|
||||
/table_parsing.egg-info
|
||||
/table_parsing.egg-info
|
||||
/tests/VV-313450.pdf
|
||||
/vidocp.egg-info/dependency_links.txt
|
||||
/vidocp.egg-info/PKG-INFO
|
||||
/vidocp.egg-info/SOURCES.txt
|
||||
/vidocp.egg-info/top_level.txt
|
||||
|
||||
29
tests/test_table_parsing.py
Normal file
29
tests/test_table_parsing.py
Normal file
@ -0,0 +1,29 @@
|
||||
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]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user