Rev 4620: Start translating blackbox tests into whitebox ones. in file:///home/vila/src/bzr/experimental/conflict-manager/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Sun Feb 28 13:44:28 GMT 2010
At file:///home/vila/src/bzr/experimental/conflict-manager/
------------------------------------------------------------
revno: 4620
revision-id: v.ladeuil+lp at free.fr-20100228134428-axphf2el34r17qfr
parent: v.ladeuil+lp at free.fr-20100226142315-gsvx3pibwclq0rsr
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: cleanup
timestamp: Sun 2010-02-28 14:44:28 +0100
message:
Start translating blackbox tests into whitebox ones.
* bzrlib/tests/test_conflicts.py:
(TestResolveContentConflicts): Rewrite test_resolve_taking_this as
a whitebox test.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_conflicts.py'
--- a/bzrlib/tests/test_conflicts.py 2010-02-23 07:43:11 +0000
+++ b/bzrlib/tests/test_conflicts.py 2010-02-28 13:44:28 +0000
@@ -18,11 +18,13 @@
import os
from bzrlib import (
+ branchbuilder,
bzrdir,
conflicts,
errors,
option,
tests,
+ workingtree,
)
from bzrlib.tests import script
@@ -192,7 +194,45 @@
pass
-class TestResolveContentConflicts(TestResolveConflicts):
+class TestResolveContentConflicts(tests.TestCaseWithTransport):
+
+ def setUp(self):
+ super(TestResolveContentConflicts, self).setUp()
+ builder = self.make_branch_builder('trunk')
+ builder.start_series()
+ # Create an empty trunk
+ builder.build_snapshot('start', None, [
+ ('add', ('', 'root-id', 'directory', ''))])
+ # Add a minimal base content
+ builder.build_snapshot('base', ['start'], [
+ ('add', ('file', 'file-id', 'file', 'trunk content\n'))])
+ # Modify the base content in branch
+ builder.build_snapshot('other', ['base'], [
+ ('unversion', 'file-id')])
+ # Modify the base content in trunk
+ builder.build_snapshot('this', ['base'], [
+ ('modify', ('file-id', 'trunk content\nmore content\n'))])
+ builder.finish_series()
+ self.builder = builder
+
+ def test_resolve_taking_this(self):
+ b = self.builder.get_branch()
+ wt = b.bzrdir.sprout('branch').open_workingtree()
+ wt.merge_from_branch(b, 'other')
+ # Check that we got the right conflict
+ confs = wt.conflicts()
+ self.assertEqual(1, len(confs))
+ c = confs[0]
+ self.assertIsInstance(confs[0], conflicts.ContentsConflict)
+ self.assertEqual('file-id', c.file_id)
+ self.assertEqual('file', c.path)
+ conflicts.resolve(wt, ['file'], action='take_this')
+ # Check that we don't have any conflicts nor unknown left
+ self.assertEqual(0, len(wt.conflicts()))
+ self.assertEqual(0, len(list(wt.unknowns())))
+
+
+class OldTestResolveContentConflicts(TestResolveConflicts):
# FIXME: We need to add the reverse case (delete in trunk, modify in
# branch) but that could wait until the resolution mechanism is implemented.
@@ -255,6 +295,7 @@
$ echo 'trunk content' >file
$ bzr add file
$ bzr commit -m 'Create trunk'
+
$ echo 'trunk content too' >file2
$ bzr add file2
$ bzr commit -m 'Add file2 in trunk'
@@ -314,6 +355,7 @@
$ mkdir dir
$ bzr add dir
$ bzr commit -m 'Create trunk'
+
$ echo 'trunk content' >dir/file
$ bzr add dir/file
$ bzr commit -m 'Add dir/file in trunk'
@@ -354,6 +396,7 @@
$ echo 'trunk content' >dir/file
$ bzr add
$ bzr commit -m 'Create trunk'
+
$ echo 'trunk content' >dir/file2
$ bzr add dir/file2
$ bzr commit -m 'Add dir/file2 in branch'
@@ -415,6 +458,7 @@
$ echo 'trunk content' >dir/file
$ bzr add
$ bzr commit -m 'Create trunk'
+
$ bzr rm dir/file --force
$ bzr rm dir --force
$ bzr commit -m 'Remove dir/file'
@@ -474,6 +518,7 @@
$ echo 'Boo!' >file
$ bzr add
$ bzr commit -m 'Create trunk'
+
$ bzr mv file file-in-trunk
$ bzr commit -m 'Renamed to file-in-trunk'
@@ -522,6 +567,7 @@
$ bzr mkdir dir1
$ bzr mkdir dir2
$ bzr commit -m 'Create trunk'
+
$ bzr mv dir2 dir1
$ bzr commit -m 'Moved dir2 into dir1'
More information about the bazaar-commits
mailing list