Skip to content

Commit

Permalink
Restructure unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jianjie Liu (MAIDAP) committed Jan 25, 2021
1 parent 1793c3d commit 3b293bd
Show file tree
Hide file tree
Showing 57 changed files with 16 additions and 24 deletions.
8 changes: 4 additions & 4 deletions tests/e2e/test_anchor_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
@pytest.mark.parametrize(
"gt_file, ocr_file",
zip(
sorted(glob.glob("tests/text/data/gt_*.txt")),
sorted(glob.glob("tests/text/data/ocr_*.txt")),
sorted(glob.glob("tests/unit/text/data/gt_*.txt")),
sorted(glob.glob("tests/unit/text/data/ocr_*.txt")),
),
)
def test_align_w_anchor_and_align(gt_file, ocr_file):
Expand All @@ -37,8 +37,8 @@ def test_align_w_anchor_and_align(gt_file, ocr_file):
@pytest.mark.parametrize(
"gt_file, ocr_file",
zip(
sorted(glob.glob("tests/text/data/gt_*.txt")),
sorted(glob.glob("tests/text/data/ocr_*.txt")),
sorted(glob.glob("tests/unit/text/data/gt_*.txt")),
sorted(glob.glob("tests/unit/text/data/ocr_*.txt")),
),
)
@pytest.mark.parametrize("max_seg_length", [25, 50, 75, 100, 150])
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/test_document_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
UNSUPPORTED_CONTENT_FORMAT = ["foo bar"]
UNSUPPORTED_CONTENT_TYPE = CompositeContent(["foo"], [ContentType.TITLE])

CUSTOM_TEMPLATE_PATH = "tests/generation/templates"
CUSTOM_TEMPLATE_PATH = "tests/unit/generation/templates"
CUSTOM_TEMPLATE_NAME = "mock.html.jinja"
CUSTOM_STYLE_TEMPLATE_NAME = "font_family.html.jinja"
MULTI_PAGE_TEMPLATE_NAME = "multipage.html.jinja"
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from genalog import pipeline

EXAMPLE_TEXT_FILE = "tests/text/data/gt_1.txt"
EXAMPLE_TEXT_FILE = "tests/unit/text/data/gt_1.txt"


@pytest.fixture
Expand Down Expand Up @@ -36,7 +36,7 @@ def test_custom_generate_img(custom_analog_generator):


def test_generate_dataset_multiprocess():
INPUT_TEXT_FILENAMES = glob.glob("tests/text/data/gt_*.txt")
INPUT_TEXT_FILENAMES = glob.glob("tests/unit/text/data/gt_*.txt")
with pytest.deprecated_call():
pipeline.generate_dataset_multiprocess(
INPUT_TEXT_FILENAMES, "test_out", {}, [], "text_block.html.jinja"
Expand Down
8 changes: 0 additions & 8 deletions tests/ocr/.env

This file was deleted.

File renamed without changes.
Empty file added tests/unit/cases/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
MOCK_TEMPLATE = MagicMock()
MOCK_TEMPLATE.render.return_value = MOCK_COMPILED_DOCUMENT

IMG_BYTES = open("tests/generation/2x2.jpg", "rb").read()
IMG_BYTES = open("tests/unit/generation/2x2.jpg", "rb").read()

FILE_DESTINATION_PDF = "sample.pdf"
FILE_DESTINATION_PNG = "sample.png"

CUSTOM_TEMPLATE_PATH = "tests/generation/templates"
CUSTOM_TEMPLATE_PATH = "tests/unit/generation/templates"
CUSTOM_TEMPLATE_NAME = "mock.html.jinja"
DEFAULT_TEMPLATE_NAME = "text_block.html.jinja"
DEFAULT_PACKAGE_NAME = "genalog.generation"
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import pytest

from genalog.text import alignment
from tests.cases.text_alignment import ALIGNMENT_REGRESSION_TEST_CASES
from tests.cases.text_alignment import PARSE_ALIGNMENT_REGRESSION_TEST_CASES
from tests.unit.cases.text_alignment import ALIGNMENT_REGRESSION_TEST_CASES
from tests.unit.cases.text_alignment import PARSE_ALIGNMENT_REGRESSION_TEST_CASES

RANDOM_INT = randint(1, 100)
MOCK_ALIGNMENT_RESULT = [("X", "X", 0, 0, 1)]
Expand Down
6 changes: 3 additions & 3 deletions tests/text/test_anchor.py → tests/unit/text/test_anchor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

from genalog.text import alignment, anchor, preprocess
from tests.cases.text_alignment import ALIGNMENT_REGRESSION_TEST_CASES
from tests.unit.cases.text_alignment import ALIGNMENT_REGRESSION_TEST_CASES


@pytest.mark.parametrize(
Expand Down Expand Up @@ -200,8 +200,8 @@ def test_find_anchor_recur_fixed_seg_len(
@pytest.mark.parametrize(
"gt_file, ocr_file",
zip(
sorted(glob.glob("tests/text/data/gt_1.txt")),
sorted(glob.glob("tests/text/data/ocr_1.txt")),
sorted(glob.glob("tests/unit/text/data/gt_1.txt")),
sorted(glob.glob("tests/unit/text/data/ocr_1.txt")),
),
)
@pytest.mark.parametrize("max_seg_length", [75])
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from genalog.text import ner_label
from tests.cases.label_propagation import LABEL_PROPAGATION_REGRESSION_TEST_CASES
from tests.unit.cases.label_propagation import LABEL_PROPAGATION_REGRESSION_TEST_CASES


@pytest.mark.parametrize(
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/text/test_utf8.py → tests/unit/text/test_utf8.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from genalog.text import alignment
from genalog.text.alignment import GAP_CHAR
from tests.cases.text_alignment import ALIGNMENT_REGRESSION_TEST_CASES
from tests.unit.cases.text_alignment import ALIGNMENT_REGRESSION_TEST_CASES


def random_utf8_char(byte_len=1):
Expand Down

0 comments on commit 3b293bd

Please sign in to comment.