# Path: mcm/comparators.py
# class UniqueKeyComparator:
# 
# 
#     def __init__(self, keys):
# 
#         self.keys = keys
#         self.SET = []
#         self.ADD = []
#         self.NO_DELETE = []
# 
# 
#     def compare(self, wanted, present):
# 
#         for wanted_rule in wanted:
#             present_rule = self.findPair(searched=wanted_rule, present=present)
#             diff = wanted_rule - present_rule
#             self.decide(wanted_rule, diff, present_rule)
# 
#         DEL = set(present) - set(self.NO_DELETE)
#         return tuple(self.ADD), tuple(self.SET), tuple(DEL)
# 
# 
#     def decide(self, wanted, difference, present):
# 
#         if wanted and difference and not present:
#             self.ADD.append( wanted )
#         elif wanted and difference and present:
#             self.NO_DELETE.append(present)
#             difference['.id'] = present['.id']
#             self.SET.append( difference )
#         elif wanted and not difference and present:
#             self.NO_DELETE.append(present)
# 
# 
#     def findPair(self, searched, present):
# 
#         for row in present:
#             if row.isunique(other=searched, keys=self.keys):
#                 return row
#         else:
#             return CmdPathRow(dict())
# 
# class OrderedComparator:
# 
# 
#     def __init__(self):
# 
#         self.DEL = []
#         self.SET= []
#         self.ADD = []
# 
# 
#     def decide(self, wanted, difference, present):
# 
#         if wanted and difference and not present:
#             self.ADD.append( wanted )
#         elif not wanted and not difference and present:
#             self.DEL.append( present )
#         elif wanted and difference and present:
#             difference['.id'] = present['.id']
#             self.SET.append( difference )
# 
# 
#     def compare(self, wanted, present):
# 
#         fillval = CmdPathRow(dict())
#         for wanted_rule, present_rule in zip_longest(wanted, present, fillvalue=fillval):
#             diff = wanted_rule - present_rule
#             self.decide(wanted_rule, diff, present_rule)
# 
#         return tuple(self.ADD), tuple(self.SET), tuple(self.DEL)


from mock import MagicMock, patch
from mcm.comparators import UniqueKeyComparator, OrderedComparator
# -*- coding: UTF-8 -*-




class Test_OrderedComparator:

    def setup(self):
        self.comparator = OrderedComparator()
        self.comparator.SET = MagicMock()
        self.comparator.DEL = MagicMock()
        self.comparator.ADD = MagicMock()
        self.difference = MagicMock()
        self.present = MagicMock()
        self.wanted = MagicMock()


# Path: mcm/comparators.py
# class UniqueKeyComparator:
# 
# 
#     def __init__(self, keys):
# 
#         self.keys = keys
#         self.SET = []
#         self.ADD = []
#         self.NO_DELETE = []
# 
# 
#     def compare(self, wanted, present):
# 
#         for wanted_rule in wanted:
#             present_rule = self.findPair(searched=wanted_rule, present=present)
#             diff = wanted_rule - present_rule
#             self.decide(wanted_rule, diff, present_rule)
# 
#         DEL = set(present) - set(self.NO_DELETE)
#         return tuple(self.ADD), tuple(self.SET), tuple(DEL)
# 
# 
#     def decide(self, wanted, difference, present):
# 
#         if wanted and difference and not present:
#             self.ADD.append( wanted )
#         elif wanted and difference and present:
#             self.NO_DELETE.append(present)
#             difference['.id'] = present['.id']
#             self.SET.append( difference )
#         elif wanted and not difference and present:
#             self.NO_DELETE.append(present)
# 
# 
#     def findPair(self, searched, present):
# 
#         for row in present:
#             if row.isunique(other=searched, keys=self.keys):
#                 return row
#         else:
#             return CmdPathRow(dict())
# 
# class OrderedComparator:
# 
# 
#     def __init__(self):
# 
#         self.DEL = []
#         self.SET= []
#         self.ADD = []
# 
# 
#     def decide(self, wanted, difference, present):
# 
#         if wanted and difference and not present:
#             self.ADD.append( wanted )
#         elif not wanted and not difference and present:
#             self.DEL.append( present )
#         elif wanted and difference and present:
#             difference['.id'] = present['.id']
#             self.SET.append( difference )
# 
# 
#     def compare(self, wanted, present):
# 
#         fillval = CmdPathRow(dict())
#         for wanted_rule, present_rule in zip_longest(wanted, present, fillvalue=fillval):
#             diff = wanted_rule - present_rule
#             self.decide(wanted_rule, diff, present_rule)
# 
#         return tuple(self.ADD), tuple(self.SET), tuple(self.DEL)


# Path: tests/test_comparators.py
from mock import MagicMock, patch
from mcm.comparators import UniqueKeyComparator, OrderedComparator

# -*- coding: UTF-8 -*-




class Test_OrderedComparator:

    def setup(self):
        self.comparator = OrderedComparator()
        self.comparator.SET = MagicMock()
        self.comparator.DEL = MagicMock()
        self.comparator.ADD = MagicMock()
        self.difference = MagicMock()
        self.present = MagicMock()
        self.wanted = MagicMock()


    def test_appends_to_ADD(self):