~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_versionedfile.py

  • Committer: Martin Pool
  • Date: 2010-12-09 04:26:53 UTC
  • mto: This revision was merged to the branch mainline in revision 5564.
  • Revision ID: mbp@canonical.com-20101209042653-hgy6vkrlfvi1d7rs
Change to using standard load_tests_apply_scenarios.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
    TestCaseWithMemoryTransport,
52
52
    TestNotApplicable,
53
53
    TestSkipped,
54
 
    condition_isinstance,
55
 
    split_suite_by_condition,
56
 
    multiply_tests,
57
54
    )
58
55
from bzrlib.tests.http_utils import TestCaseWithWebserver
59
56
from bzrlib.trace import mutter
70
67
    )
71
68
from bzrlib.weave import WeaveFile
72
69
from bzrlib.weavefile import read_weave, write_weave
73
 
 
74
 
 
75
 
def load_tests(standard_tests, module, loader):
76
 
    """Parameterize VersionedFiles tests for different implementations."""
77
 
    to_adapt, result = split_suite_by_condition(
78
 
        standard_tests, condition_isinstance(TestVersionedFiles))
79
 
    # We want to be sure of behaviour for:
80
 
    # weaves prefix layout (weave texts)
81
 
    # individually named weaves (weave inventories)
82
 
    # annotated knits - prefix|hash|hash-escape layout, we test the third only
83
 
    #                   as it is the most complex mapper.
84
 
    # individually named knits
85
 
    # individual no-graph knits in packs (signatures)
86
 
    # individual graph knits in packs (inventories)
87
 
    # individual graph nocompression knits in packs (revisions)
88
 
    # plain text knits in packs (texts)
89
 
    len_one_scenarios = [
90
 
        ('weave-named', {
91
 
            'cleanup':None,
92
 
            'factory':make_versioned_files_factory(WeaveFile,
93
 
                ConstantMapper('inventory')),
94
 
            'graph':True,
95
 
            'key_length':1,
96
 
            'support_partial_insertion': False,
97
 
            }),
98
 
        ('named-knit', {
99
 
            'cleanup':None,
100
 
            'factory':make_file_factory(False, ConstantMapper('revisions')),
101
 
            'graph':True,
102
 
            'key_length':1,
103
 
            'support_partial_insertion': False,
104
 
            }),
105
 
        ('named-nograph-nodelta-knit-pack', {
106
 
            'cleanup':cleanup_pack_knit,
107
 
            'factory':make_pack_factory(False, False, 1),
108
 
            'graph':False,
109
 
            'key_length':1,
110
 
            'support_partial_insertion': False,
111
 
            }),
112
 
        ('named-graph-knit-pack', {
113
 
            'cleanup':cleanup_pack_knit,
114
 
            'factory':make_pack_factory(True, True, 1),
115
 
            'graph':True,
116
 
            'key_length':1,
117
 
            'support_partial_insertion': True,
118
 
            }),
119
 
        ('named-graph-nodelta-knit-pack', {
120
 
            'cleanup':cleanup_pack_knit,
121
 
            'factory':make_pack_factory(True, False, 1),
122
 
            'graph':True,
123
 
            'key_length':1,
124
 
            'support_partial_insertion': False,
125
 
            }),
126
 
        ('groupcompress-nograph', {
127
 
            'cleanup':groupcompress.cleanup_pack_group,
128
 
            'factory':groupcompress.make_pack_factory(False, False, 1),
129
 
            'graph': False,
130
 
            'key_length':1,
131
 
            'support_partial_insertion':False,
132
 
            }),
133
 
        ]
134
 
    len_two_scenarios = [
135
 
        ('weave-prefix', {
136
 
            'cleanup':None,
137
 
            'factory':make_versioned_files_factory(WeaveFile,
138
 
                PrefixMapper()),
139
 
            'graph':True,
140
 
            'key_length':2,
141
 
            'support_partial_insertion': False,
142
 
            }),
143
 
        ('annotated-knit-escape', {
144
 
            'cleanup':None,
145
 
            'factory':make_file_factory(True, HashEscapedPrefixMapper()),
146
 
            'graph':True,
147
 
            'key_length':2,
148
 
            'support_partial_insertion': False,
149
 
            }),
150
 
        ('plain-knit-pack', {
151
 
            'cleanup':cleanup_pack_knit,
152
 
            'factory':make_pack_factory(True, True, 2),
153
 
            'graph':True,
154
 
            'key_length':2,
155
 
            'support_partial_insertion': True,
156
 
            }),
157
 
        ('groupcompress', {
158
 
            'cleanup':groupcompress.cleanup_pack_group,
159
 
            'factory':groupcompress.make_pack_factory(True, False, 1),
160
 
            'graph': True,
161
 
            'key_length':1,
162
 
            'support_partial_insertion':False,
163
 
            }),
164
 
        ]
