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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/github_file_system_test.py
diff --git a/chrome/common/extensions/docs/server2/github_file_system_test.py b/chrome/common/extensions/docs/server2/github_file_system_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..bd24e3dfc6a80531d484d46644ee56deabea7cad
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/github_file_system_test.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import unittest
+
+from appengine_memcache import AppEngineMemcache
+from fake_url_fetcher import FakeUrlFetcher
+from github_file_system import GithubFileSystem
+
+class FakeBlobstore(object):
+ def Set(self, blob, key, version):
+ return None
+
+ def Get(self, key, version):
+ return None
+
+ def Delete(self, key, version):
+ return None
+
+class FakeGithubFetcher(FakeUrlFetcher):
+ class _Response(object):
+ def __init__(self, content):
+ self.content = content
+
+ def Fetch(self, path):
+ if path == 'zipball':
+ return super(FakeGithubFetcher, self).Fetch('file_system.zip')
+ return self._Response('{ "commit": { "tree": { "sha": 0 } } }')
+
+class GithubFileSystemTest(unittest.TestCase):
+ def setUp(self):
+ self._file_system = GithubFileSystem(FakeGithubFetcher('test_data'),
+ AppEngineMemcache('test'),
+ FakeBlobstore())
+
+ def testReadFiles(self):
+ expected = {
+ '/test1.txt': 'test1\n',
+ '/test2.txt': 'test2\n',
+ '/test3.txt': 'test3\n',
+ }
+ self.assertEqual(
+ expected,
+ self._file_system.Read(
+ ['/test1.txt', '/test2.txt', '/test3.txt']).Get())
+
+def testListDir(self):
+ expected = ['dir/']
+ for i in range(7):
+ expected.append('file%d.html' % i)
+ self.assertEqual(expected,
+ sorted(self._file_system.ReadSingle('/list/')))
+
+if __name__ == '__main__':
+ unittest.main()

Powered by Google App Engine
This is Rietveld 408576698