1
# Copyright (C) 2008 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
"""Tests for add_inventory on a repository with external references."""
19
from bzrlib import errors
20
from bzrlib.tests.per_repository_reference import (
21
TestCaseWithExternalReferenceRepository,
25
class TestAddInventory(TestCaseWithExternalReferenceRepository):
27
def test_add_inventory_goes_to_repo(self):
28
# adding an inventory only writes to the repository add_inventory is
30
tree = self.make_branch_and_tree('sample')
31
revid = tree.commit('one')
32
inv = tree.branch.repository.get_inventory(revid)
34
self.addCleanup(tree.unlock)
35
base = self.make_repository('base')
36
repo = self.make_referring('referring', 'base')
39
repo.start_write_group()
41
repo.add_inventory(revid, inv, [])
43
repo.abort_write_group()
46
repo.commit_write_group()
50
self.addCleanup(repo.unlock)
51
inv2 = repo.get_inventory(revid)
52
content1 = dict((file_id, inv[file_id]) for file_id in inv)
53
content2 = dict((file_id, inv[file_id]) for file_id in inv2)
54
self.assertEqual(content1, content2)
55
self.assertRaises(errors.NoSuchRevision, base.get_inventory, revid)