Example #1
0
def secondlevel_test():
  # Make sure merging on 2nd-level works
  level_two_dict = {
    'levelone':{'children':{
        'leveltwoprime':{'callback': nullfunction, 'help_text': 'Help 2`', 'summary': 'Summary 2`', 'children':{}},
    }},
  }
  
  level_two_expected = {
    'levelone':{'callback': nullfunction, 'help_text': 'Help 1', 'summary': 'Summary 1', 'children':{
        'leveltwo':{'callback': nullfunction, 'help_text': 'Help 2', 'summary': 'Summary 2', 'children':{}},
        'leveltwoprime':{'callback': nullfunction, 'help_text': 'Help 2`', 'summary': 'Summary 2`', 'children':{}},
    }},
  }
  
  testdict = deepcopy(original_dict)
  seash_modules.merge_commanddict(testdict, level_two_dict)
  if not seash_modules.are_cmddicts_same(testdict, level_two_expected):
    import pdb;
    pdb.set_trace()
    raise Exception("Failed to merge dictionaries on 2nd level")
  
  # Repeat the same test the other way around
  testdict = deepcopy(level_two_dict)
  seash_modules.merge_commanddict(testdict, original_dict) 
  if not seash_modules.are_cmddicts_same(testdict, level_two_expected):
    raise Exception("Failed to merge dictionaries on 2nd level")
def branch_test():
    testdict = deepcopy(COMBINED_DICT)
    seash_modules.remove_commanddict(testdict, SHOW_DICT)

    if not seash_modules.are_cmddicts_same(testdict, GET_DICT):
        raise Exception("Failed to remove entire command branch GET")

    # Repeat the same test the other way around
    testdict = deepcopy(COMBINED_DICT)
    seash_modules.remove_commanddict(testdict, GET_DICT)

    if not seash_modules.are_cmddicts_same(testdict, SHOW_DICT):
        raise Exception("Failed to remove entire command branch SHOW")
def branch_test():  
  testdict = deepcopy(COMBINED_DICT)
  seash_modules.remove_commanddict(testdict, SHOW_DICT)
  
  if not seash_modules.are_cmddicts_same(testdict, GET_DICT):
    raise Exception("Failed to remove entire command branch GET")
  
  # Repeat the same test the other way around
  testdict = deepcopy(COMBINED_DICT)
  seash_modules.remove_commanddict(testdict, GET_DICT)
  
  if not seash_modules.are_cmddicts_same(testdict, SHOW_DICT):
    raise Exception("Failed to remove entire command branch SHOW")
Example #4
0
def secondlevel_test():
    # Make sure merging on 2nd-level works
    level_two_dict = {
        'levelone': {
            'children': {
                'leveltwoprime': {
                    'callback': nullfunction,
                    'help_text': 'Help 2`',
                    'summary': 'Summary 2`',
                    'children': {}
                },
            }
        },
    }

    level_two_expected = {
        'levelone': {
            'callback': nullfunction,
            'help_text': 'Help 1',
            'summary': 'Summary 1',
            'children': {
                'leveltwo': {
                    'callback': nullfunction,
                    'help_text': 'Help 2',
                    'summary': 'Summary 2',
                    'children': {}
                },
                'leveltwoprime': {
                    'callback': nullfunction,
                    'help_text': 'Help 2`',
                    'summary': 'Summary 2`',
                    'children': {}
                },
            }
        },
    }

    testdict = deepcopy(original_dict)
    seash_modules.merge_commanddict(testdict, level_two_dict)
    if not seash_modules.are_cmddicts_same(testdict, level_two_expected):
        import pdb
        pdb.set_trace()
        raise Exception("Failed to merge dictionaries on 2nd level")

    # Repeat the same test the other way around
    testdict = deepcopy(level_two_dict)
    seash_modules.merge_commanddict(testdict, original_dict)
    if not seash_modules.are_cmddicts_same(testdict, level_two_expected):
        raise Exception("Failed to merge dictionaries on 2nd level")
