29
from bzrlib.tests import script
32
def load_tests(standard_tests, module, loader):
33
result = loader.suiteClass()
35
sp_tests, remaining_tests = tests.split_suite_by_condition(
36
standard_tests, tests.condition_isinstance((
37
TestParametrizedResolveConflicts,
39
# Each test class defines its own scenarios. This is needed for
40
# TestResolvePathConflictBefore531967 that verifies that the same tests as
41
# TestResolvePathConflict still pass.
42
for test in tests.iter_suite_tests(sp_tests):
43
tests.apply_scenarios(test, test.scenarios(), result)
45
# No parametrization for the remaining tests
46
result.addTests(remaining_tests)
29
from bzrlib.tests import (
35
load_tests = scenarios.load_tests_apply_scenarios
51
38
# TODO: Test commit with some added, and added-but-missing files
298
"""Return the scenario list for the conflict type defined by the class.
300
Each scenario is of the form:
301
(common, (left_name, left_dict), (right_name, right_dict))
305
* left_name and right_name are the scenario names that will be combined
307
* left_dict and right_dict are the attributes specific to each half of
308
the scenario. They should include at least 'actions' and 'check' and
309
will be available as '_this' and '_other' test instance attributes.
311
Daughters classes are free to add their specific attributes as they see
312
fit in any of the three dicts.
314
This is a class method so that load_tests can find it.
316
'_base_actions' in the common dict, 'actions' and 'check' in the left
317
and right dicts use names that map to methods in the test classes. Some
318
prefixes are added to these names to get the correspong methods (see
319
_get_actions() and _get_check()). The motivation here is to avoid
320
collisions in the class namespace.
322
# Only concrete classes return actual scenarios
284
"""The scenario list for the conflict type defined by the class.
286
Each scenario is of the form:
287
(common, (left_name, left_dict), (right_name, right_dict))
291
* left_name and right_name are the scenario names that will be combined
293
* left_dict and right_dict are the attributes specific to each half of
294
the scenario. They should include at least 'actions' and 'check' and
295
will be available as '_this' and '_other' test instance attributes.
297
Daughters classes are free to add their specific attributes as they see
298
fit in any of the three dicts.
300
This is a class method so that load_tests can find it.
302
'_base_actions' in the common dict, 'actions' and 'check' in the left
303
and right dicts use names that map to methods in the test classes. Some
304
prefixes are added to these names to get the correspong methods (see
305
_get_actions() and _get_check()). The motivation here is to avoid
306
collisions in the class namespace.
326
310
super(TestParametrizedResolveConflicts, self).setUp()
391
375
class TestResolveContentsConflict(TestParametrizedResolveConflicts):
393
_conflict_type = conflicts.ContentsConflict,
377
_conflict_type = conflicts.ContentsConflict
395
# Set by load_tests from scenarios()
379
# Set by the scenarios
396
380
# path and file-id for the file involved in the conflict
384
scenarios = mirror_scenarios(
403
386
# File modified/deleted
404
387
(dict(_base_actions='create_file',
405
388
_path='file', _file_id='file-id'),
407
390
dict(actions='modify_file', check='file_has_more_content')),
409
392
dict(actions='delete_file', check='file_doesnt_exist')),),
411
return mirror_scenarios(base_scenarios)
413
395
def do_create_file(self):
414
396
return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
437
419
class TestResolvePathConflict(TestParametrizedResolveConflicts):
439
_conflict_type = conflicts.PathConflict,
421
_conflict_type = conflicts.PathConflict
441
423
def do_nothing(self):
446
# Each side dict additionally defines:
447
# - path path involved (can be '<deleted>')
426
# Each side dict additionally defines:
427
# - path path involved (can be '<deleted>')
429
scenarios = mirror_scenarios(
450
431
# File renamed/deleted
451
432
(dict(_base_actions='create_file'),
484
465
dict(actions='rename_dir2', check='dir_renamed2',
485
466
path='new-dir2', file_id='dir-id')),),
487
return mirror_scenarios(base_scenarios)
489
469
def do_create_file(self):
490
470
return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
569
549
class TestResolveDuplicateEntry(TestParametrizedResolveConflicts):
571
_conflict_type = conflicts.DuplicateEntry,
551
_conflict_type = conflicts.DuplicateEntry
575
# Each side dict additionally defines:
553
scenarios = mirror_scenarios(
579
555
# File created with different file-ids
580
556
(dict(_base_actions='nothing'),
581
557
('filea_created',
584
560
('fileb_created',
585
561
dict(actions='create_file_b', check='file_content_b',
586
562
path='file', file_id='file-b-id')),),
588
return mirror_scenarios(base_scenarios)
590
565
def do_nothing(self):
795
770
class TestResolveParentLoop(TestParametrizedResolveConflicts):
797
_conflict_type = conflicts.ParentLoop,
772
_conflict_type = conflicts.ParentLoop
799
774
_this_args = None
800
775
_other_args = None
804
# Each side dict additionally defines:
805
# - dir_id: the directory being moved
806
# - target_id: The target directory
807
# - xfail: whether the test is expected to fail if the action is
808
# involved as 'other'
777
# Each side dict additionally defines:
778
# - dir_id: the directory being moved
779
# - target_id: The target directory
780
# - xfail: whether the test is expected to fail if the action is
781
# involved as 'other'
782
scenarios = mirror_scenarios(
810
784
# Dirs moved into each other
811
785
(dict(_base_actions='create_dir1_dir2'),
812
786
('dir1_into_dir2',
823
797
('dir3_into_dir2',
824
798
dict(actions='move_dir3_into_dir2', check='dir3_4_moved',
825
799
dir_id='dir3-id', target_id='dir2-id', xfail=True))),
827
return mirror_scenarios(base_scenarios)
829
802
def do_create_dir1_dir2(self):
830
803
return [('add', ('dir1', 'dir1-id', 'directory', '')),