Beispiel #1
0
 def testOperationResetAfterRename(self):
     dev = build(self.dataroot, Server, "dev")
     jim = build(self.dataroot, Admin, "jim")
     dev.admin.addRelation(jim)
     transaction.savepoint()
     self.dataroot.manage_renameObject("dev", "newdev")
     self.assertEqual(dev._operation, -1)
Beispiel #2
0
 def testCopyPasteRMSamePath(self):
     """Copy/Paste RM in same folder as original"""
     build(self.dataroot, Device, "dev")
     transaction.savepoint()
     cookie = self.dataroot.manage_copyObjects(ids=('dev', ))
     self.dataroot.manage_pasteObjects(cookie)
     self.failUnless(self.dataroot._getOb('dev'))
     self.failUnless(self.dataroot._getOb('copy_of_dev'))
Beispiel #3
0
 def testCopyPasteToFromOneToManyLink(self):
     """Copy/Paste to form a one to many link between device and location"""
     dev = build(self.dataroot, Device, "dev")
     loc = build(self.dataroot, Location, "loc")
     transaction.savepoint()
     cookie = self.dataroot.manage_copyObjects(ids=('dev', ))
     self.dataroot.loc.devices.manage_pasteObjects(cookie)
     self.failUnless(dev.location() == loc)
     self.failUnless(dev in loc.devices())
Beispiel #4
0
 def testLinkObjectsUI2(self):
     """Test linking objects using the UI code, ids are strings"""
     dev = build(self.dataroot, Server, "dev")
     jim = build(self.dataroot, Admin, "jim")
     transaction.savepoint()
     cookie = self.dataroot.manage_copyObjects(ids='jim')
     self.failUnless(cookie)
     self.dataroot.dev.manage_linkObjects(ids="admin", cb_copy_data=cookie)
     self.failUnless(jim.server() == dev)
     self.failUnless(dev.admin() == jim)
Beispiel #5
0
 def testLinkObjectsUI3(self):
     """Test linking objects using the UI code, fail too many ids"""
     build(self.dataroot, Server, "dev")
     build(self.dataroot, Admin, "jim")
     transaction.savepoint()
     cookie = self.dataroot.manage_copyObjects(ids='jim')
     self.failUnless(cookie)
     with self.assertRaises(ZenRelationsError):
         self.dataroot.dev.manage_linkObjects(ids=("admin", "joe"),
                                              cb_copy_data=cookie)
Beispiel #6
0
 def testCopyPasteRMPP(self):
     """test that primary path gets set correctly after copy and paste"""
     build(self.dataroot, Device, "dev")
     transaction.savepoint()
     cookie = self.dataroot.manage_copyObjects(ids=('dev', ))
     self.dataroot.subfolder.manage_pasteObjects(cookie)
     self.failUnless(self.dataroot.subfolder._getOb('dev'))
     copy = self.dataroot.subfolder._getOb("dev")
     self.assertEqual(self.dataroot.subfolder.getPhysicalPath(),
                      copy.getPrimaryPath()[:-1])
Beispiel #7
0
 def testRenameRMOneToOne(self):
     """Renameing RM that has a OneToOne relationship"""
     dev = build(self.dataroot, Server, "dev")
     jim = build(self.dataroot, Admin, "jim")
     dev.admin.addRelation(jim)
     transaction.savepoint()
     self.dataroot.manage_renameObject("dev", "newdev")
     self.failUnless(self.dataroot._getOb("newdev"))
     self.failUnless(dev.admin.hasobject(jim))
     self.failUnless(jim.server.hasobject(dev))
Beispiel #8
0
 def testCopyPasteRMManyToMany(self):
     """Copy/paste to check RM with ManyToMany relationship"""
     dev = build(self.dataroot, Device, "dev")
     group = build(self.dataroot, Group, "group")
     dev.groups.addRelation(group)
     transaction.savepoint()
     self.dataroot.manage_renameObject("dev", "newdev")
     self.failUnless(self.dataroot._getOb("newdev"))
     self.failUnless(group.devices.hasobject(dev))
     self.failUnless(dev.groups.hasobject(group))
Beispiel #9
0
 def testdelObjectRMwRel(self):
     """delete an RM that has many relationships on it"""
     dev = build(self.dataroot, Server, "dev")
     loc = build(self.dataroot, Location, "loc")
     jim = build(self.dataroot, Admin, "jim")
     group = build(self.dataroot, Group, "group")
     dev.admin.addRelation(jim)
     dev.groups.addRelation(group)
     dev.location.addRelation(loc)
     self.dataroot._delObject("dev")
     self.failIf(self.dataroot._getOb('dev', False))
Beispiel #10
0
 def testRenameOneToMany(self):
     """Renaming RM that has a OneToMany relationship"""
     dev = build(self.dataroot, Device, "dev")
     anna = build(self.dataroot, Location, "anna")
     dev.location.addRelation(anna)
     self.failUnless(dev.location() == anna)
     transaction.savepoint()
     self.dataroot.manage_renameObject("dev", "newdev")
     self.failUnless(self.dataroot._getOb("newdev"))
     self.failUnless(anna.devices.hasobject(dev))
     self.failUnless(dev.location() == anna)
