~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_inv.py

  • Committer: Vincent Ladeuil
  • Date: 2011-01-27 14:27:18 UTC
  • mto: (5609.10.1 2.3b5-dev)
  • mto: This revision was merged to the branch mainline in revision 5635.
  • Revision ID: v.ladeuil+lp@free.fr-20110127142718-1ik7fyjfflgj91j5
Use self.get_transport instead of transport.get_transport where possible.

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-2011 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,
26
25
    revision,
27
26
    tests,
28
27
    )
29
 
from bzrlib.inventory import (CHKInventory, Inventory, ROOT_ID, InventoryFile,
30
 
    InventoryDirectory, InventoryEntry, TreeReference)
 
28
from bzrlib.inventory import (
 
29
    CHKInventory,
 
30
    Inventory,
 
31
    ROOT_ID,
 
32
    InventoryFile,
 
33
    InventoryDirectory,
 
34
    InventoryEntry,
 
35
    TreeReference,
 
36
    )
31
37
from bzrlib.tests import (
32
38
    TestCase,
33
39
    TestCaseWithTransport,
34
 
    condition_isinstance,
35
 
    multiply_tests,
36
 
    split_suite_by_condition,
37
40
    )
38
41
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))
 
42
from bzrlib.tests.scenarios import load_tests_apply_scenarios
 
43
 
 
44
 
 
45
load_tests = load_tests_apply_scenarios
 
46
 
 
47
 
 
48
def delta_application_scenarios():
45
49
    scenarios = [
46
50
        ('Inventory', {'apply_delta':apply_inventory_Inventory}),
47
51
        ]
64
68
            (str(format.__class__.__name__) + ".apply_inventory_delta", {
65
69
            'apply_delta':apply_inventory_WT,
66
70
            'format':format}))
67
 
    return multiply_tests(to_adapt, scenarios, result)
 
71
    return scenarios
68
72
 
69
73
 
70
74
def create_texts_for_inv(repo, inv):
74
78
        else:
75
79
            lines = []
76
80
        repo.texts.add_lines((ie.file_id, ie.revision), [], lines)
 
81
 
77
82
    
78
83
def apply_inventory_Inventory(self, basis, delta):
79
84
    """Apply delta to basis and return the result.
330
335
 
331
336
 
332
337
class TestDeltaApplication(TestCaseWithTransport):
 
338
 
 
339
    scenarios = delta_application_scenarios()
333
340
 
334
341
    def get_empty_inventory(self, reference_inv=None):
335
342
        """Get an empty inventory.
590
597
        self.assertFalse(inv.is_root('TREE_ROOT'))
591
598
        self.assertFalse(inv.is_root('booga'))
592
599
 
 
600
    def test_entries_for_empty_inventory(self):
 
601
        """Test that entries() will not fail for an empty inventory"""
 
602
        inv = Inventory(root_id=None)
 
603
        self.assertEqual([], inv.entries())
 
604
 
593
605
 
594
606
class TestInventoryEntry(TestCase):
595
607
 
607
619
 
608
620
    def test_dir_detect_changes(self):
609
621
        left = inventory.InventoryDirectory('123', 'hello.c', ROOT_ID)
610
 
        left.text_sha1 = 123
611
 
        left.executable = True
612
 
        left.symlink_target='foo'
613
622
        right = inventory.InventoryDirectory('123', 'hello.c', ROOT_ID)
614
 
        right.text_sha1 = 321
615
 
        right.symlink_target='bar'
616
623
        self.assertEqual((False, False), left.detect_changes(right))
617
624
        self.assertEqual((False, False), right.detect_changes(left))
618
625
 
632
639
 
633
640
    def test_symlink_detect_changes(self):
634
641
        left = inventory.InventoryLink('123', 'hello.c', ROOT_ID)
635
 
        left.text_sha1 = 123
636
 
        left.executable = True
637
642
        left.symlink_target='foo'
638
643
        right = inventory.InventoryLink('123', 'hello.c', ROOT_ID)
639
 
        right.text_sha1 = 321
640
644
        right.symlink_target='foo'
641
645
        self.assertEqual((False, False), left.detect_changes(right))
642
646
        self.assertEqual((False, False), right.detect_changes(left))