1
# Copyright (C) 2006-2010 Canonical Ltd
1
# Copyright (C) 2006-2011 Canonical Ltd
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
44
44
# set_path_id setting id when state is in memory modified
47
def load_tests(basic_tests, module, loader):
48
suite = loader.suiteClass()
49
dir_reader_tests, remaining_tests = tests.split_suite_by_condition(
50
basic_tests, tests.condition_isinstance(TestCaseWithDirState))
51
tests.multiply_tests(dir_reader_tests,
52
test_osutils.dir_reader_scenarios(), suite)
53
suite.addTest(remaining_tests)
47
load_tests = load_tests_apply_scenarios
57
50
class TestCaseWithDirState(tests.TestCaseWithTransport):
58
51
"""Helper functions for creating DirState objects with various content."""
53
scenarios = test_osutils.dir_reader_scenarios()
60
55
# Set by load_tests
61
56
_dir_reader_class = None
62
57
_native_to_unicode = None # Not used yet
731
726
class TestDirStateManipulations(TestCaseWithDirState):
728
def test_update_minimal_updates_id_index(self):
729
state = self.create_dirstate_with_root_and_subdir()
730
self.addCleanup(state.unlock)
731
id_index = state._get_id_index()
732
self.assertEqual(['a-root-value', 'subdir-id'], sorted(id_index))
733
state.add('file-name', 'file-id', 'file', None, '')
734
self.assertEqual(['a-root-value', 'file-id', 'subdir-id'],
736
state.update_minimal(('', 'new-name', 'file-id'), 'f',
737
path_utf8='new-name')
738
self.assertEqual(['a-root-value', 'file-id', 'subdir-id'],
740
self.assertEqual([('', 'new-name', 'file-id')],
741
sorted(id_index['file-id']))
733
744
def test_set_state_from_inventory_no_content_no_parents(self):
734
745
# setting the current inventory is a slow but important api to support.
735
746
tree1 = self.make_branch_and_memory_tree('tree1')