aboutsummaryrefslogtreecommitdiff
path: root/gerbolyze/tests/test_integration.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-04-02 23:18:03 +0200
committerjaseg <git@jaseg.de>2023-04-02 23:18:03 +0200
commitbe24d0368fca0041082793d3712b6a758b628fde (patch)
tree21ae9265f28beef082683e0cbf5d55c2b1f6a18c /gerbolyze/tests/test_integration.py
parente1c40e8c80fae86239b67225ca6721266129e8de (diff)
downloadgerbolyze-be24d0368fca0041082793d3712b6a758b628fde.tar.gz
gerbolyze-be24d0368fca0041082793d3712b6a758b628fde.tar.bz2
gerbolyze-be24d0368fca0041082793d3712b6a758b628fde.zip
Don't apply dilation scripts in convert, add paste test
Diffstat (limited to 'gerbolyze/tests/test_integration.py')
-rw-r--r--gerbolyze/tests/test_integration.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/gerbolyze/tests/test_integration.py b/gerbolyze/tests/test_integration.py
index cf59eed..3048187 100644
--- a/gerbolyze/tests/test_integration.py
+++ b/gerbolyze/tests/test_integration.py
@@ -16,6 +16,7 @@
#
import sys
+import math
import subprocess
import tempfile
from pathlib import Path
@@ -66,6 +67,41 @@ def test_template(reference):
run_command('python3', '-m', 'gerbolyze', 'template', '--top', '--force', infile, out_svg.name)
run_command('python3', '-m', 'gerbolyze', 'template', '--bottom', '--force', '--vector', infile, out_svg.name)
+def test_paste():
+ in_gerbers = reference_path('layers-gerber')
+ top_overlay = reference_path('tpl-top.svg')
+ bottom_overlay = reference_path('tpl-bottom.svg')
+ with tempfile.TemporaryDirectory() as intermediate_gerbers,\
+ tempfile.TemporaryDirectory() as output_gerbers:
+ run_command('python3', '-m', 'gerbolyze', 'paste', '--no-subtract', in_gerbers, top_overlay, intermediate_gerbers)
+ run_command('python3', '-m', 'gerbolyze', 'paste', '--no-subtract', intermediate_gerbers, bottom_overlay, output_gerbers)
+
+ stack_old = gerbonara.layers.LayerStack.open(in_gerbers)
+ stack_new = gerbonara.layers.LayerStack.open(output_gerbers)
+
+ for (side, use), layer_old in stack_old.graphic_layers.items():
+ if use == 'outline':
+ continue
+ layer_new = stack_new[side, use]
+
+ bbox_old = layer_old.bounding_box(gerbonara.utils.MM)
+ bbox_new = layer_new.bounding_box(gerbonara.utils.MM)
+ print(side, use, bbox_old, bbox_new)
+ print(' -> ',
+ bbox_new[0][0]-bbox_old[0][0], bbox_new[0][1]-bbox_old[0][1],
+ bbox_new[1][0]-bbox_old[1][0], bbox_new[1][1]-bbox_old[1][1])
+ print(' -> ',
+ bbox_new[0][0], bbox_new[0][1],
+ bbox_new[1][0], bbox_new[1][1])
+ print(' old ->', layer_old)
+ print(' new ->', layer_new)
+
+ e = 0.8
+ assert math.isclose(bbox_new[0][0], bbox_old[0][0]-e, abs_tol=0.1)
+ assert math.isclose(bbox_new[0][1], bbox_old[0][1]-e, abs_tol=0.1)
+ assert math.isclose(bbox_new[1][0], bbox_old[1][0]+e, abs_tol=0.1)
+ assert math.isclose(bbox_new[1][1], bbox_old[1][1]+e, abs_tol=0.1)
+
def test_convert_layers():
infile = reference_path('layers.svg')
with tempfile.TemporaryDirectory() as out_dir: