Skip to content

Commit

Permalink
[checkoutlinesufo_test] Remove overlap test case
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelsousa committed Jul 16, 2018
1 parent 3931a4d commit 50892e1
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Tests/checkoutlinesufo_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
from __future__ import print_function, division, absolute_import

import os
import pytest
from shutil import copytree
import tempfile

from booleanOperations.booleanGlyph import BooleanGlyph
from defcon import Glyph

from afdko.Tools.SharedData.FDKScripts.CheckOutlinesUFO import (
remove_tiny_sub_paths)

from .runner import main as runner
from .differ import main as differ

TOOL = 'checkoutlinesufo'
CMD = ['-t', TOOL]

UFO2_NAME = 'ufo2.ufo'
UFO3_NAME = 'ufo3.ufo'

data_dir_path = os.path.join(os.path.split(__file__)[0], TOOL + '_data')


def _get_expected_path(file_name):
return os.path.join(data_dir_path, 'expected_output', file_name)


def _get_input_path(file_name):
return os.path.join(data_dir_path, 'input', file_name)


# -----
# Tests
Expand Down Expand Up @@ -37,3 +61,17 @@ def test_remove_tiny_sub_paths_small_contour():
assert remove_tiny_sub_paths(bg, 25, []) == \
['Contour 0 is too small: bounding box is less than minimum area. '
'Start point: ((1, 1)).']


@pytest.mark.parametrize('ufo_filename', [UFO2_NAME, UFO3_NAME])
@pytest.mark.parametrize('args, expct_label', [
(['e', 'w', 'q'], 'dflt-layer.ufo'),
(['e', 'q'], 'proc-layer.ufo'),
])
def test_remove_overlap(args, ufo_filename, expct_label):
actual_path = os.path.join(tempfile.mkdtemp(), ufo_filename)
copytree(_get_input_path(ufo_filename), actual_path)
runner(CMD + ['-n', '-f', actual_path, '-o'] + args)
expct_filename = '{}-{}'.format(ufo_filename[:-4], expct_label)
expected_path = _get_expected_path(expct_filename)
assert differ([expected_path, actual_path])

0 comments on commit 50892e1

Please sign in to comment.