Exemplo n.º 1
0
 def test_get_modified_attributes_for_nonintersecting_list(self):
     ''' validate modified attributes for list diff '''
     current = {'name': ['two', 'four', 'six', 'eight']}
     desired = {'name': ['a', 'ab', 'abd']}
     my_obj = na_helper()
     result = my_obj.get_modified_attributes(current, desired, True)
     assert result == {'name': ['a', 'ab', 'abd']}
Exemplo n.º 2
0
 def test_get_modified_attributes_for_nonintersecting_list_of_dicts(self):
     ''' validate modified attributes for list diff '''
     current = {'address_blocks': [{'start': '10.10.10.23', 'size': 5}, {'start': '10.10.10.30', 'size': 5}]}
     desired = {'address_blocks': [{'start': '10.20.10.23', 'size': 5}, {'start': '10.20.10.30', 'size': 5}, {'start': '10.20.10.40', 'size': 5}]}
     my_obj = na_helper()
     result = my_obj.get_modified_attributes(current, desired, True)
     assert result == {'address_blocks': [{'start': '10.20.10.23', 'size': 5}, {'start': '10.20.10.30', 'size': 5}, {'start': '10.20.10.40', 'size': 5}]}
Exemplo n.º 3
0
 def test_get_modified_attributes_for_no_data(self):
     ''' validate modified attributes when current is None '''
     current = None
     desired = {'name': 'test'}
     my_obj = na_helper()
     result = my_obj.get_modified_attributes(current, desired)
     assert result == {}
Exemplo n.º 4
0
 def test_get_modified_attributes(self):
     ''' validate modified attributes '''
     current = {'name': ['test', 'abcd', 'xyz', 'pqr'], 'state': 'present'}
     desired = {'name': ['abcd', 'abc', 'xyz', 'pqr'], 'state': 'absent'}
     my_obj = na_helper()
     result = my_obj.get_modified_attributes(current, desired)
     assert result == desired
Exemplo n.º 5
0
 def test_get_cd_action_delete(self):
     ''' validate cd_action for delete '''
     current = {'state': 'absent'}
     desired = {'state': 'absent'}
     my_obj = na_helper()
     result = my_obj.get_cd_action(current, desired)
     assert result == 'delete'
Exemplo n.º 6
0
 def test_get_cd_action(self):
     ''' validate cd_action for returning None '''
     current = None
     desired = {'state': 'absent'}
     my_obj = na_helper()
     result = my_obj.get_cd_action(current, desired)
     assert result is None
Exemplo n.º 7
0
 def test_get_cd_action_create(self):
     ''' validate cd_action for create '''
     current = None
     desired = {'state': 'present'}
     my_obj = na_helper()
     result = my_obj.get_cd_action(current, desired)
     assert result == 'create'
Exemplo n.º 8
0
 def test_is_rename_action(self):
     ''' validate rename action '''
     source = 'test'
     target = 'test2'
     my_obj = na_helper()
     result = my_obj.is_rename_action(source, target)
     assert result is False
Exemplo n.º 9
0
 def test_is_rename_action_for_no_target(self):
     ''' validate rename action when target is None '''
     source = 'test2'
     target = None
     my_obj = na_helper()
     result = my_obj.is_rename_action(source, target)
     assert result is True
Exemplo n.º 10
0
 def test_is_rename_action_for_no_source(self):
     ''' validate rename action when source is None '''
     source = None
     target = 'test2'
     my_obj = na_helper()
     result = my_obj.is_rename_action(source, target)
     assert result is False
Exemplo n.º 11
0
 def test_is_rename_action_for_empty_input(self):
     ''' validate rename action for input None '''
     source = None
     target = None
     my_obj = na_helper()
     result = my_obj.is_rename_action(source, target)
     assert result == source
Exemplo n.º 12
0
 def test_get_modified_attributes_for_no_change(self):
     ''' validate modified attributes for same data in current and desired '''
     current = {'name': 'test'}
     desired = {'name': 'test'}
     my_obj = na_helper()
     result = my_obj.get_modified_attributes(current, desired)
     assert result == {}
Exemplo n.º 13
0
 def test_get_modified_attributes_for_list_diff(self):
     ''' validate modified attributes for list diff '''
     current = {'name': ['test', 'abcd'], 'state': 'present'}
     desired = {'name': ['abcd', 'abc'], 'state': 'present'}
     my_obj = na_helper()
     result = my_obj.get_modified_attributes(current, desired, True)
     assert result == {'name': ['abc']}