示例#1
0
    def testMulipleDatapointDataSourceZendoc(self):
        # If there are multiple datapoints, the zendoc should be on
        # the datasourcestr( random.random() )
        rndm = str(random.random())
        TEST_ZENDOC_STRING = "test_zendoc_string_%s" % rndm
        template = createTemplate(self.dmd, 'test_template_%s' % rndm,
                                  {'ds1': ['dp1', 'dp2']})
        targetDS = template.datasources()[0]
        dsAdapter = zope.component.queryAdapter(targetDS, IZenDocProvider)
        self.assert_(dsAdapter is not None)
        self.assertEqual('', dsAdapter.getZendoc(), "Initial zendoc not empty")
        for targetDP in targetDS.datapoints():
            dpAdapter = zope.component.queryAdapter(targetDP, IZenDocProvider)
            self.assert_(dpAdapter is not None)
            self.assertEqual('', dpAdapter.getZendoc(),
                             "Initial zendoc not empty")

        dsAdapter.setZendoc(TEST_ZENDOC_STRING)

        for targetDP in targetDS.datapoints():
            dpAdapter = zope.component.queryAdapter(targetDP, IZenDocProvider)
            self.assertEqual('', dpAdapter.getZendoc(),
                             'Multiple datapoint zendoc should not be set')
        dsAdapter2 = zope.component.queryAdapter(targetDS, IZenDocProvider)
        self.assertEqual(
            TEST_ZENDOC_STRING, dsAdapter2.getZendoc(),
            'Multiple datapoint datasource has incorrect' + ' zendoc')
示例#2
0
    def testSingleDatapointDataSourceZendoc(self):
        # If this is a single datapoint datasource, the zendoc should
        # be held on the single datapoint
        rndm = str(random.random())
        TEST_ZENDOC_STRING = "test_zendoc_string_%s" % rndm
        template = createTemplate(self.dmd, 'test_template_%s' % rndm,
                                  {'ds1': []})
        targetDS = template.datasources()[0]
        targetDP = targetDS.datapoints()[0]
        dsAdapter = zope.component.queryAdapter(targetDS, IZenDocProvider)
        dpAdapter = zope.component.queryAdapter(targetDP, IZenDocProvider)
        self.assert_(dsAdapter is not None)
        self.assert_(dpAdapter is not None)
        self.assertEqual('', dsAdapter.getZendoc(), "Initial zendoc not empty")
        self.assertEqual('', dpAdapter.getZendoc(), "Initial zendoc not empty")
        dsAdapter.setZendoc(TEST_ZENDOC_STRING)

        dpAdapter2 = zope.component.queryAdapter(targetDP, IZenDocProvider)
        self.assertEqual(
            TEST_ZENDOC_STRING, dpAdapter2.getZendoc(),
            'Sole datapoint zendoc different ' +
            'from value written to datasource')
        dsAdapter2 = zope.component.queryAdapter(targetDS, IZenDocProvider)
        self.assertEqual(
            TEST_ZENDOC_STRING, dsAdapter2.getZendoc(),
            'Sole datapoint zendoc different ' +
            'from value written to datasource')
    def testMulipleDatapointDataSourceZendoc(self):
        # If there are multiple datapoints, the zendoc should be on
        # the datasourcestr( random.random() )
        rndm = str( random.random() )
        TEST_ZENDOC_STRING = "test_zendoc_string_%s" % rndm
        template = createTemplate( self.dmd, 'test_template_%s' % rndm,
                                   {'ds1':['dp1','dp2']} )
        targetDS = template.datasources()[0]
        dsAdapter = zope.component.queryAdapter( targetDS, IZenDocProvider )
        self.assert_(dsAdapter is not None)
        self.assertEqual( '', dsAdapter.getZendoc(), "Initial zendoc not empty" )
        for targetDP in targetDS.datapoints():
            dpAdapter = zope.component.queryAdapter( targetDP, IZenDocProvider )
            self.assert_(dpAdapter is not None)
            self.assertEqual( '', dpAdapter.getZendoc(), "Initial zendoc not empty" )

        dsAdapter.setZendoc( TEST_ZENDOC_STRING )

        for targetDP in targetDS.datapoints():
            dpAdapter = zope.component.queryAdapter( targetDP, IZenDocProvider )
            self.assertEqual( '', dpAdapter.getZendoc(),
                              'Multiple datapoint zendoc should not be set' )
        dsAdapter2 = zope.component.queryAdapter( targetDS, IZenDocProvider )
        self.assertEqual( TEST_ZENDOC_STRING, dsAdapter2.getZendoc(),
                          'Multiple datapoint datasource has incorrect' +
                          ' zendoc' )
    def testSingleDatapointDataSourceZendoc(self):
        # If this is a single datapoint datasource, the zendoc should
        # be held on the single datapoint
        rndm = str( random.random() )
        TEST_ZENDOC_STRING = "test_zendoc_string_%s" % rndm
        template = createTemplate( self.dmd, 'test_template_%s' % rndm,
                                   {'ds1':[]} )
        targetDS = template.datasources()[0]
        targetDP = targetDS.datapoints()[0]
        dsAdapter = zope.component.queryAdapter( targetDS, IZenDocProvider )
        dpAdapter = zope.component.queryAdapter( targetDP, IZenDocProvider )
        self.assert_(dsAdapter is not None)
        self.assert_(dpAdapter is not None)
        self.assertEqual( '', dsAdapter.getZendoc(), "Initial zendoc not empty" )
        self.assertEqual( '', dpAdapter.getZendoc(), "Initial zendoc not empty" )
        dsAdapter.setZendoc( TEST_ZENDOC_STRING )

        dpAdapter2 = zope.component.queryAdapter( targetDP, IZenDocProvider )
        self.assertEqual( TEST_ZENDOC_STRING, dpAdapter2.getZendoc(),
                          'Sole datapoint zendoc different ' +
                          'from value written to datasource' )
        dsAdapter2 = zope.component.queryAdapter( targetDS, IZenDocProvider )
        self.assertEqual( TEST_ZENDOC_STRING, dsAdapter2.getZendoc(),
                          'Sole datapoint zendoc different ' +
                          'from value written to datasource' )
 def testCreateByMethod(self):
     aliasName = 'testalias3'
     aliasFormula = 'testformula2'
     t = createTemplate(self.dmd)
     ds0 = t.datasources()[0]
     dp0 = ds0.datapoints()[0]
     alias = manage_addDataPointAlias(dp0, aliasName, aliasFormula)
     self.assert_(alias.id == aliasName)
     self.assert_(alias.formula == aliasFormula)
 def testCreateByMethod(self):
     aliasName = 'testalias3'
     aliasFormula = 'testformula2'
     t = createTemplate(self.dmd)
     ds0 = t.datasources()[0]
     dp0 = ds0.datapoints()[0]
     alias = manage_addDataPointAlias(dp0, aliasName, aliasFormula)
     self.assert_(alias.id == aliasName)
     self.assert_(alias.formula == aliasFormula)
 def testExport(self):
     rndm = str( random.random() )
     TEST_ZENDOC_STRING = "test_zendoc_string_%s" % rndm
     template = createTemplate( self.dmd, 'test_template_%s' % rndm )
     adapter = zope.component.queryAdapter( template, IZenDocProvider )
     adapter.setZendoc( TEST_ZENDOC_STRING )
     writer = StringWriter()
     adapter.exportZendoc(writer)
     xml = writer.toString()
     self.assertEqual( "<property id='zendoc' type='string'>\n%s\n</property>\n"
                       % TEST_ZENDOC_STRING, xml )
