Пример #1
0
 def _minimize_changes(self):
     add_list, edit_list, delete_list = [], [], []
     
     if "ADD" in self._changes.keys():
         add_list = self._changes["ADD"]
     if "EDIT" in self._changes.keys():
         edit_list = self._changes["EDIT"]
     if "DELETE" in self._changes.keys():
         delete_list = self._changes["DELETE"]
     add_list, edit_list, delete_list = remove_common_elements(add_list, edit_list,  delete_list)
     add_list, delete_list, _ = remove_common_elements(add_list, delete_list)
     edit_list, _, _ = remove_common_elements(edit_list, add_list)
     edit_list, _, _ = remove_common_elements(edit_list, delete_list)
     
     
     self._changes["ADD"] = add_list
     self._changes["EDIT"] = edit_list
     self._changes["DELETE"] = delete_list
Пример #2
0
def test_rce_two_similar_lists(two_similar_lists):
    """
    output of remove_common_elements for two similar lists should be two 
    empty lists.
    """
    lists = two_similar_lists
    list1, list2, _ = utils.remove_common_elements(lists[0], lists[1])
    assert list1 == []
    assert list2 == []    
    assert isinstance(list1, list)
    assert isinstance(list2, list)
Пример #3
0
def test_rce_two_similar_lists(two_similar_lists):
    """
    output of remove_common_elements for two similar lists should be two 
    empty lists.
    """
    lists = two_similar_lists
    list1, list2, _ = utils.remove_common_elements(lists[0], lists[1])
    assert list1 == []
    assert list2 == []
    assert isinstance(list1, list)
    assert isinstance(list2, list)
Пример #4
0
def test_rce_three_dissimilar_lists(three_dissimilar_lists):
    """
    output of remove_common_elements for three dissimilar lists should be three 
    lists containing same elements as the input lists.
    """
    lists = three_dissimilar_lists
    list1, list2, list3 = utils.remove_common_elements(lists[0], lists[1], lists[2])
    assert set(list1) == set(lists[0])
    assert set(list2) == set(lists[1])
    assert set(list3) == set(lists[2])
    assert isinstance(list1, list)
    assert isinstance(list2, list)
    assert isinstance(list3, list)
Пример #5
0
def test_rce_three_similar_lists(three_similar_lists):
    """
    output of remove_common_elements for three similar lists should be three 
    empty lists.
    """
    lists = three_similar_lists
    list1, list2, list3 = utils.remove_common_elements(lists[0], lists[1], lists[2])
    assert list1 == []
    assert list2 == []
    assert list3 == []    
    assert isinstance(list1, list)
    assert isinstance(list2, list)
    assert isinstance(list3, list)
Пример #6
0
def test_rce_three_dissimilar_lists(three_dissimilar_lists):
    """
    output of remove_common_elements for three dissimilar lists should be three 
    lists containing same elements as the input lists.
    """
    lists = three_dissimilar_lists
    list1, list2, list3 = utils.remove_common_elements(lists[0], lists[1],
                                                       lists[2])
    assert set(list1) == set(lists[0])
    assert set(list2) == set(lists[1])
    assert set(list3) == set(lists[2])
    assert isinstance(list1, list)
    assert isinstance(list2, list)
    assert isinstance(list3, list)
Пример #7
0
def test_rce_three_similar_lists(three_similar_lists):
    """
    output of remove_common_elements for three similar lists should be three 
    empty lists.
    """
    lists = three_similar_lists
    list1, list2, list3 = utils.remove_common_elements(lists[0], lists[1],
                                                       lists[2])
    assert list1 == []
    assert list2 == []
    assert list3 == []
    assert isinstance(list1, list)
    assert isinstance(list2, list)
    assert isinstance(list3, list)
Пример #8
0
def test_rce_disjoint_output(two_intersecting_lists):
    """
    output of remove_common_elements for two dissimilar lists should be two 
    lists which won't have any common elements. aka output needs to be disjoint.
    """
    lists = two_intersecting_lists
    
    list1, list2, _ = utils.remove_common_elements(lists[0], lists[1])
    """
    the output lists must be disjoint too.
    """
    assert any([el in list1 for el in list2]) == False
    """
    output should be lists.
    """
    assert isinstance(list1, list)
    assert isinstance(list2, list)
Пример #9
0
def test_rce_disjoint_output(two_intersecting_lists):
    """
    output of remove_common_elements for two dissimilar lists should be two 
    lists which won't have any common elements. aka output needs to be disjoint.
    """
    lists = two_intersecting_lists

    list1, list2, _ = utils.remove_common_elements(lists[0], lists[1])
    """
    the output lists must be disjoint too.
    """
    assert any([el in list1 for el in list2]) == False
    """
    output should be lists.
    """
    assert isinstance(list1, list)
    assert isinstance(list2, list)
Пример #10
0
def test_rce_two_disjoint_lists(two_disjoint_lists):
    """
    output of remove_common_elements for two disjoint lists should be two 
    lists containing same elements as the input lists.
    """
    lists = two_disjoint_lists
    list1, list2, _ = utils.remove_common_elements(lists[0], lists[1])
    assert set(list1) == set(lists[0])
    assert set(list2) == set(lists[1])
    """
    the output lists must be disjoint too.
    """
    assert any([el in list1 for el in list2]) == False
    """
    output should be lists.
    """
    assert isinstance(list1, list)
    assert isinstance(list2, list)
Пример #11
0
def test_rce_two_disjoint_lists(two_disjoint_lists):
    """
    output of remove_common_elements for two disjoint lists should be two 
    lists containing same elements as the input lists.
    """
    lists = two_disjoint_lists
    list1, list2, _ = utils.remove_common_elements(lists[0], lists[1])
    assert set(list1) == set(lists[0])
    assert set(list2) == set(lists[1])
    """
    the output lists must be disjoint too.
    """
    assert any([el in list1 for el in list2]) == False
    """
    output should be lists.
    """
    assert isinstance(list1, list)
    assert isinstance(list2, list)