Cleaned up tests for shell. Added test steps for gerber flow.
This commit is contained in:
@@ -29,6 +29,7 @@ from MeasurementTool import Measurement
|
|||||||
from DblSidedTool import DblSidedTool
|
from DblSidedTool import DblSidedTool
|
||||||
import tclCommands
|
import tclCommands
|
||||||
|
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
## App ##
|
## App ##
|
||||||
########################################
|
########################################
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
|
|||||||
"isotooldia": self.ui.iso_tool_dia_entry,
|
"isotooldia": self.ui.iso_tool_dia_entry,
|
||||||
"isopasses": self.ui.iso_width_entry,
|
"isopasses": self.ui.iso_width_entry,
|
||||||
"isooverlap": self.ui.iso_overlap_entry,
|
"isooverlap": self.ui.iso_overlap_entry,
|
||||||
"combine_passes":self.ui.combine_passes_cb,
|
"combine_passes": self.ui.combine_passes_cb,
|
||||||
"cutouttooldia": self.ui.cutout_tooldia_entry,
|
"cutouttooldia": self.ui.cutout_tooldia_entry,
|
||||||
"cutoutmargin": self.ui.cutout_margin_entry,
|
"cutoutmargin": self.ui.cutout_margin_entry,
|
||||||
"cutoutgapsize": self.ui.cutout_gap_entry,
|
"cutoutgapsize": self.ui.cutout_gap_entry,
|
||||||
|
|||||||
@@ -21,15 +21,16 @@ for loader, name, is_pkg in pkgutil.walk_packages(__path__):
|
|||||||
module = loader.find_module(name).load_module(name)
|
module = loader.find_module(name).load_module(name)
|
||||||
__all__.append(name)
|
__all__.append(name)
|
||||||
|
|
||||||
|
|
||||||
def register_all_commands(app, commands):
|
def register_all_commands(app, commands):
|
||||||
"""
|
"""
|
||||||
Static method which register all known commands.
|
Static method which register all known commands.
|
||||||
|
|
||||||
Command should be for now in directory tclCommands and module should start with TCLCommand
|
Command should be for now in directory test_tclCommands and module should start with TCLCommand
|
||||||
Class have to follow same name as module.
|
Class have to follow same name as module.
|
||||||
|
|
||||||
we need import all modules in top section:
|
we need import all modules in top section:
|
||||||
import tclCommands.TclCommandExteriors
|
import test_tclCommands.TclCommandExteriors
|
||||||
at this stage we can include only wanted commands with this, auto loading may be implemented in future
|
at this stage we can include only wanted commands with this, auto loading may be implemented in future
|
||||||
I have no enough knowledge about python's anatomy. Would be nice to include all classes which are descendant etc.
|
I have no enough knowledge about python's anatomy. Would be nice to include all classes which are descendant etc.
|
||||||
|
|
||||||
@@ -38,10 +39,10 @@ def register_all_commands(app, commands):
|
|||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
tcl_modules = {k: v for k, v in sys.modules.items() if k.startswith('tclCommands.TclCommand')}
|
tcl_modules = {k: v for k, v in sys.modules.items() if k.startswith('test_tclCommands.TclCommand')}
|
||||||
|
|
||||||
for key, mod in tcl_modules.items():
|
for key, mod in tcl_modules.items():
|
||||||
if key != 'tclCommands.TclCommand':
|
if key != 'test_tclCommands.TclCommand':
|
||||||
class_name = key.split('.')[1]
|
class_name = key.split('.')[1]
|
||||||
class_type = getattr(mod, class_name)
|
class_type = getattr(mod, class_name)
|
||||||
command_instance = class_type(app)
|
command_instance = class_type(app)
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
from FlatCAMApp import App
|
from FlatCAMApp import App, tclCommands
|
||||||
from FlatCAMObj import FlatCAMGerber, FlatCAMGeometry, FlatCAMCNCjob
|
from FlatCAMObj import FlatCAMGerber, FlatCAMGeometry, FlatCAMCNCjob
|
||||||
from ObjectUI import GerberObjectUI, GeometryObjectUI
|
from ObjectUI import GerberObjectUI, GeometryObjectUI
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
class GerberFlowTestCase(unittest.TestCase):
|
class GerberFlowTestCase(unittest.TestCase):
|
||||||
|
|
||||||
filename = 'simple1.gbr'
|
filename = 'simple1.gbr'
|
||||||
@@ -51,6 +52,36 @@ class GerberFlowTestCase(unittest.TestCase):
|
|||||||
"Expected FlatCAMGerber, instead, %s is %s" %
|
"Expected FlatCAMGerber, instead, %s is %s" %
|
||||||
(gerber_name, type(gerber_obj)))
|
(gerber_name, type(gerber_obj)))
|
||||||
|
|
||||||
|
#----------------------------------------
|
||||||
|
# Object's GUI matches Object's options
|
||||||
|
#----------------------------------------
|
||||||
|
# TODO: Open GUI with double-click on object.
|
||||||
|
# Opens the Object's GUI, populates it.
|
||||||
|
gerber_obj.build_ui()
|
||||||
|
for option, value in gerber_obj.options.iteritems():
|
||||||
|
try:
|
||||||
|
form_field = gerber_obj.form_fields[option]
|
||||||
|
except KeyError:
|
||||||
|
print ("**********************************************************\n"
|
||||||
|
"* WARNING: Option '{}' has no form field\n"
|
||||||
|
"**********************************************************"
|
||||||
|
"".format(option))
|
||||||
|
continue
|
||||||
|
self.assertEqual(value, form_field.get_value(),
|
||||||
|
"Option '{}' == {} but form has {}".format(
|
||||||
|
option, value, form_field.get_value()
|
||||||
|
))
|
||||||
|
|
||||||
|
#--------------------------------------------------
|
||||||
|
# Changes in the GUI should be read in when
|
||||||
|
# running any process. Changing something here.
|
||||||
|
#--------------------------------------------------
|
||||||
|
|
||||||
|
form_field = gerber_obj.form_fields['isotooldia']
|
||||||
|
value = form_field.get_value()
|
||||||
|
form_field.set_value(value * 1.1) # Increase by 10%
|
||||||
|
print "'isotooldia' == {}".format(value)
|
||||||
|
|
||||||
#--------------------------------------------------
|
#--------------------------------------------------
|
||||||
# Create isolation routing using default values
|
# Create isolation routing using default values
|
||||||
# and by clicking on the button.
|
# and by clicking on the button.
|
||||||
@@ -58,11 +89,22 @@ class GerberFlowTestCase(unittest.TestCase):
|
|||||||
# Get the object's GUI and click on "Generate Geometry" under
|
# Get the object's GUI and click on "Generate Geometry" under
|
||||||
# "Isolation Routing"
|
# "Isolation Routing"
|
||||||
assert isinstance(gerber_obj, FlatCAMGerber) # Just for the IDE
|
assert isinstance(gerber_obj, FlatCAMGerber) # Just for the IDE
|
||||||
gerber_obj.build_ui() # Open the object's UI.
|
# Changed: UI has been build already
|
||||||
|
#gerber_obj.build_ui() # Open the object's UI.
|
||||||
ui = gerber_obj.ui
|
ui = gerber_obj.ui
|
||||||
assert isinstance(ui, GerberObjectUI)
|
assert isinstance(ui, GerberObjectUI)
|
||||||
ui.generate_iso_button.click() # Click
|
ui.generate_iso_button.click() # Click
|
||||||
|
|
||||||
|
#---------------------------------------------
|
||||||
|
# Check that GUI has been read in.
|
||||||
|
#---------------------------------------------
|
||||||
|
value = gerber_obj.options['isotooldia']
|
||||||
|
form_value = form_field.get_value()
|
||||||
|
self.assertEqual(value, form_value,
|
||||||
|
"Form value for '{}' == {} was not read into options"
|
||||||
|
"which has {}".format('isotooldia', form_value, value))
|
||||||
|
print "'isotooldia' == {}".format(value)
|
||||||
|
|
||||||
#---------------------------------------------
|
#---------------------------------------------
|
||||||
# Check that only 1 object has been created.
|
# Check that only 1 object has been created.
|
||||||
#---------------------------------------------
|
#---------------------------------------------
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from time import sleep
|
|||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
class TclShellTest(unittest.TestCase):
|
class TclShellTest(unittest.TestCase):
|
||||||
|
|
||||||
svg_files = 'tests/svg'
|
svg_files = 'tests/svg'
|
||||||
@@ -33,28 +34,30 @@ class TclShellTest(unittest.TestCase):
|
|||||||
|
|
||||||
# load test methods to split huge test file into smaller pieces
|
# load test methods to split huge test file into smaller pieces
|
||||||
# reason for this is reuse one test window only,
|
# reason for this is reuse one test window only,
|
||||||
from tests.tclCommands import *
|
|
||||||
|
# CANNOT DO THIS HERE!!!
|
||||||
|
#from tests.test_tclCommands import *
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(self):
|
def setUpClass(cls):
|
||||||
|
|
||||||
self.setup=True
|
cls.setup = True
|
||||||
self.app = QtGui.QApplication(sys.argv)
|
cls.app = QtGui.QApplication(sys.argv)
|
||||||
# Create App, keep app defaults (do not load
|
# Create App, keep app defaults (do not load
|
||||||
# user-defined defaults).
|
# user-defined defaults).
|
||||||
self.fc = App(user_defaults=False)
|
cls.fc = App(user_defaults=False)
|
||||||
self.fc.ui.shell_dock.show()
|
cls.fc.ui.shell_dock.show()
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.fc.exec_command_test('set_sys units MM')
|
self.fc.exec_command_test('set_sys units MM')
|
||||||
self.fc.exec_command_test('new')
|
self.fc.exec_command_test('new')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(self):
|
def tearDownClass(cls):
|
||||||
self.fc.tcl=None
|
cls.fc.tcl = None
|
||||||
self.app.closeAllWindows()
|
cls.app.closeAllWindows()
|
||||||
del self.fc
|
del cls.fc
|
||||||
del self.app
|
del cls.app
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_set_get_units(self):
|
def test_set_get_units(self):
|
||||||
@@ -72,7 +75,6 @@ class TclShellTest(unittest.TestCase):
|
|||||||
units=self.fc.exec_command_test('get_sys units')
|
units=self.fc.exec_command_test('get_sys units')
|
||||||
self.assertEquals(units, "MM")
|
self.assertEquals(units, "MM")
|
||||||
|
|
||||||
|
|
||||||
def test_gerber_flow(self):
|
def test_gerber_flow(self):
|
||||||
|
|
||||||
# open gerber files top, bottom and cutout
|
# open gerber files top, bottom and cutout
|
||||||
|
|||||||
Reference in New Issue
Block a user