diff options
author | Ian Clatworthy <ian.clatworthy@canonical.com> | 2009-08-28 12:12:14 +1000 |
---|---|---|
committer | Ian Clatworthy <ian.clatworthy@canonical.com> | 2009-08-28 12:12:14 +1000 |
commit | 5edd62787c5329ee80dffd874f771cc8d5746eeb (patch) | |
tree | 662a002f0fd5778da7fffa05d85f32424e0ab1d4 /tests | |
parent | b92fabb101430d635971bb9df65c143ceca5135a (diff) | |
parent | 1c6495d48aa1fa036e6a73876cd89cc80d5b85f5 (diff) | |
download | bzr-fastimport-5edd62787c5329ee80dffd874f771cc8d5746eeb.tar.gz |
Merge feature support including generation/parsing of commit-properties, multiple-authors and empty-directories
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_commands.py | 55 | ||||
-rw-r--r-- | tests/test_errors.py | 5 | ||||
-rw-r--r-- | tests/test_parser.py | 54 |
3 files changed, 113 insertions, 1 deletions
diff --git a/tests/test_commands.py b/tests/test_commands.py index 04f8e14..3e185b0 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -154,6 +154,61 @@ class TestCommitDisplay(tests.TestCase): "blah blah blah", repr(c)) + def test_commit_with_more_authors(self): + # user tuple is (name, email, secs-since-epoch, secs-offset-from-utc) + author = ('Sue Wong', 'sue@example.com', 1234565432, -6 * 3600) + committer = ('Joe Wong', 'joe@example.com', 1234567890, -6 * 3600) + more_authors = [ + ('Al Smith', 'al@example.com', 1234565432, -6 * 3600), + ('Bill Jones', 'bill@example.com', 1234565432, -6 * 3600), + ] + c = commands.CommitCommand("refs/heads/master", "bbb", author, + committer, "release v1.0", ":aaa", None, None, + more_authors=more_authors) + self.assertEqualDiff( + "commit refs/heads/master\n" + "mark :bbb\n" + "author Sue Wong <sue@example.com> 1234565432 -0600\n" + "author Al Smith <al@example.com> 1234565432 -0600\n" + "author Bill Jones <bill@example.com> 1234565432 -0600\n" + "committer Joe Wong <joe@example.com> 1234567890 -0600\n" + "data 12\n" + "release v1.0\n" + "from :aaa", + repr(c)) + + def test_commit_with_properties(self): + # user tuple is (name, email, secs-since-epoch, secs-offset-from-utc) + committer = ('Joe Wong', 'joe@example.com', 1234567890, -6 * 3600) + properties = { + u'greeting': u'hello', + u'planet': u'world', + } + c = commands.CommitCommand("refs/heads/master", "bbb", None, + committer, "release v1.0", ":aaa", None, None, + properties=properties) + self.assertEqualDiff( + "commit refs/heads/master\n" + "mark :bbb\n" + "committer Joe Wong <joe@example.com> 1234567890 -0600\n" + "data 12\n" + "release v1.0\n" + "from :aaa\n" + "property greeting 5 hello\n" + "property planet 5 world", + repr(c)) + + +class TestFeatureDisplay(tests.TestCase): + + def test_feature(self): + c = commands.FeatureCommand("dwim") + self.assertEqual("feature dwim", repr(c)) + + def test_feature_with_value(self): + c = commands.FeatureCommand("dwim", "please") + self.assertEqual("feature dwim=please", repr(c)) + class TestProgressDisplay(tests.TestCase): diff --git a/tests/test_errors.py b/tests/test_errors.py index ac63b29..8f483a8 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -71,3 +71,8 @@ class TestErrors(tests.TestCase): def test_MissingHandler(self): e = errors.MissingHandler('foo') self.assertEqual("Missing handler for command foo", str(e)) + + def test_UnknownFeature(self): + e = errors.UnknownFeature('aaa') + self.assertEqual("Unknown feature 'aaa' - try a later importer or " + "an earlier data format", str(e)) diff --git a/tests/test_parser.py b/tests/test_parser.py index 3d1d803..1f77a74 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -117,6 +117,29 @@ committer <bugs@bunny.org> now data 15 submodule test M 160000 rev-id tree-id +# Test features +feature whatever +feature foo=bar +# Test commit with properties +commit refs/heads/master +mark :6 +committer <bugs@bunny.org> now +data 18 +test of properties +property p1 +property p2 5 hohum +property p3 16 alpha +beta +gamma +# Test a commit with multiple authors +commit refs/heads/master +mark :7 +author Fluffy <fluffy@bunny.org> now +author Daffy <daffy@duck.org> now +author Donald <donald@duck.org> now +committer <bugs@bunny.org> now +data 17 +multi-author test """ @@ -131,7 +154,7 @@ class TestImportParser(tests.TestCase): if cmd.name == 'commit': for fc in cmd.file_iter(): result.append(fc) - self.assertEqual(len(result), 13) + self.assertEqual(len(result), 17) cmd1 = result.pop(0) self.assertEqual('progress', cmd1.name) self.assertEqual('completed', cmd1.message) @@ -208,6 +231,35 @@ class TestImportParser(tests.TestCase): self.assertEqual('tree-reference', file_cmd1.kind) self.assertEqual(False, file_cmd1.is_executable) self.assertEqual("rev-id", file_cmd1.dataref) + cmd = result.pop(0) + self.assertEqual('feature', cmd.name) + self.assertEqual('whatever', cmd.feature_name) + self.assertEqual(None, cmd.value) + cmd = result.pop(0) + self.assertEqual('feature', cmd.name) + self.assertEqual('foo', cmd.feature_name) + self.assertEqual('bar', cmd.value) + cmd = result.pop(0) + self.assertEqual('commit', cmd.name) + self.assertEqual('6', cmd.mark) + self.assertEqual('test of properties', cmd.message) + self.assertEqual({ + 'p1': None, + 'p2': u'hohum', + 'p3': u'alpha\nbeta\ngamma', + }, cmd.properties) + cmd = result.pop(0) + self.assertEqual('commit', cmd.name) + self.assertEqual('7', cmd.mark) + self.assertEqual('multi-author test', cmd.message) + self.assertEqual('', cmd.committer[0]) + self.assertEqual('bugs@bunny.org', cmd.committer[1]) + self.assertEqual('Fluffy', cmd.author[0]) + self.assertEqual('fluffy@bunny.org', cmd.author[1]) + self.assertEqual('Daffy', cmd.more_authors[0][0]) + self.assertEqual('daffy@duck.org', cmd.more_authors[0][1]) + self.assertEqual('Donald', cmd.more_authors[1][0]) + self.assertEqual('donald@duck.org', cmd.more_authors[1][1]) class TestStringParsing(tests.TestCase): |