implement tests for TCL commands

This commit is contained in:
sopak 2016-04-25 00:36:58 +02:00
parent 56ba233fd6
commit 7d465f0814
7 changed files with 92 additions and 5 deletions

View File

@ -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 *

View File

@ -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)))

View File

@ -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)))

View File

@ -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

View File

@ -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)))

View File

@ -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)))

View File

@ -3,7 +3,7 @@ from FlatCAMObj import FlatCAMGerber
def test_open_gerber(self):
"""
Test open gerber project
Test open gerber file
:param self:
:return:
"""