Spaces:
Running
Running
Merge pull request #27 from lfoppiano/test-tests
Browse files
.github/workflows/ci-build.yml
CHANGED
@@ -34,9 +34,9 @@ jobs:
|
|
34 |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
35 |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
36 |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
docker-build:
|
42 |
needs: [build]
|
|
|
34 |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
35 |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
36 |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
37 |
+
- name: Test with pytest
|
38 |
+
run: |
|
39 |
+
pytest
|
40 |
|
41 |
docker-build:
|
42 |
needs: [build]
|
tests/resources/__init__.py
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
TEST_DATA_PATH = os.path.dirname(__file__)
|
tests/test_grobid_processors.py
CHANGED
@@ -1,9 +1,12 @@
|
|
|
|
|
|
1 |
from bs4 import BeautifulSoup
|
2 |
from document_qa.grobid_processors import get_xml_nodes_body, get_xml_nodes_figures, get_xml_nodes_header
|
|
|
3 |
|
4 |
|
5 |
def test_get_xml_nodes_body_paragraphs():
|
6 |
-
with open("
|
7 |
soup = BeautifulSoup(fo, 'xml')
|
8 |
|
9 |
nodes = get_xml_nodes_body(soup, use_paragraphs=True)
|
@@ -12,7 +15,7 @@ def test_get_xml_nodes_body_paragraphs():
|
|
12 |
|
13 |
|
14 |
def test_get_xml_nodes_body_sentences():
|
15 |
-
with open("
|
16 |
soup = BeautifulSoup(fo, 'xml')
|
17 |
|
18 |
children = get_xml_nodes_body(soup, use_paragraphs=False)
|
@@ -21,7 +24,7 @@ def test_get_xml_nodes_body_sentences():
|
|
21 |
|
22 |
|
23 |
def test_get_xml_nodes_figures():
|
24 |
-
with open("
|
25 |
soup = BeautifulSoup(fo, 'xml')
|
26 |
|
27 |
children = get_xml_nodes_figures(soup)
|
@@ -30,17 +33,18 @@ def test_get_xml_nodes_figures():
|
|
30 |
|
31 |
|
32 |
def test_get_xml_nodes_header_paragraphs():
|
33 |
-
with open("
|
34 |
soup = BeautifulSoup(fo, 'xml')
|
35 |
|
36 |
children = get_xml_nodes_header(soup)
|
37 |
|
38 |
-
assert len(children) == 8
|
|
|
39 |
|
40 |
def test_get_xml_nodes_header_sentences():
|
41 |
-
with open("
|
42 |
soup = BeautifulSoup(fo, 'xml')
|
43 |
|
44 |
children = get_xml_nodes_header(soup, use_paragraphs=False)
|
45 |
|
46 |
-
assert len(children) == 15
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
from bs4 import BeautifulSoup
|
4 |
from document_qa.grobid_processors import get_xml_nodes_body, get_xml_nodes_figures, get_xml_nodes_header
|
5 |
+
from tests.resources import TEST_DATA_PATH
|
6 |
|
7 |
|
8 |
def test_get_xml_nodes_body_paragraphs():
|
9 |
+
with open(os.path.join(TEST_DATA_PATH, "2312.07559.paragraphs.tei.xml"), 'r') as fo:
|
10 |
soup = BeautifulSoup(fo, 'xml')
|
11 |
|
12 |
nodes = get_xml_nodes_body(soup, use_paragraphs=True)
|
|
|
15 |
|
16 |
|
17 |
def test_get_xml_nodes_body_sentences():
|
18 |
+
with open(os.path.join(TEST_DATA_PATH, "2312.07559.sentences.tei.xml"), 'r') as fo:
|
19 |
soup = BeautifulSoup(fo, 'xml')
|
20 |
|
21 |
children = get_xml_nodes_body(soup, use_paragraphs=False)
|
|
|
24 |
|
25 |
|
26 |
def test_get_xml_nodes_figures():
|
27 |
+
with open(os.path.join(TEST_DATA_PATH, "2312.07559.paragraphs.tei.xml"), 'r') as fo:
|
28 |
soup = BeautifulSoup(fo, 'xml')
|
29 |
|
30 |
children = get_xml_nodes_figures(soup)
|
|
|
33 |
|
34 |
|
35 |
def test_get_xml_nodes_header_paragraphs():
|
36 |
+
with open(os.path.join(TEST_DATA_PATH, "2312.07559.paragraphs.tei.xml"), 'r') as fo:
|
37 |
soup = BeautifulSoup(fo, 'xml')
|
38 |
|
39 |
children = get_xml_nodes_header(soup)
|
40 |
|
41 |
+
assert sum([len(child) for k, child in children.items()]) == 8
|
42 |
+
|
43 |
|
44 |
def test_get_xml_nodes_header_sentences():
|
45 |
+
with open(os.path.join(TEST_DATA_PATH, "2312.07559.sentences.tei.xml"), 'r') as fo:
|
46 |
soup = BeautifulSoup(fo, 'xml')
|
47 |
|
48 |
children = get_xml_nodes_header(soup, use_paragraphs=False)
|
49 |
|
50 |
+
assert sum([len(child) for k, child in children.items()]) == 15
|