def singlecommand_test():
  # Removing a child node when there are other siblings must not have
  # affect the other siblings
  testdict = deepcopy(SHOW_DICT)
  seash_modules.remove_commanddict(testdict, SHOW_X_DICT)
  
  if not seash_modules.are_cmddicts_same(testdict, SHOW_DEFINED_Y_DICT):
    raise Exception("Failed to remove child node")
  
  # When removing a child node with a parent definition when there are other 
  # siblings, we should remove the parent definition as well. 
  testdict = deepcopy(SHOW_DICT)
  seash_modules.remove_commanddict(testdict, SHOW_DEFINED_Y_DICT)
  
  if not seash_modules.are_cmddicts_same(testdict, SHOW_X_DICT):
    raise Exception("Failed to remove parent node definition when removing child node")
def singlecommand_test():
  # Removing a child node when there are other siblings must not have
  # affect the other siblings
  testdict = deepcopy(SHOW_DICT)
  seash_modules.remove_commanddict(testdict, SHOW_X_DICT)
  
  if not seash_modules.are_cmddicts_same(testdict, SHOW_DEFINED_Y_DICT):
    raise Exception("Failed to remove child node")
  
  # When removing a child node with a parent definition when there are other 
  # siblings, we should remove the parent definition as well. 
  testdict = deepcopy(SHOW_DICT)
  seash_modules.remove_commanddict(testdict, SHOW_DEFINED_Y_DICT)
  
  if not seash_modules.are_cmddicts_same(testdict, SHOW_X_DICT):
    raise Exception("Failed to remove parent node definition when removing child node")
Example #7
0
def rootlevel_test():
    level_one_dict = {
        'leveloneprime': {
            'callback': nullfunction,
            'help_text': 'Help 1`',
            'summary': 'Summary 1`',
            'children': {}
        },
    }

    level_one_expected = {
        'levelone': {
            'callback': nullfunction,
            'help_text': 'Help 1',
            'summary': 'Summary 1',
            'children': {
                'leveltwo': {
                    'callback': nullfunction,
                    'help_text': 'Help 2',
                    'summary': 'Summary 2',
                    'children': {}
                },
            }
        },
        'leveloneprime': {
            'callback': nullfunction,
            'help_text': 'Help 1`',
            'summary': 'Summary 1`',
            'children': {}
        },
    }

    testdict = deepcopy(original_dict)
    seash_modules.merge_commanddict(testdict, level_one_dict)
    if not seash_modules.are_cmddicts_same(testdict, level_one_expected):
        raise Exception("Failed to merge dictionaries on root level")

    # Repeat the same test the other way around
    testdict = deepcopy(level_one_dict)
    seash_modules.merge_commanddict(testdict, original_dict)
    if not seash_modules.are_cmddicts_same(testdict, level_one_expected):
        raise Exception("Failed to merge dictionaries on root level")
Example #8
0
def rootlevel_test():
  level_one_dict = {
    'leveloneprime':{'callback': nullfunction, 'help_text': 'Help 1`', 'summary': 'Summary 1`', 'children':{}},
  }
  
  level_one_expected = {
    'levelone':{'callback': nullfunction, 'help_text': 'Help 1', 'summary': 'Summary 1', 'children':{
        'leveltwo':{'callback': nullfunction, 'help_text': 'Help 2', 'summary': 'Summary 2', 'children':{}},
    }},
    'leveloneprime':{'callback': nullfunction, 'help_text': 'Help 1`', 'summary': 'Summary 1`', 'children':{}},
  }
  
  testdict = deepcopy(original_dict)
  seash_modules.merge_commanddict(testdict, level_one_dict)
  if not seash_modules.are_cmddicts_same(testdict, level_one_expected):
    raise Exception("Failed to merge dictionaries on root level")
  
  # Repeat the same test the other way around
  testdict = deepcopy(level_one_dict)
  seash_modules.merge_commanddict(testdict, original_dict) 
  if not seash_modules.are_cmddicts_same(testdict, level_one_expected):
    raise Exception("Failed to merge dictionaries on root level")