Ejemplo n.º 1
0
 def test_addSubComponentToCustomDeviceComponent(self):
     dc = DeviceClass(self.zp, 'Storage/NetApp', zPythonClass='Device')
     sc = dc.addComponentType('Fan')
     self.assertIsInstance(sc, Component)
     self.assertEqual(
         Relationship.relationships['a.b.c.Device a.b.c.Fan'].hasComponent(
             sc), True)
     self.assertEqual(
         Relationship.relationships['a.b.c.Device a.b.c.Fan'].hasComponent(
             dc.deviceType), True)
Ejemplo n.º 2
0
 def test_addSubComponentToDefaultDeviceComponent(self):
     dc2 = DeviceClass(self.zp, "Server/Linux")
     sc2 = dc2.addComponentType("Fan2")
     self.assertIsInstance(sc2, Component)
     self.assertEqual(
         Relationship.relationships["Products.ZenModel.Device.Device a.b.c.Fan2"].hasComponent(sc2), True
     )
     self.assertEqual(
         Relationship.relationships["Products.ZenModel.Device.Device a.b.c.Fan2"].hasComponent(dc2.deviceType), True
     )
Ejemplo n.º 3
0
 def test_addSubComponentToDefaultDeviceComponent(self):
     dc2 = DeviceClass(self.zp, 'Server/Linux')
     sc2 = dc2.addComponentType('Fan2')
     self.assertIsInstance(sc2, Component)
     self.assertEqual(
         Relationship.
         relationships['Products.ZenModel.Device.Device a.b.c.Fan2'].
         hasComponent(sc2), True)
     self.assertEqual(
         Relationship.relationships[
             'Products.ZenModel.Device.Device a.b.c.Fan2'].hasComponent(
                 dc2.deviceType), True)
Ejemplo n.º 4
0
    def test_SubDeviceClassCreate(self):
        dc = DeviceClass(self.zp, 'Storage/Foo')
        sdc = dc.addClass('Bar')
        self.assertEqual(sdc.path, '/zport/dmd/Storage/Foo/Bar')
        self.assertEqual(sdc.zPythonClass, 'Products.ZenModel.Device.Device')

        sdc_zp = dc.addClass('Bar2', zPythonClass='Products.ZenModel.Foo.Foo')
        self.assertEqual(sdc_zp.path, '/zport/dmd/Storage/Foo/Bar2')
        self.assertEqual(sdc_zp.zPythonClass, 'Products.ZenModel.Foo.Foo')

        sdc_p = dc.addClass('Bar3', prefix='bah')
        self.assertEqual(sdc_p.path, '/zport/dmd/Storage/Foo/Bar3')
Ejemplo n.º 5
0
    def test_SubDeviceClassCreate(self):
        dc = DeviceClass(self.zp, "Storage/Foo")
        sdc = dc.addClass("Bar")
        self.assertEqual(sdc.path, "/zport/dmd/Storage/Foo/Bar")
        self.assertEqual(sdc.zPythonClass, "Products.ZenModel.Device.Device")

        sdc_zp = dc.addClass("Bar2", zPythonClass="Products.ZenModel.Foo.Foo")
        self.assertEqual(sdc_zp.path, "/zport/dmd/Storage/Foo/Bar2")
        self.assertEqual(sdc_zp.zPythonClass, "Products.ZenModel.Foo.Foo")

        sdc_p = dc.addClass("Bar3", prefix="bah")
        self.assertEqual(sdc_p.path, "/zport/dmd/Storage/Foo/Bar3")
Ejemplo n.º 6
0
 def test_zPythonClassProperty(self):
     dc = DeviceClass(self.zp, 'Devices/Server/Organizer')
     org = Organizer(self.zp,
                     'Devices/Server/Organizer',
                     type_='DeviceClass')
     self.assertEqual(dc.path, '/zport/dmd/Devices/Server/Organizer')
     self.assertEqual(dc.zPythonClass, 'Products.ZenModel.Device.Device')
     self.assertEqual(org.properties['zPythonClass'].value,
                      'Products.ZenModel.Device.Device')
Ejemplo n.º 7
0
 def test_componentTypes(self):
     dc = DeviceClass(self.zp, 'Storage/Example', zPythonClass='Device')
     fc = dc.addComponentType('Fan')
     dc.addComponentType('Battery')
     dc.addComponentType('Cpu')
     fc.addComponentType('Blade')
     self.assertEqual(
         ['a.b.c.Battery', 'a.b.c.Blade', 'a.b.c.Cpu', 'a.b.c.Fan'],
         [c.id for c in dc.componentTypes])
Ejemplo n.º 8
0
 def test_componentTypes(self):
     dc = DeviceClass(self.zp, "Storage/Example", zPythonClass="Device")
     fc = dc.addComponentType("Fan")
     dc.addComponentType("Battery")
     dc.addComponentType("Cpu")
     fc.addComponentType("Blade")
     self.assertEqual(["a.b.c.Battery", "a.b.c.Blade", "a.b.c.Cpu", "a.b.c.Fan"], [c.id for c in dc.componentTypes])
Ejemplo n.º 9
0
 def test_setzPythonClass_shortClass(self):
     dc = DeviceClass(self.zp, 'Storage/Foo', zPythonClass='Device')
     self.assertEqual(dc.zPythonClass, 'a.b.c.Device')
     self.assertEqual(dc.deviceType.id, 'a.b.c.Device')
Ejemplo n.º 10
0
 def test_DeviceClassComponentId(self):
     dc = DeviceClass(self.zp, 'Storage/Foo')
     self.assertEqual(dc.deviceType.id, 'Products.ZenModel.Device.Device')
Ejemplo n.º 11
0
 def test_DeviceClassCreate(self):
     dc = DeviceClass(self.zp, '/Storage/Foo')
     self.assertIsInstance(dc, DeviceClass)
     self.assertEqual(dc.zPythonClass, 'Products.ZenModel.Device.Device')
Ejemplo n.º 12
0
 def test_addSubComponentToCustomDeviceComponent(self):
     dc = DeviceClass(self.zp, "Storage/NetApp", zPythonClass="Device")
     sc = dc.addComponentType("Fan")
     self.assertIsInstance(sc, Component)
     self.assertEqual(Relationship.relationships["a.b.c.Device a.b.c.Fan"].hasComponent(sc), True)
     self.assertEqual(Relationship.relationships["a.b.c.Device a.b.c.Fan"].hasComponent(dc.deviceType), True)