Beispiel #1
0
    def test_merge_conflict_is_readable(self):
        ancestor = ('<p>Rosamunde sells delicious gourmet sausages!</p>'
                    '<p>Vegans and beer-lovers are invited!</p>')
        mine = ('<p>Rosamunde sells delicious gourmet sausages!</p>'
                '<p>Vegans and beer-lovers are invited!</p>'
                '<p>Their "mission street" sausage is a $6.50 play on the '
                'classic <a href="/Bacon-wrapped_hot_dogs">bacon wrapped hot '
                'dog</a>.</p>')
        theirs = ('<p>Rosamunde sells delicious gourmet sausages!</p>'
                  '<p>Vegans and beer-lovers are invited!</p>'
                  '<p><a href="http://rosamundesausagegrill.com/haight-street"'
                  '>Menu</a> (Haight Street)</p>'
                  '<p><a href="http://rosamundesausagegrill.com/mission-street'
                  '">Menu</a> (Mission Street)</p>')
        (body, conflict) = daisydiff_merge(mine, theirs, ancestor)

        expected = ('<p>Rosamunde sells delicious gourmet sausages!</p>'
                '<p>Vegans and beer-lovers are invited!</p>'
                '<strong class="editConflict">Edit conflict! Other version:'
                '</strong>'
                '<p><a href="http://rosamundesausagegrill.com/haight-street">'
                'Menu</a> (Haight Street)</p><p>'
                '<a href="http://rosamundesausagegrill.com/mission-street"'
                '>Menu</a> (Mission Street)</p>'
                '<strong class="editConflict">Edit conflict! Your version:'
                '</strong>'
                '<p>Their "mission street" sausage is a $6.50 play on the '
                'classic <a href="/Bacon-wrapped_hot_dogs">bacon wrapped hot '
                'dog</a>.</p>')

        self.failUnless(conflict is True)
        self.failUnlessEqual(body, expected)
Beispiel #2
0
    def test_merge_conflict_is_readable(self):
        ancestor = ('<p>Rosamunde sells delicious gourmet sausages!</p>'
                    '<p>Vegans and beer-lovers are invited!</p>')
        mine = ('<p>Rosamunde sells delicious gourmet sausages!</p>'
                '<p>Vegans and beer-lovers are invited!</p>'
                '<p>Their "mission street" sausage is a $6.50 play on the '
                'classic <a href="/Bacon-wrapped_hot_dogs">bacon wrapped hot '
                'dog</a>.</p>')
        theirs = ('<p>Rosamunde sells delicious gourmet sausages!</p>'
                  '<p>Vegans and beer-lovers are invited!</p>'
                  '<p><a href="http://rosamundesausagegrill.com/haight-street"'
                  '>Menu</a> (Haight Street)</p>'
                  '<p><a href="http://rosamundesausagegrill.com/mission-street'
                  '">Menu</a> (Mission Street)</p>')
        (body, conflict) = daisydiff_merge(mine, theirs, ancestor)

        expected = (
            '<p>Rosamunde sells delicious gourmet sausages!</p>'
            '<p>Vegans and beer-lovers are invited!</p>'
            '<strong class="editConflict">Edit conflict! Other version:'
            '</strong>'
            '<p><a href="http://rosamundesausagegrill.com/haight-street">'
            'Menu</a> (Haight Street)</p><p>'
            '<a href="http://rosamundesausagegrill.com/mission-street"'
            '>Menu</a> (Mission Street)</p>'
            '<strong class="editConflict">Edit conflict! Your version:'
            '</strong>'
            '<p>Their "mission street" sausage is a $6.50 play on the '
            'classic <a href="/Bacon-wrapped_hot_dogs">bacon wrapped hot '
            'dog</a>.</p>')

        self.failUnless(conflict is True)
        self.failUnlessEqual(body, expected)
Beispiel #3
0
 def test_merge_conflict(self):
     (body, conflict) = daisydiff_merge('<p>First version</p>',
                                        '<p>Second version</p>',
                                        '<p>Original</p>')
     self.failUnless(conflict is True)
     self.failUnless('Edit conflict' in body)
     self.failUnless('First version' in body)
     self.failUnless('Second version' in body)
     self.failUnless('Original' not in body)
Beispiel #4
0
 def test_merge_clean(self):
     (body,
      conflict) = daisydiff_merge('<p>New stuff before</p><p>Original</p>',
                                  '<p>Original</p><p>New stuff after</p>',
                                  '<p>Original</p>')
     self.failUnless(conflict is False)
     self.failUnless('New stuff before' in body)
     self.failUnless('Original' in body)
     self.failUnless('New stuff after' in body)
Beispiel #5
0
 def test_merge_clean(self):
     (body, conflict) = daisydiff_merge(
         '<p>New stuff before</p><p>Original</p>',
         '<p>Original</p><p>New stuff after</p>',
         '<p>Original</p>'
     )
     self.failUnless(conflict is False)
     self.failUnless('New stuff before' in body)
     self.failUnless('Original' in body)
     self.failUnless('New stuff after' in body)
Beispiel #6
0
 def test_poor_quality_merge_style(self):
     """
     This doesn't quite work right but at least shouldn't lose anything.
     """
     (body, conflict) = daisydiff_merge(
         '<p><strong>Original</strong></p>',
         '<p><strong>Original</strong></p><p>New stuff</p>',
         '<p>Original</p>')
     self.failUnless(conflict is False)
     self.failUnlessEqual(body, '<p>Original</p><p>New stuff</p>')
Beispiel #7
0
 def test_merge_conflict(self):
     (body, conflict) = daisydiff_merge(
         '<p>First version</p>',
         '<p>Second version</p>',
         '<p>Original</p>'
     )
     self.failUnless(conflict is True)
     self.failUnless('Edit conflict' in body)
     self.failUnless('First version' in body)
     self.failUnless('Second version' in body)
     self.failUnless('Original' not in body)
Beispiel #8
0
 def test_poor_quality_merge_style(self):
     """ This doesn't quite work right but at least shouldn't lose anything
     """
     (body, conflict) = daisydiff_merge(
         '<p><strong>Original</strong></p>',
         '<p><strong>Original</strong></p><p>New stuff</p>',
         '<p>Original</p>'
     )
     self.failUnless(conflict is False)
     self.failUnlessEqual(body,
                         '<p>Original</p><p>New stuff</p>')
Beispiel #9
0
 def merge(self, yours, theirs, ancestor):
     # ancestor may be None
     ancestor_content = ''
     if ancestor:
         ancestor_content = ancestor['content']
     (merged_content, conflict) = daisydiff_merge(
         yours['content'], theirs['content'], ancestor_content
     )
     if conflict:
         self.data = self.data.copy()
         self.data['content'] = merged_content
         raise forms.ValidationError(self.conflict_error)
     else:
         yours['content'] = merged_content
     return yours
Beispiel #10
0
 def merge(self, yours, theirs, ancestor):
     # ancestor may be None
     ancestor_content = ''
     if ancestor:
         ancestor_content = ancestor['content']
     (merged_content, conflict) = daisydiff_merge(yours['content'],
                                                  theirs['content'],
                                                  ancestor_content)
     if conflict:
         self.data = self.data.copy()
         self.data['content'] = merged_content
         raise forms.ValidationError(self.conflict_error)
     else:
         yours['content'] = merged_content
     return yours