Option to override user's defaults. Needed for unit testing.
This commit is contained in:
@@ -1728,7 +1728,9 @@ class App(QtCore.QObject):
|
|||||||
|
|
||||||
:type app_obj_: App
|
:type app_obj_: App
|
||||||
"""
|
"""
|
||||||
assert isinstance(app_obj_, App)
|
assert isinstance(app_obj_, App), \
|
||||||
|
"Initializer expected App, got %s" % type(app_obj_)
|
||||||
|
|
||||||
self.progress.emit(10)
|
self.progress.emit(10)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -2151,7 +2153,8 @@ class App(QtCore.QObject):
|
|||||||
|
|
||||||
# Object initialization function for app.new_object()
|
# Object initialization function for app.new_object()
|
||||||
def job_init(job_obj, app_obj):
|
def job_init(job_obj, app_obj):
|
||||||
assert isinstance(job_obj, FlatCAMCNCjob)
|
assert isinstance(job_obj, FlatCAMCNCjob), \
|
||||||
|
"Initializer expected FlatCAMCNCjob, got %s" % type(job_obj)
|
||||||
|
|
||||||
job_obj.z_cut = kwa["drillz"]
|
job_obj.z_cut = kwa["drillz"]
|
||||||
job_obj.z_move = kwa["travelz"]
|
job_obj.z_move = kwa["travelz"]
|
||||||
@@ -2196,7 +2199,8 @@ class App(QtCore.QObject):
|
|||||||
if obj is None:
|
if obj is None:
|
||||||
return "Object not found: %s" % name
|
return "Object not found: %s" % name
|
||||||
|
|
||||||
assert isinstance(obj, FlatCAMExcellon)
|
assert isinstance(obj, FlatCAMExcellon), \
|
||||||
|
"Expected a FlatCAMExcellon object, got %s" % type(obj)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
success, msg = obj.generate_milling(**kwa)
|
success, msg = obj.generate_milling(**kwa)
|
||||||
@@ -2225,7 +2229,8 @@ class App(QtCore.QObject):
|
|||||||
if obj is None:
|
if obj is None:
|
||||||
return "Object not found: %s" % obj_name
|
return "Object not found: %s" % obj_name
|
||||||
|
|
||||||
assert isinstance(obj, Geometry)
|
assert isinstance(obj, Geometry), \
|
||||||
|
"Expected a Geometry, got %s" % type(obj)
|
||||||
|
|
||||||
obj_exteriors = obj.get_exteriors()
|
obj_exteriors = obj.get_exteriors()
|
||||||
|
|
||||||
@@ -2261,7 +2266,8 @@ class App(QtCore.QObject):
|
|||||||
if obj is None:
|
if obj is None:
|
||||||
return "Object not found: %s" % obj_name
|
return "Object not found: %s" % obj_name
|
||||||
|
|
||||||
assert isinstance(obj, Geometry)
|
assert isinstance(obj, Geometry), \
|
||||||
|
"Expected a Geometry, got %s" % type(obj)
|
||||||
|
|
||||||
obj_interiors = obj.get_interiors()
|
obj_interiors = obj.get_interiors()
|
||||||
|
|
||||||
@@ -2301,7 +2307,8 @@ class App(QtCore.QObject):
|
|||||||
if obj is None:
|
if obj is None:
|
||||||
return "Object not found: %s" % name
|
return "Object not found: %s" % name
|
||||||
|
|
||||||
assert isinstance(obj, FlatCAMGerber)
|
assert isinstance(obj, FlatCAMGerber), \
|
||||||
|
"Expected a FlatCAMGerber, got %s" % type(obj)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
obj.isolate(**kwa)
|
obj.isolate(**kwa)
|
||||||
|
|||||||
@@ -574,7 +574,9 @@ class FCCopy(FCMove):
|
|||||||
########################
|
########################
|
||||||
class FlatCAMDraw(QtCore.QObject):
|
class FlatCAMDraw(QtCore.QObject):
|
||||||
def __init__(self, app, disabled=False):
|
def __init__(self, app, disabled=False):
|
||||||
assert isinstance(app, FlatCAMApp.App)
|
assert isinstance(app, FlatCAMApp.App), \
|
||||||
|
"Expected the app to be a FlatCAMApp.App, got %s" % type(app)
|
||||||
|
|
||||||
super(FlatCAMDraw, self).__init__()
|
super(FlatCAMDraw, self).__init__()
|
||||||
|
|
||||||
self.app = app
|
self.app = app
|
||||||
@@ -767,9 +769,15 @@ class FlatCAMDraw(QtCore.QObject):
|
|||||||
self.add_shape(subshape)
|
self.add_shape(subshape)
|
||||||
return
|
return
|
||||||
|
|
||||||
assert isinstance(shape, DrawToolShape)
|
assert isinstance(shape, DrawToolShape), \
|
||||||
assert shape.geo is not None
|
"Expected a DrawToolShape, got %s" % type(shape)
|
||||||
assert (isinstance(shape.geo, list) and len(shape.geo) > 0) or not isinstance(shape.geo, list)
|
|
||||||
|
assert shape.geo is not None, \
|
||||||
|
"Shape object has empty geometry (None)"
|
||||||
|
|
||||||
|
assert (isinstance(shape.geo, list) and len(shape.geo) > 0) or \
|
||||||
|
not isinstance(shape.geo, list), \
|
||||||
|
"Shape objects has empty geometry ([])"
|
||||||
|
|
||||||
if isinstance(shape, DrawToolUtilityShape):
|
if isinstance(shape, DrawToolUtilityShape):
|
||||||
self.utility.append(shape)
|
self.utility.append(shape)
|
||||||
@@ -825,7 +833,8 @@ class FlatCAMDraw(QtCore.QObject):
|
|||||||
:param fcgeometry: FlatCAMGeometry
|
:param fcgeometry: FlatCAMGeometry
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
assert isinstance(fcgeometry, Geometry)
|
assert isinstance(fcgeometry, Geometry), \
|
||||||
|
"Expected a Geometry, got %s" % type(fcgeometry)
|
||||||
|
|
||||||
self.deactivate()
|
self.deactivate()
|
||||||
|
|
||||||
|
|||||||
@@ -670,7 +670,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
|
|||||||
"spindlespeed": self.ui.spindlespeed_entry
|
"spindlespeed": self.ui.spindlespeed_entry
|
||||||
})
|
})
|
||||||
|
|
||||||
assert isinstance(self.ui, ExcellonObjectUI)
|
assert isinstance(self.ui, ExcellonObjectUI), \
|
||||||
|
"Expected a ExcellonObjectUI, got %s" % type(self.ui)
|
||||||
self.ui.plot_cb.stateChanged.connect(self.on_plot_cb_click)
|
self.ui.plot_cb.stateChanged.connect(self.on_plot_cb_click)
|
||||||
self.ui.solid_cb.stateChanged.connect(self.on_solid_cb_click)
|
self.ui.solid_cb.stateChanged.connect(self.on_solid_cb_click)
|
||||||
self.ui.generate_cnc_button.clicked.connect(self.on_create_cncjob_button_click)
|
self.ui.generate_cnc_button.clicked.connect(self.on_create_cncjob_button_click)
|
||||||
@@ -718,7 +719,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
|
|||||||
return False, "Error: Milling tool is larger than hole."
|
return False, "Error: Milling tool is larger than hole."
|
||||||
|
|
||||||
def geo_init(geo_obj, app_obj):
|
def geo_init(geo_obj, app_obj):
|
||||||
assert isinstance(geo_obj, FlatCAMGeometry)
|
assert isinstance(geo_obj, FlatCAMGeometry), \
|
||||||
|
"Initializer expected a FlatCAMGeometry, got %s" % type(geo_obj)
|
||||||
app_obj.progress.emit(20)
|
app_obj.progress.emit(20)
|
||||||
|
|
||||||
geo_obj.solid_geometry = []
|
geo_obj.solid_geometry = []
|
||||||
@@ -763,7 +765,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
|
|||||||
|
|
||||||
# Object initialization function for app.new_object()
|
# Object initialization function for app.new_object()
|
||||||
def job_init(job_obj, app_obj):
|
def job_init(job_obj, app_obj):
|
||||||
assert isinstance(job_obj, FlatCAMCNCjob)
|
assert isinstance(job_obj, FlatCAMCNCjob), \
|
||||||
|
"Initializer expected a FlatCAMCNCjob, got %s" % type(job_obj)
|
||||||
|
|
||||||
app_obj.progress.emit(20)
|
app_obj.progress.emit(20)
|
||||||
job_obj.z_cut = self.options["drillz"]
|
job_obj.z_cut = self.options["drillz"]
|
||||||
@@ -888,7 +891,8 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
|
|||||||
|
|
||||||
FlatCAMApp.App.log.debug("FlatCAMCNCJob.set_ui()")
|
FlatCAMApp.App.log.debug("FlatCAMCNCJob.set_ui()")
|
||||||
|
|
||||||
assert isinstance(self.ui, CNCObjectUI)
|
assert isinstance(self.ui, CNCObjectUI), \
|
||||||
|
"Expected a CNCObjectUI, got %s" % type(self.ui)
|
||||||
|
|
||||||
self.form_fields.update({
|
self.form_fields.update({
|
||||||
"plot": self.ui.plot_cb,
|
"plot": self.ui.plot_cb,
|
||||||
@@ -1027,7 +1031,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
|||||||
|
|
||||||
FlatCAMApp.App.log.debug("FlatCAMGeometry.set_ui()")
|
FlatCAMApp.App.log.debug("FlatCAMGeometry.set_ui()")
|
||||||
|
|
||||||
assert isinstance(self.ui, GeometryObjectUI)
|
assert isinstance(self.ui, GeometryObjectUI), \
|
||||||
|
"Expected a GeometryObjectUI, got %s" % type(self.ui)
|
||||||
|
|
||||||
self.form_fields.update({
|
self.form_fields.update({
|
||||||
"plot": self.ui.plot_cb,
|
"plot": self.ui.plot_cb,
|
||||||
@@ -1084,7 +1089,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
|||||||
|
|
||||||
# Initializes the new geometry object
|
# Initializes the new geometry object
|
||||||
def gen_paintarea(geo_obj, app_obj):
|
def gen_paintarea(geo_obj, app_obj):
|
||||||
assert isinstance(geo_obj, FlatCAMGeometry)
|
assert isinstance(geo_obj, FlatCAMGeometry), \
|
||||||
|
"Initializer expected a FlatCAMGeometry, got %s" % type(geo_obj)
|
||||||
#assert isinstance(app_obj, App)
|
#assert isinstance(app_obj, App)
|
||||||
|
|
||||||
if self.options["paintmethod"] == "seed":
|
if self.options["paintmethod"] == "seed":
|
||||||
@@ -1156,7 +1162,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
|||||||
# Object initialization function for app.new_object()
|
# Object initialization function for app.new_object()
|
||||||
# RUNNING ON SEPARATE THREAD!
|
# RUNNING ON SEPARATE THREAD!
|
||||||
def job_init(job_obj, app_obj):
|
def job_init(job_obj, app_obj):
|
||||||
assert isinstance(job_obj, FlatCAMCNCjob)
|
assert isinstance(job_obj, FlatCAMCNCjob), \
|
||||||
|
"Initializer expected a FlatCAMCNCjob, got %s" % type(job_obj)
|
||||||
|
|
||||||
# Propagate options
|
# Propagate options
|
||||||
job_obj.options["tooldia"] = tooldia
|
job_obj.options["tooldia"] = tooldia
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,8 @@ class FCVisibleProcessContainer(QtCore.QObject, FCProcessContainer):
|
|||||||
something_changed = QtCore.pyqtSignal()
|
something_changed = QtCore.pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, view):
|
def __init__(self, view):
|
||||||
assert isinstance(view, FlatCAMActivityView)
|
assert isinstance(view, FlatCAMActivityView), \
|
||||||
|
"Expected a FlatCAMActivityView, got %s" % type(view)
|
||||||
|
|
||||||
FCProcessContainer.__init__(self)
|
FCProcessContainer.__init__(self)
|
||||||
QtCore.QObject.__init__(self)
|
QtCore.QObject.__init__(self)
|
||||||
|
|||||||
@@ -249,7 +249,8 @@ class VerticalScrollArea(QtGui.QScrollArea):
|
|||||||
class OptionalInputSection():
|
class OptionalInputSection():
|
||||||
|
|
||||||
def __init__(self, cb, optinputs):
|
def __init__(self, cb, optinputs):
|
||||||
assert isinstance(cb, FCCheckBox)
|
assert isinstance(cb, FCCheckBox), \
|
||||||
|
"Expected an FCCheckBox, got %s" % type(cb)
|
||||||
|
|
||||||
self.cb = cb
|
self.cb = cb
|
||||||
self.optinputs = optinputs
|
self.optinputs = optinputs
|
||||||
|
|||||||
@@ -379,7 +379,8 @@ class Geometry(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
log.debug("camlib.clear_polygon()")
|
log.debug("camlib.clear_polygon()")
|
||||||
assert type(polygon) == Polygon or type(polygon) == MultiPolygon
|
assert type(polygon) == Polygon or type(polygon) == MultiPolygon, \
|
||||||
|
"Expected a Polygon or MultiPolygon, got %s" % type(polygon)
|
||||||
|
|
||||||
## The toolpaths
|
## The toolpaths
|
||||||
# Index first and last points in paths
|
# Index first and last points in paths
|
||||||
@@ -2717,7 +2718,8 @@ class CNCjob(Geometry):
|
|||||||
:param tolerance:
|
:param tolerance:
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
assert isinstance(geometry, Geometry)
|
assert isinstance(geometry, Geometry), \
|
||||||
|
"Expected a Geometry, got %s" % type(geometry)
|
||||||
log.debug("generate_from_geometry_2()")
|
log.debug("generate_from_geometry_2()")
|
||||||
|
|
||||||
## Flatten the geometry
|
## Flatten the geometry
|
||||||
|
|||||||
Reference in New Issue
Block a user