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

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

Issue 10825067: Extensions Docs Server: Apps samples page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: less is_apps and fixes Created 8 years, 4 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
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import os
7 import unittest
8
9 from appengine_memcache import AppEngineMemcache
10 from fake_url_fetcher import FakeUrlFetcher
11 from github_file_system import GithubFileSystem
12
13 class FakeBlobstore(object):
14 def Set(self, blob, key, version):
15 return None
16
17 def Get(self, key, version):
18 return None
19
20 def Delete(self, key, version):
21 return None
22
23 class FakeGithubFetcher(FakeUrlFetcher):
24 class _Response(object):
25 def __init__(self, content):
26 self.content = content
27
28 def Fetch(self, path):
29 if path == 'zipball':
30 return super(FakeGithubFetcher, self).Fetch('file_system.zip')
31 return self._Response('{ "commit": { "tree": { "sha": 0 } } }')
32
33 class GithubFileSystemTest(unittest.TestCase):
34 def setUp(self):
35 self._file_system = GithubFileSystem(FakeGithubFetcher('test_data'),
36 AppEngineMemcache('test'),
37 FakeBlobstore())
38
39 def testReadFiles(self):
40 expected = {
41 '/test1.txt': 'test1\n',
42 '/test2.txt': 'test2\n',
43 '/test3.txt': 'test3\n',
44 }
45 self.assertEqual(
46 expected,
47 self._file_system.Read(
48 ['/test1.txt', '/test2.txt', '/test3.txt']).Get())
49
50 def testListDir(self):
51 expected = ['dir/']
52 for i in range(7):
53 expected.append('file%d.html' % i)
54 self.assertEqual(expected,
55 sorted(self._file_system.ReadSingle('/list/')))
56
57 if __name__ == '__main__':
58 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698