示例#8
0
 def testExport(self):
     rndm = str(random.random())
     TEST_ZENDOC_STRING = "test_zendoc_string_%s" % rndm
     template = createTemplate(self.dmd, 'test_template_%s' % rndm)
     adapter = zope.component.queryAdapter(template, IZenDocProvider)
     adapter.setZendoc(TEST_ZENDOC_STRING)
     writer = StringWriter()
     adapter.exportZendoc(writer)
     xml = writer.toString()
     self.assertEqual(
         "<property id='zendoc' type='string'>\n%s\n</property>\n" %
         TEST_ZENDOC_STRING, xml)
    def testTrimmedAliasId(self):
        alias = RRDDataPointAlias(' alias1')
        self.assert_(alias.id == 'alias1')
        alias = RRDDataPointAlias('alias1 ')
        self.assert_(alias.id == 'alias1')
        alias = RRDDataPointAlias(' alias1 ')
        self.assert_(alias.id == 'alias1')

        t = createTemplate(self.dmd)
        ds0 = t.datasources()[0]
        dp0 = ds0.datapoints()[0]
        alias1 = manage_addDataPointAlias(dp0, ' alias1', '')
        self.assert_(alias1.id == 'alias1')
        alias2 = manage_addDataPointAlias(dp0, 'alias2 ', '')
        self.assert_(alias2.id == 'alias2')
        alias3 = manage_addDataPointAlias(dp0, ' alias3 ', '')
        self.assert_(alias3.id == 'alias3')
    def testTrimmedAliasId(self):
        alias = RRDDataPointAlias(' alias1')
        self.assert_(alias.id == 'alias1')
        alias = RRDDataPointAlias('alias1 ')
        self.assert_(alias.id == 'alias1')
        alias = RRDDataPointAlias(' alias1 ')
        self.assert_(alias.id == 'alias1')

        t = createTemplate(self.dmd)
        ds0 = t.datasources()[0]
        dp0 = ds0.datapoints()[0]
        alias1 = manage_addDataPointAlias(dp0, ' alias1', '')
        self.assert_(alias1.id == 'alias1')
        alias2 = manage_addDataPointAlias(dp0, 'alias2 ', '')
        self.assert_(alias2.id == 'alias2')
        alias3 = manage_addDataPointAlias(dp0, ' alias3 ', '')
        self.assert_(alias3.id == 'alias3')