Example #1
0
 def testConfigInstantiate(self):
     dc = None
     dc = DeviceConfigurations()
     dc.setConfig(self.config_line)
     a = dc.getContexts()
     assert len(a) == 1 and a[
         0] == default_context, 'single config on intantiate doenst work'
Example #2
0
 def testCmpSame(self):
     dc1 = None
     dc2 = None
     dc1 = DeviceConfigurations()
     dc1.setConfig(self.config_line)
     dc2 = DeviceConfigurations()
     dc2.setConfig(self.config_line)
     assert cmp(dc1, dc2) == 0, 'cmp() with same failed'
Example #3
0
 def testDiffDifferent(self):
     dc1 = None
     dc2 = None
     dc1 = DeviceConfigurations()
     dc1.setConfig(self.config_line)
     dc2 = DeviceConfigurations()
     dc2.append(self.config_three)
     diff = dc1.diff(dc2)
     assert len(diff) > 0, 'diff() of different failed'
Example #4
0
 def testDiffSame(self):
     dc1 = None
     dc2 = None
     dc1 = DeviceConfigurations()
     dc1.setConfig(self.config_line)
     dc2 = DeviceConfigurations()
     dc2.setConfig(self.config_line)
     diff = dc1.diff(dc2)
     assert len(diff) == 0, 'diff() of same failed'
Example #5
0
 def testCmpDifferent(self):
     dc1 = None
     dc2 = None
     dc1 = DeviceConfigurations()
     dc1.setConfig(self.config_line)
     dc2 = DeviceConfigurations()
     dc2.append(self.config_two)
     c = cmp(dc1, dc2)
     assert not c == 0, 'cmp() with different failed (' + str(
         c) + '): \ndc1=' + str(dc1) + "\ndc2=" + str(dc2)
 def testDiffSame(self):
     store = ConfigurationStorage(dbhost=self._dbhost,
                                  dbname=self._dbname,
                                  user=self._dbuser,
                                  passwd=self._dbpasswd)
     config_one = DeviceConfigurations()
     config_one.setConfig(["hello there\n", "this is a test"])
     config_two = DeviceConfigurations()
     config_two.setConfig(["hello there\n", "this is a test"])
     ret = store.isChanged(config_one, config_two)
     #logging.warn( diff )
     assert ret == False, "same configs showed different diffs"
    def testDetermineMergedContexts(self):
        store = ConfigurationStorage(dbhost=self._dbhost,
                                     dbname=self._dbname,
                                     user=self._dbuser,
                                     passwd=self._dbpasswd)

        # create a device configuration o bject from teh raw strings
        config_one = DeviceConfigurations()
        config_one.setConfig(["hello there\n", "this is a test"])

        # construct a device configuration ob ject from a configuration object
        config_two = DeviceConfigurations()
        conf = Configuration()
        conf.set(["hello there\n", "this is a test"])
        conf.setContext('something_else')
        config_two.append(conf)
        array = store.determineMergedContexts(config_one, config_two)
        assert array == ['something_else', 'system'
                         ], 'determining merged contexts failed: ' + str(array)
Example #8
0
 def testContext(self):
     dc = DeviceConfigurations()
     string = 'test_context'
     dc.setConfig(self.config_one, context=string)
     assert dc.getContexts()[0] == string, 'context names do not match'