Beispiel #1
0
    def test_diff_between_different_hosts(self):
        """
        This test case creates a host and the compares it
        with another different host using the ModelObjectDiff class
        """
        h1 = Host(name='host1', os='Windows')
        h2 = Host(name='host1', os='Linux')

        diff = ModelObjectDiff(h1, h2)

        self.assertTrue(diff.existDiff())
Beispiel #2
0
    def test_diff_between_different_hosts(self):
        """
        This test case creates a host and the compares it
        with another different host using the ModelObjectDiff class
        """
        h1 = Host(name='host1', os='Windows')
        h2 = Host(name='host1', os='Linux')

        diff = ModelObjectDiff(h1, h2)

        self.assertTrue(diff.existDiff())
Beispiel #3
0
 def addUpdate(self, newModelObject):
     conflict = False
     diff = ModelObjectDiff(self, newModelObject)
     for k, v in diff.getPropertiesDiff().items():
         attribute = self.__getAttribute(k)
         prop_update = self.propertyTieBreaker(attribute, *v)
         if isinstance(prop_update, tuple):
             conflict = True
         else:
             setattr(self, attribute, prop_update)
     if conflict:
         self.updates.append(ConflictUpdate(self, newModelObject))
     return conflict
Beispiel #4
0
 def addUpdate(self, newModelObject):
     conflict = False
     diff = ModelObjectDiff(self, newModelObject)
     for k, v in diff.getPropertiesDiff().items():
         attribute = self.__getAttribute(k)
         prop_update = self.propertyTieBreaker(attribute, *v)
         if isinstance(prop_update, tuple):
             conflict = True
         else:
             setattr(self, attribute, prop_update)
     if conflict:
         self.updates.append(ConflictUpdate(self, newModelObject))
     return conflict
Beispiel #5
0
    def addUpdate(self, newModelObject):
        conflict = False
        diff = ModelObjectDiff(self, newModelObject)
        for k, v in diff.getPropertiesDiff().items():
            attribute = self.__getAttribute(k)
            prop_update = self.propertyTieBreaker(attribute, *v)

            if (not isinstance(prop_update, tuple) or CONF.getMergeStrategy()):
                # if there's a strategy set by the user, apply it
                if isinstance(prop_update, tuple):
                    prop_update = MergeSolver(CONF.getMergeStrategy()).solve(
                        prop_update[0], prop_update[1])

                setattr(self, attribute, prop_update)
            else:
                conflict = True
        if conflict:
            self.updates.append(ConflictUpdate(self, newModelObject))
        return conflict
Beispiel #6
0
    def addUpdate(self, newModelObject):
        conflict = False
        diff = ModelObjectDiff(self, newModelObject)
        for k, v in diff.getPropertiesDiff().items():
            attribute = self.publicattrsrefs().get(k)
            prop_update = self.propertyTieBreaker(attribute, *v)

            if not isinstance(prop_update, tuple) or CONF.getMergeStrategy():
                # if there's a strategy set by the user, apply it
                if isinstance(prop_update, tuple):
                    prop_update = MergeSolver(CONF.getMergeStrategy())
                    prop_update = prop_update.solve(prop_update[0], prop_update[1])

                setattr(self, attribute, prop_update)
            else:
                conflict = True
        if conflict:
            self.updates.append(ConflictUpdate(self, newModelObject))
        return conflict
Beispiel #7
0
 def needs_merge(self, new_obj):
     return ModelObjectDiff(self, new_obj).existDiff()