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

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

Issue 10689144: Extensions Docs Server: Samples zip files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up and tests Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 os 6 import os
7 import unittest 7 import unittest
8 import test_urlfetch 8 import test_urlfetch
9 9
10 from subversion_fetcher import SubversionFetcher 10 from subversion_fetcher import SubversionFetcher
11 11
12 class TestSubversionFetcher(SubversionFetcher): 12 class TestSubversionFetcher(SubversionFetcher):
13 def _GetURLFromBranch(self, branch): 13 def _GetURLFromBranch(self, branch):
14 if branch == 'trunk':
15 return os.path.join('subversion_fetcher', 'trunk')
16 return os.path.join('subversion_fetcher', branch) 14 return os.path.join('subversion_fetcher', branch)
17 15
18
19 class SubversionFetcherTest(unittest.TestCase): 16 class SubversionFetcherTest(unittest.TestCase):
20 def testFetchResource(self): 17 def testFetchResource(self):
21 fetcher_t = TestSubversionFetcher('trunk', '', test_urlfetch) 18 fetcher_t = TestSubversionFetcher('trunk', '', test_urlfetch)
22 fetcher_b1 = TestSubversionFetcher('branch1', '', test_urlfetch) 19 fetcher_b1 = TestSubversionFetcher('branch1', '', test_urlfetch)
23 fetcher_b2 = TestSubversionFetcher('branch2', '', test_urlfetch) 20 fetcher_b2 = TestSubversionFetcher('branch2', '', test_urlfetch)
24 self.assertEquals('trunk test\n', 21 self.assertEquals('trunk test\n',
25 fetcher_t.FetchResource('/test.txt').content) 22 fetcher_t.FetchResource('/test.txt').content)
26 self.assertEquals('branch1 test\n', 23 self.assertEquals('branch1 test\n',
27 fetcher_b1.FetchResource('/test.txt').content) 24 fetcher_b1.FetchResource('/test.txt').content)
28 self.assertEquals('branch2 test\n', 25 self.assertEquals('branch2 test\n',
29 fetcher_b2.FetchResource('/test.txt').content) 26 fetcher_b2.FetchResource('/test.txt').content)
30 27
28 def testListDirectory(self):
29 fetcher = TestSubversionFetcher('trunk', '', test_urlfetch)
30 expected = ['file%d.html' % i for i in range(7)]
31 self.assertEquals(
32 expected,
33 fetcher.ListDirectory('recursive_list/list').content)
34 expected2 = ['recursive_list.html/' + x for x in expected]
35 expected2.extend(['recursive_list.html/list/' + x for x in expected])
36 self.assertEquals(
37 expected2,
38 fetcher.ListDirectory('recursive_list.html', recursive=True).content)
39
31 if __name__ == '__main__': 40 if __name__ == '__main__':
32 unittest.main() 41 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698