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

Unified Diff: chrome/common/extensions/docs/server2/github_file_system_test.py

Issue 10871002: Extensions Docs Server: Testing GithubFileSystem and cron jobs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
index fe20a95e6f88b784cffc0b2773a91e352f7a1326..3552de5d7423532c9180bb4498bdc72a1ac26c9e 100755
--- a/chrome/common/extensions/docs/server2/github_file_system_test.py
+++ b/chrome/common/extensions/docs/server2/github_file_system_test.py
@@ -3,56 +3,40 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import json
import os
import unittest
-from fake_url_fetcher import FakeUrlFetcher
+from appengine_blobstore import AppEngineBlobstore
+from appengine_url_fetcher import AppEngineUrlFetcher
+from fake_fetchers import ConfigureFakeFetchers
from github_file_system import GithubFileSystem
from in_memory_object_store import InMemoryObjectStore
-
-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 } } }')
+import url_constants
class GithubFileSystemTest(unittest.TestCase):
def setUp(self):
- self._file_system = GithubFileSystem(FakeGithubFetcher('test_data'),
- InMemoryObjectStore('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/')))
+ ConfigureFakeFetchers()
+ self._base_path = os.path.join('test_data', 'github_file_system')
+ self._file_system = GithubFileSystem(
+ AppEngineUrlFetcher(url_constants.GITHUB_URL),
+ InMemoryObjectStore('github'),
+ AppEngineBlobstore())
+
+ def _ReadLocalFile(self, filename):
+ with open(os.path.join(self._base_path, filename), 'r') as f:
+ return f.read()
+
+ def testList(self):
+ self.assertEqual(json.loads(self._ReadLocalFile('expected_list.json')),
+ self._file_system.Read(['/']).Get())
+
+ def testRead(self):
+ self.assertEqual(self._ReadLocalFile('expected_read.txt'),
+ self._file_system.ReadSingle('/analytics/launch.js'))
+
+ def testStat(self):
+ self.assertEqual(0, self._file_system.Stat('zipball').version)
not at google - send to devlin 2012/08/22 13:57:58 and these tests picked up the bug?
cduvall 2012/08/22 17:20:43 Yeah these tests caught the error, but I just adde
if __name__ == '__main__':
unittest.main()

Powered by Google App Engine
This is Rietveld 408576698