Ejemplo n.º 1
0
 def test_merge_map(self):
     tests = [
         # 2 lists of stacks defined
         [{'stacks': [{'stack1': {'variables': {'a': 'b'}}}]},
          {'stacks': [{'stack2': {'variables': {'c': 'd'}}}]},
          {'stacks': [
              {'stack1': {
                  'variables': {
                      'a': 'b'}}},
              {'stack2': {
                  'variables': {
                      'c': 'd'}}}]}],
         # A list of stacks combined with a higher precedence dict of stacks
         [{'stacks': [{'stack1': {'variables': {'a': 'b'}}}]},
          {'stacks': {'stack2': {'variables': {'c': 'd'}}}},
          {'stacks': {'stack2': {'variables': {'c': 'd'}}}}],
         # 2 dicts of stacks with non-overlapping variables merged
         [{'stacks': {'stack1': {'variables': {'a': 'b'}}}},
          {'stacks': {'stack1': {'variables': {'c': 'd'}}}},
          {'stacks': {
              'stack1': {
                  'variables': {
                      'a': 'b',
                      'c': 'd'}}}}],
         # 2 dicts of stacks with overlapping variables merged
         [{'stacks': {'stack1': {'variables': {'a': 'b'}}}},
          {'stacks': {'stack1': {'variables': {'a': 'c'}}}},
          {'stacks': {'stack1': {'variables': {'a': 'c'}}}}],
     ]
     for t in tests:
         self.assertEqual(merge_map(t[0], t[1]), t[2])
Ejemplo n.º 2
0
 def test_merge_map(self):
     tests = [
         # 2 lists of stacks defined
         [{'stacks': [{'stack1': {'variables': {'a': 'b'}}}]},
          {'stacks': [{'stack2': {'variables': {'c': 'd'}}}]},
          {'stacks': [
              {'stack1': {
                  'variables': {
                      'a': 'b'}}},
              {'stack2': {
                  'variables': {
                      'c': 'd'}}}]}],
         # A list of stacks combined with a higher precedence dict of stacks
         [{'stacks': [{'stack1': {'variables': {'a': 'b'}}}]},
          {'stacks': {'stack2': {'variables': {'c': 'd'}}}},
          {'stacks': {'stack2': {'variables': {'c': 'd'}}}}],
         # 2 dicts of stacks with non-overlapping variables merged
         [{'stacks': {'stack1': {'variables': {'a': 'b'}}}},
          {'stacks': {'stack1': {'variables': {'c': 'd'}}}},
          {'stacks': {
              'stack1': {
                  'variables': {
                      'a': 'b',
                      'c': 'd'}}}}],
         # 2 dicts of stacks with overlapping variables merged
         [{'stacks': {'stack1': {'variables': {'a': 'b'}}}},
          {'stacks': {'stack1': {'variables': {'a': 'c'}}}},
          {'stacks': {'stack1': {'variables': {'a': 'c'}}}}],
     ]
     for t in tests:
         self.assertEqual(merge_map(t[0], t[1]), t[2])