コード例 #1
0
ファイル: tests.py プロジェクト: ageron/commis
 def test_deep_merge(self):
     a = {
         'a': 1,
         'b': 2,
         'c': {
             'd': 3,
             'e': 4,
         }
     }
     b = {
         'a': 10,
         'd': 3,
         'c': {
             'd': 10,
             'f': 4,
         }
     }
     data = deep_merge(a, b)
     self.assertEqual(data, {
         'a': 1,
         'b': 2,
         'd': 3,
         'c': {
             'd': 3,
             'e': 4,
             'f': 4,
         }
     })
コード例 #2
0
ファイル: models.py プロジェクト: ageron/commis
 def to_search(self):
     data = deep_merge(self.automatic, self.override, self.normal, self.default)
     data['name'] = self.name
     data['chef_type'] = 'node'
     run_list = list(self.run_list.all().order_by('id'))
     data['recipe'] = [entry.name for entry in run_list if entry.type == 'recipe']
     data['role'] = [entry.name for entry in run_list if entry.type == 'role']
     data['run_list'] = [entry.name for entry in run_list]
     return data