# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Test FilterProcessor"""
-from __future__ import unicode_literals
-from future import standard_library
-standard_library.install_aliases()
-from builtins import str
-
from io import StringIO
from unittest import TestCase
# A sample input stream containing all (top level) import commands
_SAMPLE_ALL = \
-"""blob
+u"""blob
mark :1
data 4
foo
# doc/README.txt
# doc/index.txt
_SAMPLE_WITH_DIR = \
-"""blob
+u"""blob
mark :1
data 9
Welcome!
# * from clause is dropped from the first command
params = {'include_paths': ['NEWS']}
self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-"""blob
+u"""blob
mark :2
data 17
Life
# * other files changed in matching commits are excluded
params = {'include_paths': ['doc/index.txt']}
self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-"""blob
+u"""blob
mark :4
data 11
== Docs ==
# * from updated to reference parents in the output
params = {'include_paths': ['doc/README.txt']}
self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-"""blob
+u"""blob
mark :1
data 9
Welcome!
def test_subdir(self):
params = {'include_paths': ['doc/']}
self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-"""blob
+u"""blob
mark :1
data 9
Welcome!
# The new root should be the subdrectory
params = {'include_paths': ['doc/README.txt', 'doc/index.txt']}
self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-"""blob
+u"""blob
mark :1
data 9
Welcome!
def test_file_in_root(self):
params = {'exclude_paths': ['NEWS']}
self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-"""blob
+u"""blob
mark :1
data 9
Welcome!
def test_file_in_subdir(self):
params = {'exclude_paths': ['doc/README.txt']}
self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-"""blob
+u"""blob
mark :2
data 17
Life
def test_subdir(self):
params = {'exclude_paths': ['doc/']}
self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-"""blob
+u"""blob
mark :2
data 17
Life
def test_multple_files(self):
params = {'exclude_paths': ['doc/index.txt', 'NEWS']}
self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-"""blob
+u"""blob
mark :1
data 9
Welcome!
def test_included_dir_and_excluded_file(self):
params = {'include_paths': ['doc/'], 'exclude_paths': ['doc/index.txt']}
self.assertFiltering(_SAMPLE_WITH_DIR, params, \
-"""blob
+u"""blob
mark :1
data 9
Welcome!
#
# It then renames doc/README.txt => doc/README
_SAMPLE_WITH_RENAME_INSIDE = _SAMPLE_WITH_DIR + \
-"""commit refs/heads/master
+u"""commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
#
# It then renames doc/README.txt => README
_SAMPLE_WITH_RENAME_TO_OUTSIDE = _SAMPLE_WITH_DIR + \
-"""commit refs/heads/master
+u"""commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
#
# It then renames NEWS => doc/NEWS
_SAMPLE_WITH_RENAME_TO_INSIDE = _SAMPLE_WITH_DIR + \
-"""commit refs/heads/master
+u"""commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
# These rename commands ought to be kept but adjusted for the new root
params = {'include_paths': ['doc/']}
self.assertFiltering(_SAMPLE_WITH_RENAME_INSIDE, params, \
-"""blob
+u"""blob
mark :1
data 9
Welcome!
# These rename commands become deletes
params = {'include_paths': ['doc/']}
self.assertFiltering(_SAMPLE_WITH_RENAME_TO_OUTSIDE, params, \
-"""blob
+u"""blob
mark :1
data 9
Welcome!
# This ought to create a new file but doesn't yet
params = {'include_paths': ['doc/']}
self.assertFiltering(_SAMPLE_WITH_RENAME_TO_INSIDE, params, \
-"""blob
+u"""blob
mark :1
data 9
Welcome!
#
# It then copies doc/README.txt => README
_SAMPLE_WITH_COPY_TO_OUTSIDE = _SAMPLE_WITH_DIR + \
-"""commit refs/heads/master
+u"""commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
#
# It then copies NEWS => doc/NEWS
_SAMPLE_WITH_COPY_TO_INSIDE = _SAMPLE_WITH_DIR + \
-"""commit refs/heads/master
+u"""commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
# These copy commands ought to be kept but adjusted for the new root
params = {'include_paths': ['doc/']}
self.assertFiltering(_SAMPLE_WITH_COPY_INSIDE, params, \
-"""blob
+u"""blob
mark :1
data 9
Welcome!
# This ought to create a new file but doesn't yet
params = {'include_paths': ['doc/']}
self.assertFiltering(_SAMPLE_WITH_COPY_TO_INSIDE, params, \
-"""blob
+u"""blob
mark :1
data 9
Welcome!
# doc/README.txt
# doc/index.txt
_SAMPLE_WITH_DELETEALL = \
-"""blob
+u"""blob
mark :1
data 9
Welcome!
def test_deleteall(self):
params = {'include_paths': ['doc/index.txt']}
self.assertFiltering(_SAMPLE_WITH_DELETEALL, params, \
-"""blob
+u"""blob
mark :4
data 11
== Docs ==
_SAMPLE_WITH_TAGS = _SAMPLE_WITH_DIR + \
-"""tag v0.1
+u"""tag v0.1
from :100
tagger d <b@c> 1234798653 +0000
data 12
# Otherwise, delete the tag command.
params = {'include_paths': ['NEWS']}
self.assertFiltering(_SAMPLE_WITH_TAGS, params, \
-"""blob
+u"""blob
mark :2
data 17
Life
_SAMPLE_WITH_RESETS = _SAMPLE_WITH_DIR + \
-"""reset refs/heads/foo
+u"""reset refs/heads/foo
reset refs/heads/bar
from :102
"""
# keep the reset but adjust 'from' accordingly.
params = {'include_paths': ['NEWS']}
self.assertFiltering(_SAMPLE_WITH_RESETS, params, \
-"""blob
+u"""blob
mark :2
data 17
Life
# A sample input stream containing empty commit
_SAMPLE_EMPTY_COMMIT = \
-"""blob
+u"""blob
mark :1
data 4
foo
# A sample input stream containing unresolved from and merge references
_SAMPLE_FROM_MERGE_COMMIT = \
-"""blob
+u"""blob
mark :1
data 4
foo
def test_squash_empty_commit(self):
params = {'include_paths': None, 'exclude_paths': None}
self.assertFiltering(_SAMPLE_EMPTY_COMMIT, params, \
-"""blob
+u"""blob
mark :1
data 4
foo
def test_squash_unresolved_references(self):
params = {'include_paths': None, 'exclude_paths': None}
self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, \
-"""blob
+u"""blob
mark :1
data 4
foo
'exclude_paths': ['data/DATA'],
'squash_empty_commits': False}
self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, \
-"""blob
+u"""blob
mark :1
data 4
foo
'exclude_paths': None,
'squash_empty_commits': False}
self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, \
-"""blob
+u"""blob
mark :1
data 4
foo
'exclude_paths': None,
'squash_empty_commits': False}
self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, \
-"""commit refs/heads/master
+u"""commit refs/heads/master
mark :3
committer Joe <joe@example.com> 1234567890 +1000
data 6