def Create(name='PropertyBag'): '''Create(name = 'PropertyBag') ... creates a new setup sheet''' FreeCAD.ActiveDocument.openTransaction( translate("PathPropertyBag", "Create PropertyBag")) pcont = PathPropertyBag.Create(name) PathIconViewProvider.Attach(pcont.ViewObject, name) return pcont
def test02(self): """refreshCustomPropertyGroups deletes empty groups""" bag = PathPropertyBag.Create() proxy = bag.Proxy proxy.addCustomProperty("App::PropertyString", "Title", "Address", "Some description") bag.Title = "Madame" bag.removeProperty("Title") proxy.refreshCustomPropertyGroups() self.assertEqual(bag.Proxy.getCustomProperties(), []) self.assertEqual(bag.CustomPropertyGroups, [])
def test01(self): """adding properties to a PropertyBag is tracked properly""" bag = PathPropertyBag.Create() proxy = bag.Proxy proxy.addCustomProperty("App::PropertyString", "Title", "Address", "Some description") self.assertTrue(hasattr(bag, "Title")) bag.Title = "Madame" self.assertEqual(bag.Title, "Madame") self.assertEqual(bag.Proxy.getCustomProperties(), ["Title"]) self.assertEqual(bag.CustomPropertyGroups, ["Address"])
def test02(self): '''refreshCustomPropertyGroups deletes empty groups''' bag = PathPropertyBag.Create() proxy = bag.Proxy proxy.addCustomProperty('App::PropertyString', 'Title', 'Address', 'Some description') bag.Title = 'Madame' bag.removeProperty('Title') proxy.refreshCustomPropertyGroups() self.assertEqual(bag.Proxy.getCustomProperties(), []) self.assertEqual(bag.CustomPropertyGroups, [])
def test01(self): '''adding properties to a PropertyBag is tracked properly''' bag = PathPropertyBag.Create() proxy = bag.Proxy proxy.addCustomProperty('App::PropertyString', 'Title', 'Address', 'Some description') self.assertTrue(hasattr(bag, 'Title')) bag.Title = 'Madame' self.assertEqual(bag.Title, 'Madame') self.assertEqual(bag.Proxy.getCustomProperties(), ['Title']) self.assertEqual(bag.CustomPropertyGroups, ['Address'])
def test03(self): """refreshCustomPropertyGroups does not delete non-empty groups""" bag = PathPropertyBag.Create() proxy = bag.Proxy proxy.addCustomProperty("App::PropertyString", "Title", "Address", "Some description") proxy.addCustomProperty("App::PropertyString", "Gender", "Attributes") bag.Title = "Madame" bag.Gender = "Female" bag.removeProperty("Gender") proxy.refreshCustomPropertyGroups() self.assertEqual(bag.Proxy.getCustomProperties(), ["Title"]) self.assertEqual(bag.CustomPropertyGroups, ["Address"])
def test03(self): '''refreshCustomPropertyGroups does not delete non-empty groups''' bag = PathPropertyBag.Create() proxy = bag.Proxy proxy.addCustomProperty('App::PropertyString', 'Title', 'Address', 'Some description') proxy.addCustomProperty('App::PropertyString', 'Gender', 'Attributes') bag.Title = 'Madame' bag.Gender = 'Female' bag.removeProperty('Gender') proxy.refreshCustomPropertyGroups() self.assertEqual(bag.Proxy.getCustomProperties(), ['Title']) self.assertEqual(bag.CustomPropertyGroups, ['Address'])
def Create(name="PropertyBag"): """Create(name = 'PropertyBag') ... creates a new setup sheet""" FreeCAD.ActiveDocument.openTransaction("Create PropertyBag") pcont = PathPropertyBag.Create(name) PathIconViewProvider.Attach(pcont.ViewObject, name) return pcont
def test00(self): """basic PropertyBag creation and access test""" bag = PathPropertyBag.Create() self.assertTrue(hasattr(bag, "Proxy")) self.assertEqual(bag.Proxy.getCustomProperties(), []) self.assertEqual(bag.CustomPropertyGroups, [])