예제 #1
0
 def test_deep_merge_dicts(self):
     dict1 = {
         'key1': 'value1',
         'key2': {
             'key2-1': 'value2-1',
             'unchanged': 'unchanged'
         },
         'unchanged': 'unchanged',
     }
     dict2 = {
         'key1': 'value1-final',
         'key2': {
             'key2-1': 'value2-1-final',
             'key2-2': 'value2-2'
         },
     }
     merged = {
         'key1': 'value1-final',
         'key2': {
             'key2-1': 'value2-1-final',
             'key2-2': 'value2-2',
             'unchanged': 'unchanged',
         },
         'unchanged': 'unchanged',
     }
     self.assertDictEqual(deep_merge_dicts(dict1, dict2), merged)
예제 #2
0
def get_metric_configuration():
    metrics = deep_merge_dicts(DEFAULT_METRICS,
                               app_settings.ADDITIONAL_METRICS)
    # ensure configuration is not broken
    for metric_config in metrics.values():
        _validate_metric_configuration(metric_config)
    return metrics
예제 #3
0
def get_ping_schema():
    schema = {
        '$schema': 'http://json-schema.org/draft-07/schema#',
        'type': 'object',
        'additionalProperties': False,
    }
    schema['properties'] = deep_merge_dicts(DEFAULT_PING_CHECK_CONFIG,
                                            app_settings.PING_CHECK_CONFIG)
    return schema
예제 #4
0
def get_chart_configuration():
    metrics = get_metric_configuration()
    for metric in metrics.values():
        if 'charts' in metric:
            DEFAULT_CHARTS.update(metric['charts'])
    charts = deep_merge_dicts(DEFAULT_CHARTS, app_settings.ADDITIONAL_CHARTS)
    # ensure configuration is not broken
    for key, options in charts.items():
        _validate_chart_configuration(options)
    return charts