diff tests/test_fetch_command_regexes.py @ 859:1d07e86f5797

stupid: handle changes in svn 1.7 diff format Metadata changes are now represented like: Property changes on: a ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* instead of: Property changes on: a ___________________________________________________________________ Added: svn:executable + * Also, I got tired of massaging the diff with regexps, so I extracted the parsing logic in parsediff(). This is no small refactoring but it makes things cleaner and the test suite pass on 1.6 and 1.7 so...
author Patrick Mezard <patrick@mezard.eu>
date Thu, 19 Apr 2012 14:59:50 +0200
parents 46e69be8e2c8
children d741f536f23a
line wrap: on
line diff
--- a/tests/test_fetch_command_regexes.py
+++ b/tests/test_fetch_command_regexes.py
@@ -48,28 +48,99 @@ Name: svn:special
 
 class RegexTests(unittest.TestCase):
     def test_empty_file_re(self):
-        matches = stupid.empty_file_patch_wont_make_re.findall(two_empties)
-        assert sorted(matches) == ['__init__.py', 'bar/__init__.py']
+        changed = stupid.parsediff(two_empties)
+        self.assertEqual(3, len(changed))
+        self.assertEqual('__init__.py', changed[0].name)
+        self.assert_(changed[0].isempty())
+        self.assertEqual('bar/__init__.py', changed[1].name)
+        self.assert_(changed[1].isempty())
+        self.assertEqual('bar/test_muhaha.py', changed[2].name)
+        self.assert_(not changed[2].isempty())
 
     def test_any_matches_just_one(self):
         pat = '''Index: trunk/django/contrib/admin/urls/__init__.py
 ===================================================================
 '''
-        matches = stupid.any_file_re.findall(pat)
-        assert len(matches) == 1
+        changed = stupid.parsediff(pat)
+        self.assertEqual(['trunk/django/contrib/admin/urls/__init__.py'],
+                         [f.name for f in changed])
 
     def test_special_re(self):
-        matches = stupid.property_special_set_re.findall(special_delta)
-        assert len(matches) == 1
+        changed = stupid.parsediff(special_delta)
+        self.assertEqual(1, len(changed))
+        self.assert_(changed[0].symlink)
 
     def test_any_file_re(self):
-        matches = stupid.any_file_re.findall(two_empties)
-        assert sorted(matches) == ['__init__.py', 'bar/__init__.py',
-                                   'bar/test_muhaha.py']
+        changed = stupid.parsediff(two_empties)
+        self.assertEqual(['__init__.py', 'bar/__init__.py', 'bar/test_muhaha.py'],
+                         [f.name for f in changed])
 
     def test_binary_file_re(self):
-        matches = stupid.binary_file_re.findall(binary_delta)
-        assert matches == ['trunk/functional_tests/doc_tests/test_doctest_fixtures/doctest_fixtures_fixtures.pyc']
+        changed = stupid.parsediff(binary_delta)
+        binaries = [f.name for f in changed if f.binary]
+        self.assertEqual(['trunk/functional_tests/doc_tests/test_doctest_fixtures/doctest_fixtures_fixtures.pyc'],
+                         binaries)
+
+    def test_diff16(self):
+        data = """Index: d3/d
+===================================================================
+--- d3/d        (revision 0)
++++ d3/d        (revision 6)
+@@ -0,0 +1 @@
++d
+
+Property changes on: d3
+___________________________________________________________________
+Added: svn:externals
+   + ^/trunk/common/ext ext3
+
+
+
+Property changes on: .
+___________________________________________________________________
+Added: svn:mergeinfo
+   Merged /branches/branch:r4-5
+"""
+        changed = stupid.parsediff(data)
+        self.assertEqual(['d3/d', 'd3', '.'], [f.name for f in changed])
+        data = """Property changes on: empty1
+___________________________________________________________________
+Deleted: svn:executable
+   - *
+
+
+Property changes on: empty2
+___________________________________________________________________
+Added: svn:executable
+   + *
+
+
+Property changes on: binary1
+___________________________________________________________________
+Deleted: svn:executable
+   - *
+
+
+Property changes on: text1
+___________________________________________________________________
+Deleted: svn:executable
+   - *
+
+
+Property changes on: binary2
+___________________________________________________________________
+Added: svn:executable
+   + *
+
+
+Property changes on: text2
+___________________________________________________________________
+Added: svn:executable
+   + *
+"""
+        changed = stupid.parsediff(data)
+        self.assertEqual(['empty1', 'empty2', 'binary1', 'text1', 'binary2', 'text2'],
+                         [f.name for f in changed])
 
 def suite():
     return unittest.TestLoader().loadTestsFromTestCase(RegexTests)