Exemplo n.º 1
0
    def afterSetUp(self):
        super(Testzenbatchdumper, self).afterSetUp()

        self.zdumper = BatchDeviceDumper(noopts=1)
        self.zdumper.options = FakeOptions()
        self.zdumper.options.regex = '.*'
        self.zdumper.options.prune = False
        self.zdumper.options.root = '/zport/dmd/Devices/TestZenBatchDumper'

        self.zloader = BatchDeviceLoader(noopts=1)
        self.zloader.options = FakeOptions()
        self.zloader.options.nomodel = True
        self.zloader.options.nocommit = False

        # Ensure that both commands get
        # a real database connection
        self.zdumper.dmd = self.zloader.dmd

        self.log = logging.getLogger("zen.BatchDeviceDumper")
        self.zdumper.log = self.log
        self.zloader.log = logging.getLogger("zen.BatchDeviceLoader")

        # Actually add the organizer we use in testing
        testRoot = self.zdumper.options.root.rsplit('/', 1)[1]
        self.zdumper.dmd.Devices.manage_addOrganizer(testRoot)
Exemplo n.º 2
0
    def afterSetUp(self):
        super(Testzenbatchloader, self).afterSetUp()

        self.zloader = BatchDeviceLoader(noopts=1)
        self.zloader.options = FakeOptions()
        self.zloader.options.nomodel = True
        self.zloader.options.nocommit = False

        self.log = logging.getLogger("zen.BatchDeviceLoader")
        self.zloader.log = self.log
Exemplo n.º 3
0
class Testzenbatchdumper(BaseTestCase):
    def afterSetUp(self):
        super(Testzenbatchdumper, self).afterSetUp()

        self.zdumper = BatchDeviceDumper(noopts=1)
        self.zdumper.options = FakeOptions()
        self.zdumper.options.regex = '.*'
        self.zdumper.options.prune = False
        self.zdumper.options.root = '/zport/dmd/Devices/TestZenBatchDumper'

        self.zloader = BatchDeviceLoader(noopts=1)
        self.zloader.options = FakeOptions()
        self.zloader.options.nomodel = True
        self.zloader.options.nocommit = False

        # Ensure that both commands get
        # a real database connection
        self.zdumper.dmd = self.zloader.dmd

        self.log = logging.getLogger("zen.BatchDeviceDumper")
        self.zdumper.log = self.log
        self.zloader.log = logging.getLogger("zen.BatchDeviceLoader")

        # Actually add the organizer we use in testing
        testRoot = self.zdumper.options.root.rsplit('/', 1)[1]
        self.zdumper.dmd.Devices.manage_addOrganizer(testRoot)

    def testDump(self):
        olympics = DateTime("2010/02/28")
        configs = [
            "/Devices/TestZenBatchDumper",
            "device1 cDateTest=%s" % repr(olympics)
        ]
        device_list, unparseable = self.zloader.parseDevices(configs)
        self.zloader.processDevices(device_list)

        outFile = StringIO()
        numDevs = self.zdumper.listDeviceTree(outFile)

        total = len([d for d in self.zdumper.root.getSubDevices()])
        self.assert_(total > 0, "Didn't load any devices")
        self.assert_(numDevs['Devices'] == total,
                     "Dumped %d of %d devices" % (numDevs['Devices'], total))
        outText = outFile.getvalue()
        outFile.close()

        self.log.info(outText)
        outConfigs = outText.split('\n')
        out_device_list, unparseable = self.zloader.parseDevices(outConfigs)
        self.assert_(numDevs['Devices'] == len(out_device_list))
        dev = self.zloader.dmd.Devices.findDevice('device1')
        self.assert_(dev.cDateTest == olympics)
Exemplo n.º 4
0
    def importDevices(self, data, options={}):
        loader = BatchDeviceLoader(noopts=True)
        if isinstance(data, str):
            data = data.split('\n')

        # Set command-line options
        loader.options.nomodel = True
        self._setOptions(loader, options)

        devices, unparseable = loader.parseDevices(data)
        stats = loader.processDevices(devices)
        stats['unparseable'] = unparseable
        return stats
