Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1286)

Side by Side Diff: chrome/common/extensions/docs/server2/path_util_test.py

Issue 344453003: Docserver: separate models for apps and extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase/Add comment Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import unittest 6 import unittest
7 7
8 from path_util import SplitParent, Segment 8 from path_util import SplitParent, Split, Segment
9 9
10 10
11 class PathUtilTest(unittest.TestCase): 11 class PathUtilTest(unittest.TestCase):
12 12
13 def testSplitParent(self): 13 def testSplitParent(self):
14 self.assertEqual(('', 'hi'), SplitParent('hi')) 14 self.assertEqual(('', 'hi'), SplitParent('hi'))
15 self.assertEqual(('', 'hi/'), SplitParent('hi/')) 15 self.assertEqual(('', 'hi/'), SplitParent('hi/'))
16 self.assertEqual(('/', 'hi'), SplitParent('/hi')) 16 self.assertEqual(('/', 'hi'), SplitParent('/hi'))
17 self.assertEqual(('/', 'hi/'), SplitParent('/hi/')) 17 self.assertEqual(('/', 'hi/'), SplitParent('/hi/'))
18 self.assertEqual(('parent', 'hi'), SplitParent('parent/hi')) 18 self.assertEqual(('parent', 'hi'), SplitParent('parent/hi'))
19 self.assertEqual(('parent', 'hi/'), SplitParent('parent/hi/')) 19 self.assertEqual(('parent', 'hi/'), SplitParent('parent/hi/'))
20 self.assertEqual(('/parent', 'hi'), SplitParent('/parent/hi')) 20 self.assertEqual(('/parent', 'hi'), SplitParent('/parent/hi'))
21 self.assertEqual(('/parent', 'hi/'), SplitParent('/parent/hi/')) 21 self.assertEqual(('/parent', 'hi/'), SplitParent('/parent/hi/'))
22 self.assertEqual(('p1/p2', 'hi'), SplitParent('p1/p2/hi')) 22 self.assertEqual(('p1/p2', 'hi'), SplitParent('p1/p2/hi'))
23 self.assertEqual(('p1/p2', 'hi/'), SplitParent('p1/p2/hi/')) 23 self.assertEqual(('p1/p2', 'hi/'), SplitParent('p1/p2/hi/'))
24 self.assertEqual(('/p1/p2', 'hi'), SplitParent('/p1/p2/hi')) 24 self.assertEqual(('/p1/p2', 'hi'), SplitParent('/p1/p2/hi'))
25 self.assertEqual(('/p1/p2', 'hi/'), SplitParent('/p1/p2/hi/')) 25 self.assertEqual(('/p1/p2', 'hi/'), SplitParent('/p1/p2/hi/'))
26 26
27 def testSplit(self):
28 self.assertEqual(['p1/', 'p2/', 'p3'], Split('p1/p2/p3'))
29 self.assertEqual(['p1/', 'p2/', 'p3/'], Split('p1/p2/p3/'))
30 self.assertEqual([''], Split(''))
31 self.assertEqual(['p1/'], Split('p1/'))
32 self.assertEqual(['p1'], Split('p1'))
33
27 def testSegment(self): 34 def testSegment(self):
28 self.assertEqual([('', '')], list(Segment(''))) 35 self.assertEqual([('', '')], list(Segment('')))
29 self.assertEqual([('', 'hi'), ('hi', '')], list(Segment('hi'))) 36 self.assertEqual([('', 'hi'), ('hi', '')], list(Segment('hi')))
30 self.assertEqual([('', 'p1/p2/hi'), 37 self.assertEqual([('', 'p1/p2/hi'),
31 ('p1/', 'p2/hi'), 38 ('p1/', 'p2/hi'),
32 ('p1/p2/', 'hi'), 39 ('p1/p2/', 'hi'),
33 ('p1/p2/hi', '')], 40 ('p1/p2/hi', '')],
34 list(Segment('p1/p2/hi'))) 41 list(Segment('p1/p2/hi')))
35 self.assertEqual([('', 'foo/bar/baz.txt'), 42 self.assertEqual([('', 'foo/bar/baz.txt'),
36 ('foo/', 'bar/baz.txt'), 43 ('foo/', 'bar/baz.txt'),
37 ('foo/bar/', 'baz.txt'), 44 ('foo/bar/', 'baz.txt'),
38 ('foo/bar/baz.txt', '')], 45 ('foo/bar/baz.txt', '')],
39 list(Segment('foo/bar/baz.txt'))) 46 list(Segment('foo/bar/baz.txt')))
40 47
41 48
42 if __name__ == '__main__': 49 if __name__ == '__main__':
43 unittest.main() 50 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/path_util.py ('k') | chrome/common/extensions/docs/server2/permissions_data_source.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698