Beispiel #11
0
 def testCopyPasteRMOneToOne(self):
     """Copy/paste to check RM with OneToOne relationship"""
     dev = build(self.dataroot, Server, "dev")
     jim = build(self.dataroot, Admin, "jim")
     dev.admin.addRelation(jim)
     transaction.savepoint()
     cookie = self.dataroot.manage_copyObjects(ids=('dev', ))
     self.dataroot.subfolder.manage_pasteObjects(cookie)
     copy = self.dataroot.subfolder._getOb("dev")
     self.failUnless(dev.admin() == jim)
     self.assertIsNone(copy.admin())
Beispiel #12
0
 def testCopyPasteRMOneToMany(self):
     """Copy/paste to check RM with OneToMany relationship"""
     dev = build(self.dataroot, Device, "dev")
     anna = build(self.dataroot, Location, "anna")
     dev.location.addRelation(anna)
     transaction.savepoint()
     cookie = self.dataroot.manage_copyObjects(ids=('dev', ))
     self.dataroot.subfolder.manage_pasteObjects(cookie)
     copy = self.dataroot.subfolder._getOb("dev")
     self.failUnless(copy.location() == anna)
     self.failUnless(dev.location() == anna)
     self.failUnless(len(anna.devices()) == 2)
Beispiel #13
0
 def test_setObjectOneToManyCont(self):
     """Place object into ToManyCont with _setObject"""
     dev = build(self.dataroot, Device, "dev")
     eth0 = create(self.dataroot, IpInterface, "eth0")
     dev.interfaces._setObject("eth0", eth0)
     self.failUnless(dev.interfaces._getOb("eth0") == eth0)
     self.assertIn("interfaces", dev.interfaces.eth0.getPrimaryPath())
Beispiel #14
0
 def testCutPasteRM(self):
     """test cut and past of a RM make sure primarypath is set properly"""
     dev = build(self.dataroot, Device, "dev")
     transaction.savepoint()
     cookie = self.dataroot.manage_cutObjects(ids=('dev', ))
     self.dataroot.subfolder.manage_pasteObjects(cookie)
     self.failIf(self.dataroot._getOb('dev', False))
     self.failUnless(self.dataroot.subfolder._getOb('dev'))
     self.failUnless(self.dataroot.subfolder.getPhysicalPath() ==
                     dev.getPrimaryPath()[:-1])
Beispiel #15
0
 def testCutPasteRMwRel(self):
     """cut and paste with relationships make sure they persist and
     that their keys are updated properly"""
     dev = build(self.dataroot, Server, "dev")
     loc = build(self.dataroot, Location, "loc")
     jim = build(self.dataroot, Admin, "jim")
     group = build(self.dataroot, Group, "group")
     dev.admin.addRelation(jim)
     dev.groups.addRelation(group)
     dev.location.addRelation(loc)
     transaction.savepoint()
     cookie = self.dataroot.manage_cutObjects(ids=('dev', ))
     self.dataroot.subfolder.manage_pasteObjects(cookie)
     self.failIf(self.dataroot._getOb('dev', False))
     self.failUnless(self.dataroot.subfolder._getOb('dev'))
     self.failUnless(dev in group.devices())
     self.failUnless(dev.admin() == jim)
     self.failUnless(dev.location() == loc)
     self.failUnless(loc.devices.hasobject(dev))
     self.failUnless(group.devices.hasobject(dev))
Beispiel #16
0
 def testCopyPasteProperties(self):
     """test that Properties are copied correctly"""
     dev = build(self.dataroot, Device, "dev")
     dev.pingStatus = 3
     transaction.savepoint()
     cookie = self.dataroot.manage_copyObjects(ids=('dev', ))
     self.dataroot.manage_pasteObjects(cookie)
     self.failUnless(self.dataroot.copy_of_dev._getOb('pingStatus'))
     copy = self.dataroot._getOb("copy_of_dev")
     self.failUnless(dev.pingStatus == copy.pingStatus)
     self.failUnless(dev.pingStatus == 3)
Beispiel #17
0
 def testCopyPasteRMOneToManyCont(self):
     """Copy/paste to check RM with OneToManyCont subobject"""
     dev = build(self.dataroot, Device, "dev")
     eth0 = create(dev.interfaces, IpInterface, "eth0")
     transaction.savepoint()
     self.dataroot.manage_renameObject("dev", "newdev")
     self.failUnless(self.dataroot._getOb("newdev"))
     self.assertEqual(self.dataroot.getPhysicalPath(),
                      dev.getPrimaryPath()[:-1])
     self.assertEqual(dev.getPrimaryPath(), eth0.getPrimaryPath()[:-2])
     self.failUnless(eth0.device() == dev)
Beispiel #18
0
 def testCutPasteRM2(self):
     """add contained relationship to cut/paste test"""
     dev = build(self.dataroot, Device, "dev")
     eth0 = create(dev.interfaces, IpInterface, "eth0")
     transaction.savepoint()
     cookie = self.dataroot.manage_cutObjects(ids=('dev', ))
     self.dataroot.subfolder.manage_pasteObjects(cookie)
     self.failIf(self.dataroot._getOb('dev', False))
     self.failUnless(self.dataroot.subfolder._getOb('dev'))
     self.assertEqual(self.dataroot.subfolder.getPhysicalPath(),
                      dev.getPrimaryPath()[:-1])
     self.assertEqual(
         eth0.getPrimaryUrlPath().find(dev.getPrimaryUrlPath()), 0)