コード例 #1
0
    def test_valid_color(self):
        ''''''
        config = self.configs.get('ZenPacks.zenoss.Color')
        yaml_param = config.get('yaml_from_specparams')
        yaml_spec = config.get('yaml_dump')

        diff = ZenPack.get_yaml_diff(EXPECTED, yaml_spec)
        self.assertEquals(
            yaml_spec, EXPECTED,
            'YAML Color validation test failed:\n{}'.format(diff))

        diff = ZenPack.get_yaml_diff(yaml_param, yaml_spec)

        self.assertEquals(
            yaml_spec, yaml_param,
            'YAML Color validation test failed:\n{}'.format(diff))
コード例 #2
0
 def test_optimized_yaml(self):
     """Test that optimized YAML is the same as the original"""
     config = self.configs.get('ZenPacks.zenoss.Microsoft.Windows')
     orig_yaml = config.get('yaml_from_specparams')
     new_yaml = optimize_yaml(YAML_WHOLE)
     compare_equals = compare_zenpackspecs(orig_yaml, new_yaml)
     diff = ZenPack.get_yaml_diff(orig_yaml, new_yaml)
     self.assertTrue(compare_equals,
                     'YAML optimization test failed:\n{}'.format(diff))
コード例 #3
0
 def test_optimized_yaml(self):
     """Test that optimized YAML is the same as the original"""
     config = self.configs.get('ZenPacks.zenoss.Microsoft.Windows')
     orig_yaml = config.get('yaml_from_specparams')
     new_yaml = optimize_yaml(YAML_WHOLE)
     compare_equals = compare_zenpackspecs(orig_yaml, new_yaml)
     diff = ZenPack.get_yaml_diff(orig_yaml, new_yaml)
     self.assertTrue(compare_equals,
                     'YAML optimization test failed:\n{}'.format(diff))
コード例 #4
0
    def test_optimized_yaml(self):
        ''''''

        orig_yaml = self.z.export_specparams_yaml()

        new_yaml = optimize_yaml(YAML_WHOLE)

        compare_equals = compare_zenpackspecs(orig_yaml, new_yaml)

        diff = ZenPack.get_yaml_diff(orig_yaml, new_yaml)
        self.assertTrue(compare_equals,
                        'YAML optimization test failed:\n{}'.format(diff))
コード例 #5
0
    def test_multi_yaml(self):
        ''''''

        # reference yaml (all in one
        cfg_whole = zenpacklib.load_yaml(YAML_DOC)

        # reference yaml split across multiple files
        cfg_multi = zenpacklib.load_yaml([YAML_DOC_1, YAML_DOC_2, YAML_DOC_3, YAML_DOC_4, YAML_DOC_5, YAML_DOC_6])

        # dump both back to YAML
        whole_yaml = yaml.dump(cfg_whole.specparams, Dumper=Dumper)
        multi_yaml = yaml.dump(cfg_multi.specparams, Dumper=Dumper)

        compare_equals = compare_zenpackspecs(whole_yaml, multi_yaml)

        diff = ZenPack.get_yaml_diff(whole_yaml, multi_yaml)
        self.assertTrue(compare_equals,
                        'YAML merged dictionary test failed:\n{}'.format(diff))
コード例 #6
0
    def test_dir_load(self):
        ''''''
        # reference yaml (all in one
        cfg_whole = zenpacklib.load_yaml(YAML_WHOLE)

        # reference yaml split across multiple files
        fdir = '{}/data/yaml/test_dir_load'.format(
            os.path.abspath(os.path.dirname(__file__)))
        cfg_dir = zenpacklib.load_yaml(fdir)

        # dump both back to YAML
        whole_yaml = yaml.dump(cfg_whole.specparams, Dumper=Dumper)
        dir_yaml = yaml.dump(cfg_dir.specparams, Dumper=Dumper)

        compare_equals = compare_zenpackspecs(whole_yaml, dir_yaml)

        diff = ZenPack.get_yaml_diff(whole_yaml, dir_yaml)
        self.assertTrue(compare_equals,
                        'YAML Multiple file test failed:\n{}'.format(diff))
コード例 #7
0
ファイル: test_load_dir.py プロジェクト: zenoss/zenpacklib
    def test_dir_load(self):
        ''''''
        # reference yaml (all in one
        cfg_whole = zenpacklib.load_yaml(YAML_WHOLE)

        # reference yaml split across multiple files
        fdir = '{}/data/yaml/test_dir_load'.format(
            os.path.abspath(os.path.dirname(__file__)))
        cfg_dir = zenpacklib.load_yaml(fdir)

        # dump both back to YAML
        whole_yaml = yaml.dump(cfg_whole.specparams, Dumper=Dumper)
        dir_yaml = yaml.dump(cfg_dir.specparams, Dumper=Dumper)

        compare_equals = utils.compare_zenpackspecs(whole_yaml, dir_yaml)

        diff = ZenPack.get_yaml_diff(whole_yaml, dir_yaml)
        self.assertTrue(compare_equals,
                        'YAML Multiple file test failed:\n{}'.format(diff))
コード例 #8
0
    def test_multi_yaml(self):
        ''''''

        # reference yaml (all in one
        cfg_whole = zenpacklib.load_yaml(YAML_DOC)

        # reference yaml split across multiple files
        cfg_multi = zenpacklib.load_yaml([
            YAML_DOC_1, YAML_DOC_2, YAML_DOC_3, YAML_DOC_4, YAML_DOC_5,
            YAML_DOC_6
        ])

        # dump both back to YAML
        whole_yaml = yaml.dump(cfg_whole.specparams, Dumper=Dumper)
        multi_yaml = yaml.dump(cfg_multi.specparams, Dumper=Dumper)

        compare_equals = compare_zenpackspecs(whole_yaml, multi_yaml)

        diff = ZenPack.get_yaml_diff(whole_yaml, multi_yaml)
        self.assertTrue(compare_equals,
                        'YAML merged dictionary test failed:\n{}'.format(diff))
コード例 #9
0
    def test_device_class(self):
        # instantiate the ZenPack class
        zenpack = ZenPack(self.app)

        # create the device class
        for dcname, dcspec in self.z.cfg.device_classes.items():
            zenpack.create_device_class(self.app, dcspec)
            # verify that it was created
            self.assertTrue(
                self.device_class_exists(dcspec.path),
                'Device class {} was not created'.format(dcspec.path))

        for dcname, dcspec in self.z.cfg.device_classes.iteritems():
            if dcspec.remove:
                zenpack.remove_device_class(self.app, dcspec)
                # verify that it was removed
                self.assertFalse(
                    self.device_class_exists(dcspec.path),
                    'Device class {} was not removed'.format(dcspec.path))