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

Side by Side Diff: chrome/common/extensions/docs/server2/local_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 8
9 from local_fetcher import LocalFetcher 9 from local_fetcher import LocalFetcher
10 10
11 class LocalFetcherTest(unittest.TestCase): 11 class LocalFetcherTest(unittest.TestCase):
12 def setUp(self):
13 self._base_path = os.path.join('test_data', 'local_fetcher')
14 self._fetcher = LocalFetcher(self._base_path)
15
12 def testFetchResource(self): 16 def testFetchResource(self):
13 fetcher = LocalFetcher('') 17 self.assertEquals('test1\n',
14 local_path = os.path.join('test_data', 'local_fetcher') 18 self._fetcher.FetchResource('test1.txt').content)
15 self.assertEquals('test1\n', fetcher.FetchResource( 19 self.assertEquals('test2\n',
16 os.path.join(local_path, 'test1.txt')).content) 20 self._fetcher.FetchResource('test2.txt').content)
17 self.assertEquals('test2\n', fetcher.FetchResource( 21 self.assertEquals('test3\n',
18 os.path.join(local_path, 'test2.txt')).content) 22 self._fetcher.FetchResource('test3.txt').content)
19 self.assertEquals('test3\n', fetcher.FetchResource( 23
20 os.path.join(local_path, 'test3.txt')).content) 24 def testListDirectory(self):
25 expected = ['file%d.html' % i for i in range(7)]
26 self.assertEquals(
27 expected,
28 sorted(self._fetcher.ListDirectory('recursive_list/list').content))
29 expected2 = ['recursive_list/' + x for x in expected]
30 expected2.extend(['recursive_list/list/' + x for x in expected])
31 self.assertEquals(
32 expected2,
33 sorted(self._fetcher.ListDirectory('recursive_list',
34 recursive=True).content))
21 35
22 if __name__ == '__main__': 36 if __name__ == '__main__':
23 unittest.main() 37 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/local_fetcher.py ('k') | chrome/common/extensions/docs/server2/samples_data_source.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698