24
import Path.Base.PropertyBag as PathPropertyBag
25
import Tests.PathTestUtils as PathTestUtils
28
class TestPathPropertyBag(PathTestUtils.PathTestBase):
30
self.doc = FreeCAD.newDocument("test-property-bag")
33
FreeCAD.closeDocument(self.doc.Name)
36
"""basic PropertyBag creation and access test"""
37
bag = PathPropertyBag.Create()
38
self.assertTrue(hasattr(bag, "Proxy"))
39
self.assertEqual(bag.Proxy.getCustomProperties(), [])
40
self.assertEqual(bag.CustomPropertyGroups, [])
43
"""adding properties to a PropertyBag is tracked properly"""
44
bag = PathPropertyBag.Create()
46
proxy.addCustomProperty("App::PropertyString", "Title", "Address", "Some description")
47
self.assertTrue(hasattr(bag, "Title"))
49
self.assertEqual(bag.Title, "Madame")
50
self.assertEqual(bag.Proxy.getCustomProperties(), ["Title"])
51
self.assertEqual(bag.CustomPropertyGroups, ["Address"])
54
"""refreshCustomPropertyGroups deletes empty groups"""
55
bag = PathPropertyBag.Create()
57
proxy.addCustomProperty("App::PropertyString", "Title", "Address", "Some description")
59
bag.removeProperty("Title")
60
proxy.refreshCustomPropertyGroups()
61
self.assertEqual(bag.Proxy.getCustomProperties(), [])
62
self.assertEqual(bag.CustomPropertyGroups, [])
65
"""refreshCustomPropertyGroups does not delete non-empty groups"""
66
bag = PathPropertyBag.Create()
68
proxy.addCustomProperty("App::PropertyString", "Title", "Address", "Some description")
69
proxy.addCustomProperty("App::PropertyString", "Gender", "Attributes")
72
bag.removeProperty("Gender")
73
proxy.refreshCustomPropertyGroups()
74
self.assertEqual(bag.Proxy.getCustomProperties(), ["Title"])
75
self.assertEqual(bag.CustomPropertyGroups, ["Address"])