Beispiel #1
0
 def test_build_tree(self):
     """Test building works using a MemoryTree."""
     branch = self.make_branch('branch')
     tree = MemoryTree.create_on_branch(branch)
     builder = TreeBuilder()
     builder.start_tree(tree)
     builder.build(['foo', "bar/", "bar/file"])
     self.assertEqual(b'contents of foo\n', tree.get_file('foo').read())
     self.assertEqual(b'contents of bar/file\n',
                      tree.get_file('bar/file').read())
     builder.finish_tree()
Beispiel #2
0
 def test_build_tree_not_started_errors(self):
     builder = TreeBuilder()
     self.assertRaises(NotBuilding, builder.build, "foo")
Beispiel #3
0
 def test_finish_tree_unlocks(self):
     builder = TreeBuilder()
     tree = FakeTree()
     builder.start_tree(tree)
     builder.finish_tree()
     self.assertEqual(["lock_tree_write", "unlock"], tree._calls)
Beispiel #4
0
 def test_finish_tree_not_started_errors(self):
     builder = TreeBuilder()
     self.assertRaises(NotBuilding, builder.finish_tree)
Beispiel #5
0
 def test_start_tree_when_started_fails(self):
     builder = TreeBuilder()
     tree = FakeTree()
     builder.start_tree(tree)
     self.assertRaises(AlreadyBuilding, builder.start_tree, tree)
Beispiel #6
0
 def test_start_tree_locks_write(self):
     builder = TreeBuilder()
     tree = FakeTree()
     builder.start_tree(tree)
     self.assertEqual(["lock_tree_write"], tree._calls)
Beispiel #7
0
 def test_create(self):
     TreeBuilder()