コード例 #1
0
 def test_charmconfig_custom_merge(self, mockspew):
     """ Verify rightmost custom charm config dictionary
     does not overwrite untouched items in rendered
     charmconfig
     """
     charm_custom = {"swift-proxy": {"replicas": 15}, "mysql": {"dataset-size": "2048M"}}
     charm_conf = yaml.load(slurp(os.path.join(DATA_DIR, "charmconf.yaml")))
     merged_dicts = merge_dicts(charm_conf, charm_custom)
     self.assertEqual(merged_dicts["mysql"]["max-connections"], 25000)
     self.assertEqual(merged_dicts["swift-proxy"]["zone-assignment"], "auto")
コード例 #2
0
 def test_charmconfig_custom_merge(self, mockspew):
     """ Verify rightmost custom charm config dictionary
     does not overwrite untouched items in rendered
     charmconfig
     """
     charm_custom = {'swift-proxy': {'replicas': 15},
                     'mysql': {'dataset-size': '2048M'}}
     charm_conf = yaml.load(slurp(os.path.join(DATA_DIR, 'charmconf.yaml')))
     merged_dicts = merge_dicts(charm_conf, charm_custom)
     self.assertEqual(merged_dicts['mysql']['max-connections'], 25000)
     self.assertEqual(merged_dicts['swift-proxy']['zone-assignment'],
                      'auto')
コード例 #3
0
 def test_charmconfig_custom_merge(self, mockspew):
     """ Verify rightmost custom charm config dictionary
     does not overwrite untouched items in rendered
     charmconfig
     """
     charm_custom = {'swift-proxy': {'replicas': 15},
                     'mysql': {'dataset-size': '2048M'}}
     charm_conf = yaml.load(slurp(os.path.join(DATA_DIR, 'charmconf.yaml')))
     merged_dicts = merge_dicts(charm_conf, charm_custom)
     self.assertEqual(merged_dicts['mysql']['max-connections'], 25000)
     self.assertEqual(merged_dicts['swift-proxy']['zone-assignment'],
                      'auto')
コード例 #4
0
 def test_charmconfig_custom_overwrite(self, mockspew):
     """ Verify complex yaml can safely overwrite existing defined keys
     """
     charm_conf = yaml.load(slurp(os.path.join(DATA_DIR, 'charmconf.yaml')))
     charm_conf_custom = yaml.load(
         slurp(os.path.join(DATA_DIR, 'charmconf-deepchainmap-fail.yaml')))
     merged_dicts = merge_dicts(charm_conf, charm_conf_custom)
     with NamedTemporaryFile(mode='w+', encoding='utf-8') as tempf:
         spew(tempf.name,
              yaml.safe_dump(merged_dicts, default_flow_style=False))
         modified_charm_conf = yaml.load(slurp(tempf.name))
         self.assertEqual(modified_charm_conf['mysql']['dataset-size'],
                          '512M')
         self.assertEqual(modified_charm_conf['swift-storage']['zone'], 1)
コード例 #5
0
 def test_charmconfig_custom_overwrite(self, mockspew):
     """ Verify complex yaml can safely overwrite existing defined keys
     """
     charm_conf = yaml.load(slurp(os.path.join(DATA_DIR, 'charmconf.yaml')))
     charm_conf_custom = yaml.load(slurp(
         os.path.join(DATA_DIR, 'charmconf-deepchainmap-fail.yaml')))
     merged_dicts = merge_dicts(charm_conf, charm_conf_custom)
     with NamedTemporaryFile(mode='w+', encoding='utf-8') as tempf:
         spew(tempf.name, yaml.safe_dump(
             merged_dicts, default_flow_style=False))
         modified_charm_conf = yaml.load(slurp(tempf.name))
         self.assertEqual(modified_charm_conf['mysql']['dataset-size'],
                          '512M')
         self.assertEqual(modified_charm_conf['swift-storage']['zone'],
                          1)