def test_merge_three_conditions(self):
   values = {
     ('linux',): {
       'isolate_dependency_tracked': ['file_common', 'file_linux'],
     },
     ('mac',): {
       'isolate_dependency_tracked': ['file_common', 'file_mac'],
     },
     ('win',): {
       'isolate_dependency_tracked': ['file_common', 'file_win'],
     },
   }
   expected = {
     'conditions': [
       ['OS=="linux"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_linux',
           ],
         },
       }],
       ['OS=="linux" or OS=="mac" or OS=="win"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_common',
           ],
         },
       }],
       ['OS=="mac"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_mac',
           ],
         },
       }],
       ['OS=="win"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_win',
           ],
         },
       }],
     ],
   }
   actual = isolate_format.convert_map_to_isolate_dict(
       isolate_format.reduce_inputs(isolate_format.invert_map(values)),
       ('OS',))
   self.assertEqual(expected, actual)
 def test_merge_empty(self):
   actual = isolate_format.convert_map_to_isolate_dict(
       isolate_format.reduce_inputs(isolate_format.invert_map({})),
       ('dummy1', 'dummy2'))
   self.assertEqual({'conditions': []}, actual)
 def test_invert_map(self):
   value = {
     ('amiga',): {
       'command': ['echo', 'You should get an Atari'],
       KEY_TOUCHED: ['touched', 'touched_e'],
       KEY_TRACKED: ['a', 'e', 'g', 'x'],
       KEY_UNTRACKED: ['b', 'f', 'h'],
       'read_only': 0,
     },
     ('atari',): {
       'command': ['echo', 'Hello World'],
       KEY_TOUCHED: ['touched', 'touched_a'],
       KEY_TRACKED: ['a', 'c', 'x'],
       KEY_UNTRACKED: ['b', 'd', 'h'],
       'read_only': 1,
     },
     ('coleco',): {
       'command': ['echo', 'You should get an Atari'],
       KEY_TOUCHED: ['touched', 'touched_e'],
       KEY_TRACKED: ['a', 'e', 'x'],
       KEY_UNTRACKED: ['b', 'f'],
     },
     ('dendy',): {
       'command': ['echo', 'You should get an Atari'],
       KEY_TOUCHED: ['touched', 'touched_e'],
       KEY_TRACKED: ['a', 'e', 'x'],
       KEY_UNTRACKED: ['b', 'f', 'h'],
     },
   }
   amiga, atari, coleco, dendy = (
       set([(os,)]) for os in ('amiga', 'atari', 'coleco', 'dendy'))
   expected_values = {
     'command': {
       ('echo', 'Hello World'): atari,
       ('echo', 'You should get an Atari'): amiga | coleco | dendy,
     },
     KEY_TRACKED: {
       'a': amiga | atari | coleco | dendy,
       'c': atari,
       'e': amiga | coleco | dendy,
       'g': amiga,
       'x': amiga | atari | coleco | dendy,
     },
     KEY_UNTRACKED: {
       'b': amiga | atari | coleco | dendy,
       'd': atari,
       'f': amiga | coleco | dendy,
       'h': amiga | atari | dendy,
     },
     KEY_TOUCHED: {
       'touched': amiga | atari | coleco | dendy,
       'touched_a': atari,
       'touched_e': amiga | coleco | dendy,
     },
     'read_only': {
       0: amiga,
       1: atari,
     },
   }
   actual_values = isolate_format.invert_map(value)
   self.assertEqual(expected_values, actual_values)