From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- ...46547012e-17__--orientation-points-count__3.out | 41 +++ ...codetools__06eec9617e749f35cb949d850415f68d.out | 30 +++ ...codetools__2bf3b298fa730dafb8c6fd51921078f0.out | 40 +++ ...codetools__4a9fb751baf0533eadd4d394957c966d.out | 0 .../tests/data/svg/default-inkscape-SVG.svg | 37 +++ .../other/gcodetools/tests/data/svg/shapes.svg | 284 +++++++++++++++++++++ .../other/gcodetools/tests/dev_requirements.txt | 11 + .../other/gcodetools/tests/test_gcodetools.py | 65 +++++ .../other/gcodetools/tests/test_inkex_inx.py | 114 +++++++++ 9 files changed, 622 insertions(+) create mode 100644 share/extensions/other/gcodetools/tests/data/refs/gcodetools__--active-tab__orientation__--Zsurface__0__00000000000001e-5__--Zdepth__-9__71445146547012e-17__--orientation-points-count__3.out create mode 100644 share/extensions/other/gcodetools/tests/data/refs/gcodetools__06eec9617e749f35cb949d850415f68d.out create mode 100644 share/extensions/other/gcodetools/tests/data/refs/gcodetools__2bf3b298fa730dafb8c6fd51921078f0.out create mode 100644 share/extensions/other/gcodetools/tests/data/refs/gcodetools__4a9fb751baf0533eadd4d394957c966d.out create mode 100644 share/extensions/other/gcodetools/tests/data/svg/default-inkscape-SVG.svg create mode 100644 share/extensions/other/gcodetools/tests/data/svg/shapes.svg create mode 100644 share/extensions/other/gcodetools/tests/dev_requirements.txt create mode 100644 share/extensions/other/gcodetools/tests/test_gcodetools.py create mode 100644 share/extensions/other/gcodetools/tests/test_inkex_inx.py (limited to 'share/extensions/other/gcodetools/tests') diff --git a/share/extensions/other/gcodetools/tests/data/refs/gcodetools__--active-tab__orientation__--Zsurface__0__00000000000001e-5__--Zdepth__-9__71445146547012e-17__--orientation-points-count__3.out b/share/extensions/other/gcodetools/tests/data/refs/gcodetools__--active-tab__orientation__--Zsurface__0__00000000000001e-5__--Zdepth__-9__71445146547012e-17__--orientation-points-count__3.out new file mode 100644 index 0000000..61a62cc --- /dev/null +++ b/share/extensions/other/gcodetools/tests/data/refs/gcodetools__--active-tab__orientation__--Zsurface__0__00000000000001e-5__--Zdepth__-9__71445146547012e-17__--orientation-points-count__3.out @@ -0,0 +1,41 @@ + + + + + + + + + + + + format: png +dpi: 96 +layout-disposition: bg-el-norepeat +layout-position-anchor: tl + + (0.0; 0.0; 0.00000)(100.0; 0.0; -0.00000)(0.0; 100.0; 0.0) + + + + + + + + + + + Hello World + flow text which wraps UPPER + Multi linetextFOO + + Grouped + text + + + + + + + \ No newline at end of file diff --git a/share/extensions/other/gcodetools/tests/data/refs/gcodetools__06eec9617e749f35cb949d850415f68d.out b/share/extensions/other/gcodetools/tests/data/refs/gcodetools__06eec9617e749f35cb949d850415f68d.out new file mode 100644 index 0000000..e2ae9a3 --- /dev/null +++ b/share/extensions/other/gcodetools/tests/data/refs/gcodetools__06eec9617e749f35cb949d850415f68d.out @@ -0,0 +1,30 @@ +% +(Header) +(Generated by gcodetools from Inkscape.) +(Using default header. To add your own header create file "header" in the output dir.) +M3 +(Header end.) +G21 (All units in mm) + +(Start cutting path id: p1) +(Change tool to Default tool) + +G00 Z5.000000 +G00 X100.000000 Y400.000000 + +G01 Z-0.125000 F100.0(Penetrate) +G01 X200.000000 Y300.000000 Z-0.125000 F400.000000 +G01 X300.000000 Y400.000000 Z-0.125000 +G01 X400.000000 Y300.000000 Z-0.125000 +G00 Z5.000000 + +(End cutting path id: p1) + + +(Footer) +M5 +G00 X0.0000 Y0.0000 +M2 +(Using default footer. To add your own footer create file "footer" in the output dir.) +(end) +% \ No newline at end of file diff --git a/share/extensions/other/gcodetools/tests/data/refs/gcodetools__2bf3b298fa730dafb8c6fd51921078f0.out b/share/extensions/other/gcodetools/tests/data/refs/gcodetools__2bf3b298fa730dafb8c6fd51921078f0.out new file mode 100644 index 0000000..8694e43 --- /dev/null +++ b/share/extensions/other/gcodetools/tests/data/refs/gcodetools__2bf3b298fa730dafb8c6fd51921078f0.out @@ -0,0 +1,40 @@ +% +(Header) +(Generated by gcodetools from Inkscape.) +(Using default header. To add your own header create file "header" in the output dir.) +M3 +(Header end.) +G21 (All units in mm) +(Change tool to Default tool) + +G01 Z 16.000000 F 800.000000 +G01 X 100.000000 Z 16.000000 F 800.000000 +G01 X 100.000000 Z 16.000000 F 800.000000 +G01 X 100.000000 Z 401.000000 F 800.000000 +G01 X 200.000000 Z 301.000000 F 800.000000 +G01 X 300.000000 Z 401.000000 F 800.000000 +G01 X 400.000000 Z 301.000000 F 800.000000 +G01 X 400.000000 Z 16.000000 F 800.000000 +G01 X 100.000000 Z 16.000000 F 800.000000 + +(Fine cutting start) +(Calculating fine cut using Move path) + +(Fine cut 1-th cicle start) +G01 X 100.000000 Z 16.000000 F 800.000000 +G01 X 100.000000 Z 401.000000 F 800.000000 +G01 X 100.000000 Z 400.000000 F 800.000000 +G01 X 100.000000 Z 400.000000 F 800.000000 +G01 X 200.000000 Z 300.000000 F 800.000000 +G01 X 300.000000 Z 400.000000 F 800.000000 +G01 X 400.000000 Z 300.000000 F 800.000000 +G01 Z 16.000000 F 800.000000 +G01 X 100.000000 Z 16.000000 F 800.000000 + +(Footer) +M5 +G00 X0.0000 Y0.0000 +M2 +(Using default footer. To add your own footer create file "footer" in the output dir.) +(end) +% \ No newline at end of file diff --git a/share/extensions/other/gcodetools/tests/data/refs/gcodetools__4a9fb751baf0533eadd4d394957c966d.out b/share/extensions/other/gcodetools/tests/data/refs/gcodetools__4a9fb751baf0533eadd4d394957c966d.out new file mode 100644 index 0000000..e69de29 diff --git a/share/extensions/other/gcodetools/tests/data/svg/default-inkscape-SVG.svg b/share/extensions/other/gcodetools/tests/data/svg/default-inkscape-SVG.svg new file mode 100644 index 0000000..259e13c --- /dev/null +++ b/share/extensions/other/gcodetools/tests/data/svg/default-inkscape-SVG.svg @@ -0,0 +1,37 @@ + + + + + + + + + image/svg+xml + + + + + + diff --git a/share/extensions/other/gcodetools/tests/data/svg/shapes.svg b/share/extensions/other/gcodetools/tests/data/svg/shapes.svg new file mode 100644 index 0000000..eb9caed --- /dev/null +++ b/share/extensions/other/gcodetools/tests/data/svg/shapes.svg @@ -0,0 +1,284 @@ + + + + + + + + + + + + + + + format: png +dpi: 96 +layout-disposition: bg-el-norepeat +layout-position-anchor: tl + + + + + + + + + + + + + Hello World + flow text which wraps UPPER + Multi linetextFOO + + Grouped + text + + + + + + + diff --git a/share/extensions/other/gcodetools/tests/dev_requirements.txt b/share/extensions/other/gcodetools/tests/dev_requirements.txt new file mode 100644 index 0000000..0e358d9 --- /dev/null +++ b/share/extensions/other/gcodetools/tests/dev_requirements.txt @@ -0,0 +1,11 @@ +# Dev Requirements +pytest +pytest-cov + +# Code requirements +typing +lxml +numpy +scour +pyserial +cssselect \ No newline at end of file diff --git a/share/extensions/other/gcodetools/tests/test_gcodetools.py b/share/extensions/other/gcodetools/tests/test_gcodetools.py new file mode 100644 index 0000000..0575729 --- /dev/null +++ b/share/extensions/other/gcodetools/tests/test_gcodetools.py @@ -0,0 +1,65 @@ +# coding=utf-8 + +import sys +import os + +from gcodetools import Gcodetools +from inkex.tester import ComparisonMixin, InkscapeExtensionTestMixin, TestCase +from inkex.tester.filters import CompareOrderIndependentBytes + +SETTINGS = ( + '--id=p1', '--max-area-curves=100', + '--area-inkscape-radius=-10', '--area-tool-overlap=0', + '--area-fill-angle=0', '--area-fill-shift=0', '--area-fill-method=0', + '--area-fill-method=0', '--area-find-artefacts-diameter=5', + '--area-find-artefacts-action=mark with an arrow', + '--biarc-tolerance=1', '--biarc-max-split-depth=4', + '--path-to-gcode-order=subpath by subpath', + '--path-to-gcode-depth-function=d', + '--path-to-gcode-sort-paths=false', '--Zscale=1', '--Zoffset=0', + '--auto_select_paths=true', '--min-arc-radius=0.05000000074505806', + '--comment-gcode-from-properties=false', '--create-log=false', + '--add-numeric-suffix-to-filename=false', '--Zsafe=5', + '--unit=G21 (All units in mm)', '--postprocessor= ', +) +FILESET = SETTINGS + ('--directory=/home', '--filename=output.ngc',) + +class TestGcodetoolsBasic(ComparisonMixin, InkscapeExtensionTestMixin, TestCase): + stderr_protect = False + effect_class = Gcodetools + comparisons = [ + FILESET + ('--active-tab="area_fill"',), + FILESET + ('--active-tab="area"',), + FILESET + ('--active-tab="area_artefacts"',), + FILESET + ('--active-tab="dxfpoints"',), + FILESET + ('--active-tab="orientation"',), + FILESET + ('--active-tab="tools_library"',), + FILESET + ('--active-tab="lathe_modify_path"',), + FILESET + ('--active-tab="offset"',), + FILESET + ('--active-tab="plasma-prepare-path"',), + ] + compare_filters = [CompareOrderIndependentBytes()] + compare_file_extension = 'dxf' + + def test_all_comparisons(self): + """ + gcodetools tries to write to a folder and filename specified + on the command line, this needs to be handled carefully. + """ + for tab in ( + ('--active-tab="path-to-gcode"',), + #('--active-tab="engraving"',), + #('--active-tab="graffiti"',), + ('--active-tab="lathe"',), + ): + args = SETTINGS + tab + ( + '--directory={}'.format(self.tempdir), + '--filename=output.ngc', + ) + outfile = os.path.join(self.tempdir, 'output.ngc') + self.assertCompare(self.compare_file, None, args, 'output.ngc') + +class TestGcodeToolsOrientationScientific(ComparisonMixin, TestCase): + effect_class = Gcodetools + compare_file = "svg/shapes.svg" + comparisons = [("--active-tab=orientation", "--Zsurface=0.00000000000001e-5", "--Zdepth=-9.71445146547012e-17", "--orientation-points-count=3")] diff --git a/share/extensions/other/gcodetools/tests/test_inkex_inx.py b/share/extensions/other/gcodetools/tests/test_inkex_inx.py new file mode 100644 index 0000000..211b746 --- /dev/null +++ b/share/extensions/other/gcodetools/tests/test_inkex_inx.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python +# coding=utf-8 +""" +Test elements extra logic from svg xml lxml custom classes. +""" + +import os +from glob import glob + +from inkex.utils import PY3 +from inkex.tester import TestCase +from inkex.tester.inx import InxMixin +from inkex.inx import InxFile + +class InxTestCase(InxMixin, TestCase): + """Test INX files""" + def test_inx_effect(self): + inx = InxFile(""" + + TestOne + org.inkscape.test.inx_one + + all + + + + + + + +""") + self.assertEqual(inx.name, 'TestOne') + self.assertEqual(inx.ident, 'org.inkscape.test.inx_one') + self.assertEqual(inx.slug, 'InxOne') + self.assertEqual(inx.metadata, {'type': 'effect', 'preview': False, 'objects': 'all'}) + self.assertEqual(inx.menu, ['Banana', 'Ice Cream', 'TestOne']) + self.assertEqual(inx.warnings, []) + + def test_inx_output(self): + inx = InxFile(""" + + <_name>TestTwo + org.inkscape.test.inx_two + + .inx + text/xml+inx + Extension (*.inx) + <_filetypetooltip>The extension extension repention suspension. + true + +""") + self.assertEqual(inx.name, 'TestTwo') + self.assertEqual(inx.ident, 'org.inkscape.test.inx_two') + self.assertEqual(inx.metadata, { + 'dataloss': True, + 'extension': '.inx', + 'mimetype': 'text/xml+inx', + 'name': 'Extension (*.inx)', + 'tooltip': 'The extension extension repention suspension.', + 'type': 'output'}) + self.assertEqual(inx.warnings, [ + 'Use of old translation scheme: <_filetypetooltip...>', + 'Use of old translation scheme: <_name...>']) + + def test_inx_input(self): + inx = InxFile(""" + TestThree + org.inkscape.test.inx_three + + .inx + text/xml+inx + Extension (*.inx) + The extension extension repention suspension. + +""") + self.assertEqual(inx.name, 'TestThree') + self.assertEqual(inx.metadata, { + 'extension': '.inx', + 'mimetype': 'text/xml+inx', + 'name': 'Extension (*.inx)', + 'tooltip': 'The extension extension repention suspension.', + 'type': 'input'}) + self.assertEqual(inx.warnings, ['No inx xml prefix.']) + + def test_inx_template(self): + inx = InxFile(""" + TestFour + org.inkscape.test.inx_four + + all + + + Magic Number + Donky Oaty + Something might happen. + 2070-01-01 + word food strawberry + +""") + self.assertEqual(inx.name, 'TestFour') + self.assertEqual(inx.metadata, {'author': 'Donky Oaty', 'desc': 'Something might happen.', 'type': 'template'}) + self.assertEqual(inx.warnings, ['No inx xml prefix.']) + + + def test_inx_files(self): + """Get all inx files and test each of them""" + if not PY3: + self.skipTest("No INX testing in python2") + return + for inx_file in glob(os.path.join(self._testdir(), '..', '*.inx')): + self.assertInxIsGood(inx_file) -- cgit v1.2.3