class Testzenbatchdumper(BaseTestCase):

    def afterSetUp(self):
        super(Testzenbatchdumper, self).afterSetUp()

        self.zdumper = BatchDeviceDumper(noopts=1)
        self.zdumper.options = FakeOptions()
        self.zdumper.options.regex = '.*'
        self.zdumper.options.prune = False
        self.zdumper.options.root = '/zport/dmd/Devices/TestZenBatchDumper'

        self.zloader = BatchDeviceLoader(noopts=1)
        self.zloader.options = FakeOptions()
        self.zloader.options.nomodel = True
        self.zloader.options.nocommit = False

        # Ensure that both commands get
        # a real database connection
        self.zdumper.dmd = self.zloader.dmd

        self.log = logging.getLogger("zen.BatchDeviceDumper")
        self.zdumper.log = self.log
        self.zloader.log = logging.getLogger("zen.BatchDeviceLoader")

        # Actually add the organizer we use in testing
        testRoot = self.zdumper.options.root.rsplit('/', 1)[1]
        self.zdumper.dmd.Devices.manage_addOrganizer(testRoot)

    def testDump(self):
        olympics = DateTime("2010/02/28")
        configs = ["/Devices/TestZenBatchDumper", "device1 cDateTest=%s" % repr(olympics)]
        device_list, unparseable = self.zloader.parseDevices(configs)
        self.zloader.processDevices(device_list)

        outFile = StringIO()
        numDevs = self.zdumper.listDeviceTree(outFile)

        total = len([d for d in self.zdumper.root.getSubDevices() ])
        self.assert_(total > 0, "Didn't load any devices")
        self.assert_(numDevs['Devices'] == total,
            "Dumped %d of %d devices" % ( numDevs['Devices'], total))
        outText = outFile.getvalue()
        outFile.close()

        self.log.info(outText)
        outConfigs = outText.split('\n')
        out_device_list, unparseable = self.zloader.parseDevices(outConfigs)
        self.assert_(numDevs['Devices'] == len(out_device_list))
        dev = self.zloader.dmd.Devices.findDevice('device1')
        self.assert_(dev.cDateTest == olympics)
    def afterSetUp(self):
        super(Testzenbatchdumper, self).afterSetUp()

        self.zdumper = BatchDeviceDumper(noopts=1)
        self.zdumper.options = FakeOptions()
        self.zdumper.options.regex = '.*'
        self.zdumper.options.prune = False
        self.zdumper.options.root = '/zport/dmd/Devices/TestZenBatchDumper'

        self.zloader = BatchDeviceLoader(noopts=1)
        self.zloader.options = FakeOptions()
        self.zloader.options.nomodel = True
        self.zloader.options.nocommit = False

        # Ensure that both commands get
        # a real database connection
        self.zdumper.dmd = self.zloader.dmd

        self.log = logging.getLogger("zen.BatchDeviceDumper")
        self.zdumper.log = self.log
        self.zloader.log = logging.getLogger("zen.BatchDeviceLoader")

        # Actually add the organizer we use in testing
        testRoot = self.zdumper.options.root.rsplit('/', 1)[1]
        self.zdumper.dmd.Devices.manage_addOrganizer(testRoot)
    def afterSetUp(self):
        super(Testzenbatchloader, self).afterSetUp()

        self.zloader = BatchDeviceLoader(noopts=1)
        self.zloader.options = FakeOptions()
        self.zloader.options.nomodel = True
        self.zloader.options.nocommit = False

        self.log = logging.getLogger("zen.BatchDeviceLoader")
        self.zloader.log = self.log
class Testzenbatchloader(BaseTestCase):

    def afterSetUp(self):
        super(Testzenbatchloader, self).afterSetUp()

        self.zloader = BatchDeviceLoader(noopts=1)
        self.zloader.options = FakeOptions()
        self.zloader.options.nomodel = True
        self.zloader.options.nocommit = False

        self.log = logging.getLogger("zen.BatchDeviceLoader")
        self.zloader.log = self.log

    def testSampleConfig(self):
        """
        Is the internal sample config still working?
        """
        configs = self.zloader.sample_configs.split('\n')
        device_list, unparseable = self.zloader.parseDevices(configs)
        self.zloader.processDevices(device_list)

    def testCProps(self):
        """
        Verify that we can set custom properties
        """
        olympics = DateTime("2010/02/28")
        configs = ["device1 cDateTest=%s" % repr(olympics)]
        device_list, unparseable = self.zloader.parseDevices(configs)
        self.zloader.processDevices(device_list)

        dev = self.zloader.dmd.Devices.findDevice('device1')
        self.assert_(dev.cDateTest == olympics)
Exemplo n.º 9
0
class Testzenbatchloader(BaseTestCase):
    def afterSetUp(self):
        super(Testzenbatchloader, self).afterSetUp()

        self.zloader = BatchDeviceLoader(noopts=1)
        self.zloader.options = FakeOptions()
        self.zloader.options.nomodel = True
        self.zloader.options.nocommit = False

        self.log = logging.getLogger("zen.BatchDeviceLoader")
        self.zloader.log = self.log

    def testSampleConfig(self):
        """
        Is the internal sample config still working?
        """
        configs = self.zloader.sample_configs.split('\n')
        device_list, unparseable = self.zloader.parseDevices(configs)
        self.zloader.processDevices(device_list)

    def testCProps(self):
        """
        Verify that we can set custom properties
        """
        olympics = DateTime("2010/02/28")
        configs = ["device1 cDateTest=%s" % repr(olympics)]
        device_list, unparseable = self.zloader.parseDevices(configs)
        self.zloader.processDevices(device_list)

        dev = self.zloader.dmd.Devices.findDevice('device1')
        self.assert_(dev.cDateTest == olympics)