Exemplo n.º 1
0
 def _get_dict_mapping(cls, prop, data):
     mapping = {}
     for name, value in data.items():
         if isinstance(value, (dict, collections.Mapping)):
             dict_merge(mapping, cls._get_dict_mapping(name, value))
         else:
             dict_merge(mapping, cls._get_field_mapping(name, value))
     return {prop: {'properties': mapping}}
Exemplo n.º 2
0
 def test_dm_empty(self):
     d1 = {}
     dict_merge(d1, {})
     self.assertEqual(d1, {})
     dict_merge(d1, dict(foo=42))
     self.assertEqual(d1, dict(foo=42))
     dict_merge(d1, dict(foo=43))
     self.assertEqual(d1, dict(foo=43))
Exemplo n.º 3
0
 def test_dm_rec(self):
     d1 = dict(foo=dict(bar=42))
     dict_merge(d1, dict(foo=dict(foo=44)))
     self.assertEqual(d1, dict(foo=dict(bar=42, foo=44)))
     dict_merge(d1, dict(foo=dict(foo=42)))
     self.assertEqual(d1, dict(foo=dict(bar=42, foo=42)))
Exemplo n.º 4
0
 def _get_document_mapping(self, benchmark):
     fields = {}
     for run in ESExporter._get_benchmark_runs(self.campaign, benchmark):
         dict_merge(fields, ESExporter._get_dict_mapping(benchmark, run))
     return fields
Exemplo n.º 5
0
 def execution_matrix(self):
     clazz = self.get_benchmark_clazz()
     benchmark = clazz()
     dict_merge(benchmark.attributes, self.attributes)
     return list(benchmark.execution_matrix(self.exec_context))