852
852
self.fail("Can't handle contents with no name")
853
853
transform.finalize()
855
def test_reuse_name(self):
856
"""Avoid reusing the same limbo name for different files"""
857
transform, root = self.get_transform()
858
oz = transform.new_directory('oz', root)
859
elphaba1 = transform.new_directory('elphaba', oz)
861
elphaba2 = transform.new_directory('elphaba', oz)
863
self.fail('Tranform tried to use the same limbo name twice')
864
transform.adjust_path('galinda', oz, elphaba2)
866
# limbo/oz => oz, limbo/new-3 => oz/galinda
867
self.assertEqual(2, transform.rename_count)
869
def test_reuse_when_first_moved(self):
870
"""Don't avoid direct paths when it is safe to use them"""
871
transform, root = self.get_transform()
872
oz = transform.new_directory('oz', root)
873
elphaba1 = transform.new_directory('elphaba', oz)
874
transform.adjust_path('galinda', oz, elphaba1)
875
elphaba2 = transform.new_directory('elphaba', oz)
878
self.assertEqual(1, transform.rename_count)
880
def test_reuse_after_cancel(self):
881
"""Don't avoid direct paths when it is safe to use them"""
882
transform, root = self.get_transform()
883
oz = transform.new_directory('oz', root)
884
elphaba1 = transform.new_directory('elphaba', oz)
885
transform.cancel_creation(oz)
886
transform.create_directory(oz)
887
elphaba2 = transform.new_directory('elphaba', oz)
888
transform.adjust_path('galinda', oz, elphaba1)
890
# limbo/oz => oz, limbo/new-1 => oz/elphaba
891
self.assertEqual(2, transform.rename_count)
856
894
class TransformGroup(object):
857
895
def __init__(self, dirname, root_id):