view tests/test_fetch_command_regexes.py @ 131:4d42dbbb5127

hg_delta_editor: fix parent revision detection on branch copy Project items copyfrom revisions are irrelevant to parent revision detection, only the project one or those of its ancestors matter. Items copyfrom is useful when retrieving items content. Former code resulted in incorrect converted graph for pyglet repository, especially on the following revision: ------------------------------------------------------------------------ r274 | r1chardj0n3s | 2006-12-21 02:02:14 +0100 (Jeu, 21 Dec 2006) | 2 lines Changed paths: A /branches/richard-glx-version (from /trunk:269) M /branches/richard-glx-version/pyglet/window/xlib/__init__.py R /branches/richard-glx-version/tests/test.py (from /trunk/tests/test.py:270) R /branches/richard-glx-version/tools/info.py (from /trunk/tools/info.py:272) R /branches/richard-glx-version/website/get_involved.php (from /trunk/website/get_involved.php:273) Branching to horribly mangle GLX
author Patrick Mezard <pmezard@gmail.com>
date Wed, 10 Dec 2008 11:03:22 -0600
parents 99f8e4b535e9
children e2214c8fc91f
line wrap: on
line source

import fetch_command
import unittest

two_empties = """Index: __init__.py
===================================================================
Index: bar/__init__.py
===================================================================
Index: bar/test_muhaha.py
===================================================================
--- bar/test_muhaha.py	(revision 0)
+++ bar/test_muhaha.py	(revision 1)
@@ -0,0 +1,2 @@
+
+blah blah blah, I'm a fake patch
\ No newline at end of file
"""

binary_delta = """Index: trunk/functional_tests/doc_tests/test_doctest_fixtures/doctest_fixtures_fixtures.pyc
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: trunk/functional_tests/doc_tests/test_doctest_fixtures/doctest_fixtures_fixtures.pyc
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: trunk/functional_tests/doc_tests/test_doctest_fixtures/doctest_fixtures.rst
===================================================================
"""

special_delta = """Index: delta
===================================================================
--- delta(revision 0)
+++ delta(revision 9)
@@ -0,0 +1 @@
+link alpha
\ No newline at end of file

Property changes on: delta
___________________________________________________________________
Name: svn:special
   + *

"""

class RegexTests(unittest.TestCase):
    def test_empty_file_re(self):
        matches = fetch_command.empty_file_patch_wont_make_re.findall(two_empties)
        assert sorted(matches) == ['__init__.py', 'bar/__init__.py']

    def test_any_matches_just_one(self):
        pat = '''Index: trunk/django/contrib/admin/urls/__init__.py
===================================================================
'''
        matches = fetch_command.any_file_re.findall(pat)
        assert len(matches) == 1

    def test_special_re(self):
        matches = fetch_command.property_special_set_re.findall(special_delta)
        assert len(matches) == 1

    def test_any_file_re(self):
        matches = fetch_command.any_file_re.findall(two_empties)
        assert sorted(matches) == ['__init__.py', 'bar/__init__.py',
                                   'bar/test_muhaha.py']

    def test_binary_file_re(self):
        matches = fetch_command.binary_file_re.findall(binary_delta)
        assert matches == ['trunk/functional_tests/doc_tests/test_doctest_fixtures/doctest_fixtures_fixtures.pyc']

def suite():
    return unittest.TestLoader().loadTestsFromTestCase(RegexTests)