165
 
    scenarios = len_one_scenarios + len_two_scenarios
166
 
    return multiply_tests(to_adapt, scenarios, result)
 
70
from bzrlib.tests.scenarios import load_tests_apply_scenarios
 
71
 
 
72
 
 
73
load_tests = load_tests_apply_scenarios
167
74
 
168
75
 
169
76
def get_diamond_vf(f, trailing_eol=True, left_only=False):
1475
1382
class TestVersionedFiles(TestCaseWithMemoryTransport):
1476
1383
    """Tests for the multiple-file variant of VersionedFile."""
1477
1384
 
 
1385
    # We want to be sure of behaviour for:
 
1386
    # weaves prefix layout (weave texts)
 
1387
    # individually named weaves (weave inventories)
 
1388
    # annotated knits - prefix|hash|hash-escape layout, we test the third only
 
1389
    #                   as it is the most complex mapper.
 
1390
    # individually named knits
 
1391
    # individual no-graph knits in packs (signatures)
 
1392
    # individual graph knits in packs (inventories)
 
1393
    # individual graph nocompression knits in packs (revisions)
 
1394
    # plain text knits in packs (texts)
 
1395
    len_one_scenarios = [
 
1396
        ('weave-named', {
 
1397
            'cleanup':None,
 
1398
            'factory':make_versioned_files_factory(WeaveFile,
 
1399
                ConstantMapper('inventory')),
 
1400
            'graph':True,
 
1401
            'key_length':1,
 
1402
            'support_partial_insertion': False,
 
1403
            }),
 
1404
        ('named-knit', {
 
1405
            'cleanup':None,
 
1406
            'factory':make_file_factory(False, ConstantMapper('revisions')),
 
1407
            'graph':True,
 
1408
            'key_length':1,
 
1409
            'support_partial_insertion': False,
 
1410
            }),
 
1411
        ('named-nograph-nodelta-knit-pack', {
 
1412
            'cleanup':cleanup_pack_knit,
 
1413
            'factory':make_pack_factory(False, False, 1),
 
1414
            'graph':False,
 
1415
            'key_length':1,
 
1416
            'support_partial_insertion': False,
 
1417
            }),
 
1418
        ('named-graph-knit-pack', {
 
1419
            'cleanup':cleanup_pack_knit,
 
1420
            'factory':make_pack_factory(True, True, 1),
 
1421
            'graph':True,
 
1422
            'key_length':1,
 
1423
            'support_partial_insertion': True,
 
1424
            }),
 
1425
        ('named-graph-nodelta-knit-pack', {
 
1426
            'cleanup':cleanup_pack_knit,
 
1427
            'factory':make_pack_factory(True, False, 1),
 
1428
            'graph':True,
 
1429
            'key_length':1,
 
1430
            'support_partial_insertion': False,
 
1431
            }),
 
1432
        ('groupcompress-nograph', {
 
1433
            'cleanup':groupcompress.cleanup_pack_group,
 
1434
            'factory':groupcompress.make_pack_factory(False, False, 1),
 
1435
            'graph': False,
 
1436
            'key_length':1,
 
1437
            'support_partial_insertion':False,
 
1438
            }),
 
1439
        ]
 
1440
    len_two_scenarios = [
 
1441
        ('weave-prefix', {
 
1442
            'cleanup':None,
 
1443
            'factory':make_versioned_files_factory(WeaveFile,
 
1444
                PrefixMapper()),
 
1445
            'graph':True,
 
1446
            'key_length':2,
 
1447
            'support_partial_insertion': False,
 
1448
            }),
 
1449
        ('annotated-knit-escape', {
 
1450
            'cleanup':None,
 
1451
            'factory':make_file_factory(True, HashEscapedPrefixMapper()),
 
1452
            'graph':True,
 
1453
            'key_length':2,
 
1454
            'support_partial_insertion': False,
 
1455
            }),
 
1456
        ('plain-knit-pack', {
 
1457
            'cleanup':cleanup_pack_knit,
 
1458
            'factory':make_pack_factory(True, True, 2),
 
1459
            'graph':True,
 
1460
            'key_length':2,
 
1461
            'support_partial_insertion': True,
 
1462
            }),
 
1463
        ('groupcompress', {
 
1464
            'cleanup':groupcompress.cleanup_pack_group,
 
1465
            'factory':groupcompress.make_pack_factory(True, False, 1),
 
1466
            'graph': True,
 
1467
            'key_length':1,
 
1468
            'support_partial_insertion':False,
 
1469
            }),
 
1470
        ]
 
1471
 
 
1472
    scenarios = len_one_scenarios + len_two_scenarios
 
1473
 
1478
1474
    def get_versionedfiles(self, relpath='files'):
1479
1475
        transport = self.get_transport(relpath)
1480
1476
        if relpath != '.':