1
# Copyright (C) 2012 Canonical Ltd
1
# Copyright (C) 2012, 2016 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
30
31
self.tree_a = self.workingtree_to_test_tree(work_a)
32
33
def test_path2id(self):
33
self.assertEquals('bla-id', self.tree_a.path2id('bla'))
34
self.assertEquals('dir-id', self.tree_a.path2id('dir'))
34
self.assertEqual('bla-id', self.tree_a.path2id('bla'))
35
self.assertEqual('dir-id', self.tree_a.path2id('dir'))
35
36
self.assertIs(None, self.tree_a.path2id('idontexist'))
37
38
def test_path2id_list(self):
38
self.assertEquals('bla-id', self.tree_a.path2id(['bla']))
39
self.assertEquals('dir-id', self.tree_a.path2id(['dir']))
40
self.assertEquals('file-id', self.tree_a.path2id(['dir', 'file']))
41
self.assertEquals(self.tree_a.get_root_id(),
42
self.tree_a.path2id([]))
39
self.assertEqual('bla-id', self.tree_a.path2id(['bla']))
40
self.assertEqual('dir-id', self.tree_a.path2id(['dir']))
41
self.assertEqual('file-id', self.tree_a.path2id(['dir', 'file']))
42
self.assertEqual(self.tree_a.get_root_id(),
43
self.tree_a.path2id([]))
43
44
self.assertIs(None, self.tree_a.path2id(['idontexist']))
44
45
self.assertIs(None, self.tree_a.path2id(['dir', 'idontexist']))
46
47
def test_id2path(self):
47
48
self.addCleanup(self.tree_a.lock_read().unlock)
48
self.assertEquals('bla', self.tree_a.id2path('bla-id'))
49
self.assertEquals('dir', self.tree_a.id2path('dir-id'))
50
self.assertEquals('dir/file', self.tree_a.id2path('file-id'))
49
self.assertEqual('bla', self.tree_a.id2path('bla-id'))
50
self.assertEqual('dir', self.tree_a.id2path('dir-id'))
51
self.assertEqual('dir/file', self.tree_a.id2path('file-id'))
51
52
self.assertRaises(errors.NoSuchId, self.tree_a.id2path, 'nonexistant')