CAM: Remove hardcoded style for Tool Number, Fix TestPathToolBitSerializer
Fix issue with toolshapes Renamed fillet to radius Added Tool Type Filter to library Fix units so that they honor user preference Remove the QToolBox widget from the Shape Selector page and combine into a single page. Fix issue with PropertyBag so that CustomPropertyGroups as a string is converted to enum and enums are handled correctly. Update TestPathPropertyBag test for enum changes. Update TestPathToolBitListWidget Update TestPathToolLibrarySerializer to match new LinuxCNC output Fix LinuxCNC export too handle ALL tool types, use user preferences for units, and include all lcnc fields
This commit is contained in:
@@ -25,6 +25,20 @@ import Path.Base.PropertyBag as PathPropertyBag
|
||||
import CAMTests.PathTestUtils as PathTestUtils
|
||||
|
||||
|
||||
def as_group_list(groups):
|
||||
"""Normalize CustomPropertyGroups to a list of strings."""
|
||||
if groups is None:
|
||||
return []
|
||||
if isinstance(groups, (list, tuple)):
|
||||
return list(groups)
|
||||
if isinstance(groups, str):
|
||||
return [groups]
|
||||
try:
|
||||
return list(groups)
|
||||
except Exception:
|
||||
return [str(groups)]
|
||||
|
||||
|
||||
class TestPathPropertyBag(PathTestUtils.PathTestBase):
|
||||
def setUp(self):
|
||||
self.doc = FreeCAD.newDocument("test-property-bag")
|
||||
@@ -37,7 +51,7 @@ class TestPathPropertyBag(PathTestUtils.PathTestBase):
|
||||
bag = PathPropertyBag.Create()
|
||||
self.assertTrue(hasattr(bag, "Proxy"))
|
||||
self.assertEqual(bag.Proxy.getCustomProperties(), [])
|
||||
self.assertEqual(bag.CustomPropertyGroups, [])
|
||||
self.assertEqual(as_group_list(bag.CustomPropertyGroups), [])
|
||||
|
||||
def test01(self):
|
||||
"""adding properties to a PropertyBag is tracked properly"""
|
||||
@@ -48,7 +62,7 @@ class TestPathPropertyBag(PathTestUtils.PathTestBase):
|
||||
bag.Title = "Madame"
|
||||
self.assertEqual(bag.Title, "Madame")
|
||||
self.assertEqual(bag.Proxy.getCustomProperties(), ["Title"])
|
||||
self.assertEqual(bag.CustomPropertyGroups, ["Address"])
|
||||
self.assertEqual(as_group_list(bag.CustomPropertyGroups), ["Address"])
|
||||
|
||||
def test02(self):
|
||||
"""refreshCustomPropertyGroups deletes empty groups"""
|
||||
@@ -59,7 +73,7 @@ class TestPathPropertyBag(PathTestUtils.PathTestBase):
|
||||
bag.removeProperty("Title")
|
||||
proxy.refreshCustomPropertyGroups()
|
||||
self.assertEqual(bag.Proxy.getCustomProperties(), [])
|
||||
self.assertEqual(bag.CustomPropertyGroups, [])
|
||||
self.assertEqual(as_group_list(bag.CustomPropertyGroups), [])
|
||||
|
||||
def test03(self):
|
||||
"""refreshCustomPropertyGroups does not delete non-empty groups"""
|
||||
@@ -72,4 +86,4 @@ class TestPathPropertyBag(PathTestUtils.PathTestBase):
|
||||
bag.removeProperty("Gender")
|
||||
proxy.refreshCustomPropertyGroups()
|
||||
self.assertEqual(bag.Proxy.getCustomProperties(), ["Title"])
|
||||
self.assertEqual(bag.CustomPropertyGroups, ["Address"])
|
||||
self.assertEqual(as_group_list(bag.CustomPropertyGroups), ["Address"])
|
||||
|
||||
@@ -55,7 +55,7 @@ class TestToolBitListWidget(PathTestWithAssets):
|
||||
self.assertEqual(cell_widget.tool_no, str(tool_no))
|
||||
self.assertEqual(cell_widget.upper_text, toolbit.label)
|
||||
# Assuming the 5mm_Endmill asset has a shape named 'Endmill'
|
||||
self.assertEqual(cell_widget.lower_text, "5 mm 4-flute endmill, 30 mm cutting edge")
|
||||
self.assertEqual(cell_widget.lower_text, "5.00 mm 4-flute endmill, 30.00 mm cutting edge")
|
||||
|
||||
# Verify URI is stored in item data
|
||||
stored_uri = item.data(ToolBitUriRole)
|
||||
|
||||
@@ -149,7 +149,7 @@ class TestYamlToolBitSerializer(_BaseToolBitSerializerTestCase):
|
||||
self.assertEqual(data.get("shape"), "endmill.fcstd")
|
||||
self.assertEqual(data.get("shape-type"), "Endmill")
|
||||
self.assertEqual(data.get("parameter", {}).get("Diameter"), "4.12 mm")
|
||||
self.assertEqual(data.get("parameter", {}).get("Length"), "15.0 mm")
|
||||
self.assertEqual(data.get("parameter", {}).get("Length"), "15.00 mm")
|
||||
|
||||
def test_extract_dependencies(self):
|
||||
"""Test dependency extraction for YAML."""
|
||||
|
||||
@@ -144,13 +144,13 @@ class TestLinuxCNCLibrarySerializer(TestPathToolLibrarySerializerBase):
|
||||
# Verify the content format (basic check)
|
||||
lines = serialized_data.decode("ascii", "ignore").strip().split("\n")
|
||||
self.assertEqual(len(lines), 3)
|
||||
self.assertEqual(lines[0], "T1 P0 D6.000 ;Endmill 6mm")
|
||||
self.assertEqual(lines[1], "T2 P0 D3.000 ;Endmill 3mm")
|
||||
self.assertEqual(lines[2], "T3 P0 D5.000 ;Ballend 5mm")
|
||||
self.assertEqual(lines[0], "T1 P0 X0 Y0 Z0 A0 B0 C0 U0 V0 W0 D6.00 I0 J0 Q0 ;Endmill 6mm")
|
||||
self.assertEqual(lines[1], "T2 P0 X0 Y0 Z0 A0 B0 C0 U0 V0 W0 D3.00 I0 J0 Q0 ;Endmill 3mm")
|
||||
self.assertEqual(lines[2], "T3 P0 X0 Y0 Z0 A0 B0 C0 U0 V0 W0 D5.00 I0 J0 Q0 ;Ballend 5mm")
|
||||
|
||||
def test_linuxcnc_deserialize_not_implemented(self):
|
||||
serializer = LinuxCNCSerializer
|
||||
dummy_data = b"T1 D6.0 ;Endmill 6mm\n"
|
||||
dummy_data = b"T1 P0 X0 Y0 Z0 A0 B0 C0 U0 V0 W0 D6.00 I0 J0 Q0 ;Endmill 6mm\n"
|
||||
with self.assertRaises(NotImplementedError):
|
||||
serializer.deserialize(dummy_data, "dummy_id", {})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user