/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2729.2.2 by Martin Pool
Start moving inventory tests into per-inventory module
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
2729.2.1 by Martin Pool
Start adding per-inventory tests
2
#
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.
7
#
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.
12
#
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
"""Tests for different inventory implementations"""
18
19
20
from bzrlib.inventory import (
21
    Inventory,
22
    )
23
24
from bzrlib.tests import (
25
    TestCase,
26
    multiply_tests_from_modules,
27
    )
28
29
30
class TestInventoryBasics(TestCase):
2729.2.2 by Martin Pool
Start moving inventory tests into per-inventory module
31
    # Most of these were moved the rather old bzrlib.tests.test_inv module
2729.2.1 by Martin Pool
Start adding per-inventory tests
32
    
2729.2.2 by Martin Pool
Start moving inventory tests into per-inventory module
33
    def make_inventory(self, root_id):
34
        return self.inventory_class(root_id=root_id)
35
36
    def test_add_path_of_root(self):
37
        # add a root entry by adding its path
38
        inv = self.make_inventory(root_id=None)
39
        self.assertIs(None, inv.root)
40
        ie = inv.add_path("", "directory", "my-root")
41
        self.assertEqual("my-root", ie.file_id)
42
        self.assertIs(ie, inv.root)
43
44
    def test_add_path(self):
45
        inv = self.make_inventory(root_id='tree_root')
46
        ie = inv.add_path('hello', 'file', 'hello-id')
47
        self.assertEqual('hello-id', ie.file_id)
48
        self.assertEqual('file', ie.kind)
2729.2.1 by Martin Pool
Start adding per-inventory tests
49
50
51
def _inventory_test_scenarios():
52
    """Return a sequence of test scenarios.
53
54
    Each scenario is (scenario_name_suffix, params).  The params are each 
55
    set as attributes on the test case.
56
    """
2729.2.2 by Martin Pool
Start moving inventory tests into per-inventory module
57
    yield ('Inventory', dict(inventory_class=Inventory))
2729.2.1 by Martin Pool
Start adding per-inventory tests
58
59
60
def test_suite():
61
    """Generate suite containing all parameterized tests"""
62
    modules_to_test = [
63
            'bzrlib.tests.inventory_implementations',
64
            ]
2729.2.2 by Martin Pool
Start moving inventory tests into per-inventory module
65
    import pdb;pdb.set_trace()
2729.2.1 by Martin Pool
Start adding per-inventory tests
66
    return multiply_tests_from_modules(modules_to_test,
67
            _inventory_test_scenarios())