diff --git a/tests/tclCommands/__init__.py b/tests/tclCommands/__init__.py index 0829032f..2d1ed5cd 100644 --- a/tests/tclCommands/__init__.py +++ b/tests/tclCommands/__init__.py @@ -4,14 +4,15 @@ import sys # allowed command tests (please append them alphabetically ordered) from test_TclCommandAddPolygon import * from test_TclCommandAddPolyline import * -# from test_TclCommandCncjob import * -# from test_TclCommandDrillcncjob import * -# from test_TclCommandExportGcode import * +from test_TclCommandCncjob import * +from test_TclCommandDrillcncjob import * +from test_TclCommandExportGcode import * from test_TclCommandExteriors import * from test_TclCommandImportSvg import * from test_TclCommandInteriors import * from test_TclCommandIsolate import * from test_TclCommandNew import * from test_TclCommandNewGeometry import * +from test_TclCommandOpenExcellon import * from test_TclCommandOpenGerber import * from test_TclCommandPaintPolygon import * diff --git a/tests/tclCommands/test_TclCommandCncjob.py b/tests/tclCommands/test_TclCommandCncjob.py new file mode 100644 index 00000000..cdd8e79f --- /dev/null +++ b/tests/tclCommands/test_TclCommandCncjob.py @@ -0,0 +1,17 @@ +from FlatCAMObj import FlatCAMGerber, FlatCAMGeometry, FlatCAMObj +from test_TclCommandIsolate import * + +def test_cncjob(self): + """ + Test cncjob + :param self: + :return: + """ + + # reuse isolate tests + test_isolate(self) + + self.fc.exec_command_test('cncjob %s_iso -tooldia 0.5 -z_cut 0.05 -z_move 3 -feedrate 300' % self.gerber_top_name) + cam_top_obj = self.fc.collection.get_by_name(self.gerber_top_name + '_iso_cnc') + self.assertTrue(isinstance(cam_top_obj, FlatCAMObj), "Expected FlatCAMObj, instead, %s is %s" + % (self.gerber_top_name + '_iso_cnc', type(cam_top_obj))) \ No newline at end of file diff --git a/tests/tclCommands/test_TclCommandDrillcncjob.py b/tests/tclCommands/test_TclCommandDrillcncjob.py new file mode 100644 index 00000000..78326d24 --- /dev/null +++ b/tests/tclCommands/test_TclCommandDrillcncjob.py @@ -0,0 +1,18 @@ +from FlatCAMObj import FlatCAMObj +from test_TclCommandOpenExcellon import * + + +def test_drillcncjob(self): + """ + Test cncjob + :param self: + :return: + """ + # reuse open excellontests + test_open_excellon(self) + + self.fc.exec_command_test('drillcncjob %s -tools all -drillz 0.5 -travelz 3 -feedrate 300' + % self.excellon_name) + cam_top_obj = self.fc.collection.get_by_name(self.excellon_name + '_cnc') + self.assertTrue(isinstance(cam_top_obj, FlatCAMObj), "Expected FlatCAMObj, instead, %s is %s" + % (self.excellon_name + '_cnc', type(cam_top_obj))) diff --git a/tests/tclCommands/test_TclCommandExportGcode.py b/tests/tclCommands/test_TclCommandExportGcode.py new file mode 100644 index 00000000..102e6e36 --- /dev/null +++ b/tests/tclCommands/test_TclCommandExportGcode.py @@ -0,0 +1,33 @@ +import os +import tempfile + +from test_TclCommandCncjob import * +from test_TclCommandDrillcncjob import * + + +def test_export_gcodecncjob(self): + """ + Test cncjob + :param self: + :return: + """ + + # reuse tests + test_cncjob(self) + test_drillcncjob(self) + + with tempfile.NamedTemporaryFile(prefix='unittest.', suffix="." + self.excellon_name + '.gcode', delete=True)\ + as tmp_file: + output_filename = tmp_file.name + self.fc.exec_command_test('write_gcode "%s" "%s"' % (self.excellon_name + '_cnc', output_filename)) + self.assertTrue(os.path.isfile(output_filename)) + os.remove(output_filename) + + with tempfile.NamedTemporaryFile(prefix='unittest.', suffix="." + self.gerber_top_name + '.gcode', delete=True)\ + as tmp_file: + output_filename = tmp_file.name + self.fc.exec_command_test('write_gcode "%s" "%s"' % (self.gerber_top_name + '_iso_cnc', output_filename)) + self.assertTrue(os.path.isfile(output_filename)) + os.remove(output_filename) + + # TODO check what is inside files , it should be same every time \ No newline at end of file diff --git a/tests/tclCommands/test_TclCommandIsolate.py b/tests/tclCommands/test_TclCommandIsolate.py index 3823d614..e61aa40b 100644 --- a/tests/tclCommands/test_TclCommandIsolate.py +++ b/tests/tclCommands/test_TclCommandIsolate.py @@ -1,4 +1,4 @@ -from FlatCAMObj import FlatCAMGerber +from FlatCAMObj import FlatCAMGerber, FlatCAMGeometry def test_isolate(self): @@ -16,3 +16,6 @@ def test_isolate(self): # isolate traces self.fc.exec_command_test('isolate %s -dia %f' % (self.gerber_top_name, self.engraver_diameter)) + geometry_top_obj = self.fc.collection.get_by_name(self.gerber_top_name+'_iso') + self.assertTrue(isinstance(geometry_top_obj, FlatCAMGeometry), "Expected FlatCAMGeometry, instead, %s is %s" + % (self.gerber_top_name+'_iso', type(geometry_top_obj))) \ No newline at end of file diff --git a/tests/tclCommands/test_TclCommandOpenExcellon.py b/tests/tclCommands/test_TclCommandOpenExcellon.py new file mode 100644 index 00000000..7570ea53 --- /dev/null +++ b/tests/tclCommands/test_TclCommandOpenExcellon.py @@ -0,0 +1,15 @@ +from FlatCAMObj import FlatCAMExcellon + + +def test_open_excellon(self): + """ + Test open excellon file + :param self: + :return: + """ + + self.fc.exec_command_test('open_excellon %s/%s -outname %s' + % (self.gerber_files, self.excellon_filename, self.excellon_name)) + excellon_obj = self.fc.collection.get_by_name(self.excellon_name) + self.assertTrue(isinstance(excellon_obj, FlatCAMExcellon), "Expected FlatCAMExcellon, instead, %s is %s" + % (self.excellon_name, type(excellon_obj))) diff --git a/tests/tclCommands/test_TclCommandOpenGerber.py b/tests/tclCommands/test_TclCommandOpenGerber.py index 1510021d..71d50b0d 100644 --- a/tests/tclCommands/test_TclCommandOpenGerber.py +++ b/tests/tclCommands/test_TclCommandOpenGerber.py @@ -3,7 +3,7 @@ from FlatCAMObj import FlatCAMGerber def test_open_gerber(self): """ - Test open gerber project + Test open gerber file :param self: :return: """