/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_inv.py

  • Committer: Martin Pool
  • Date: 2010-12-14 23:39:41 UTC
  • mto: This revision was merged to the branch mainline in revision 5571.
  • Revision ID: mbp@sourcefrog.net-20101214233941-95uq6n9xf0xgtyc3
Code guidelines re exception objects

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
18
18
from bzrlib import (
19
19
    chk_map,
20
20
    groupcompress,
21
 
    bzrdir,
22
21
    errors,
23
22
    inventory,
24
23
    osutils,
33
32
    TestCaseWithTransport,
34
33
    condition_isinstance,
35
34
    multiply_tests,
36
 
    split_suite_by_condition,
37
35
    )
38
36
from bzrlib.tests.per_workingtree import workingtree_formats
39
 
 
40
 
 
41
 
def load_tests(standard_tests, module, loader):
42
 
    """Parameterise some inventory tests."""
43
 
    to_adapt, result = split_suite_by_condition(standard_tests,
44
 
        condition_isinstance(TestDeltaApplication))
 
37
from bzrlib.tests.scenarios import load_tests_apply_scenarios
 
38
 
 
39
 
 
40
load_tests = load_tests_apply_scenarios
 
41
 
 
42
 
 
43
def delta_application_scenarios():
45
44
    scenarios = [
46
45
        ('Inventory', {'apply_delta':apply_inventory_Inventory}),
47
46
        ]
64
63
            (str(format.__class__.__name__) + ".apply_inventory_delta", {
65
64
            'apply_delta':apply_inventory_WT,
66
65
            'format':format}))
67
 
    return multiply_tests(to_adapt, scenarios, result)
 
66
    return scenarios
68
67
 
69
68
 
70
69
def create_texts_for_inv(repo, inv):
74
73
        else:
75
74
            lines = []
76
75
        repo.texts.add_lines((ie.file_id, ie.revision), [], lines)
 
76
 
77
77
    
78
78
def apply_inventory_Inventory(self, basis, delta):
79
79
    """Apply delta to basis and return the result.
330
330
 
331
331
 
332
332
class TestDeltaApplication(TestCaseWithTransport):
 
333
 
 
334
    scenarios = delta_application_scenarios()
333
335
 
334
336
    def get_empty_inventory(self, reference_inv=None):
335
337
        """Get an empty inventory.
590
592
        self.assertFalse(inv.is_root('TREE_ROOT'))
591
593
        self.assertFalse(inv.is_root('booga'))
592
594
 
 
595
    def test_entries_for_empty_inventory(self):
 
596
        """Test that entries() will not fail for an empty inventory"""
 
597
        inv = Inventory(root_id=None)
 
598
        self.assertEqual([], inv.entries())
 
599
 
593
600
 
594
601
class TestInventoryEntry(TestCase):
595
602
 
607
614
 
608
615
    def test_dir_detect_changes(self):
609
616
        left = inventory.InventoryDirectory('123', 'hello.c', ROOT_ID)
610
 
        left.text_sha1 = 123
611
 
        left.executable = True
612
 
        left.symlink_target='foo'
613
617
        right = inventory.InventoryDirectory('123', 'hello.c', ROOT_ID)
614
 
        right.text_sha1 = 321
615
 
        right.symlink_target='bar'
616
618
        self.assertEqual((False, False), left.detect_changes(right))
617
619
        self.assertEqual((False, False), right.detect_changes(left))
618
620
 
632
634
 
633
635
    def test_symlink_detect_changes(self):
634
636
        left = inventory.InventoryLink('123', 'hello.c', ROOT_ID)
635
 
        left.text_sha1 = 123
636
 
        left.executable = True
637
637
        left.symlink_target='foo'
638
638
        right = inventory.InventoryLink('123', 'hello.c', ROOT_ID)
639
 
        right.text_sha1 = 321
640
639
        right.symlink_target='foo'
641
640
        self.assertEqual((False, False), left.detect_changes(right))
642
641
        self.assertEqual((False, False), right.detect_changes(left))