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

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

Issue 14273041: Doc server manifest page generation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Manifest Update preview 2 Created 7 years, 8 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/intro_data_source_test.py
diff --git a/chrome/common/extensions/docs/server2/intro_data_source_test.py b/chrome/common/extensions/docs/server2/intro_data_source_test.py
index 90f2c76de4c146147104d2176c17b6d2c475e42b..d222cdf4972f40a1339116df69b48ea3c31c1dc2 100755
--- a/chrome/common/extensions/docs/server2/intro_data_source_test.py
+++ b/chrome/common/extensions/docs/server2/intro_data_source_test.py
@@ -3,32 +3,60 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-from server_instance import ServerInstance
-import svn_constants
-from test_file_system import TestFileSystem
import unittest
-_TEST_DATA = TestFileSystem.MoveTo(svn_constants.INTRO_PATH, {
- 'test.html': '<h1>hello</h1>world<h2>first</h2><h3>inner</h3><h2>second</h2>'
-})
+from file_system import FileNotFoundError
+from intro_data_source import _MakeIntroDict, IntroDataSource
-class IntroDataSourceTest(unittest.TestCase):
- def setUp(self):
- self._server = ServerInstance.CreateForTest(TestFileSystem(_TEST_DATA))
+class MockRefResolver(object):
+ class Factory(object):
+ def Create(self):
+ return False
+
+ def ResolveAllLinks(self, text, namespace):
+ return text
+
+class MockCompiledFileSystem(object):
+ """Mocks a Compiled File System. Demonstrates that IntroDataSource uses the
+ same Compiled File System for all children.
+ """
+ class Factory(object):
+ def Create(self, _, __):
+ return MockCompiledFileSystem()
+ def CreateIdentity(self, _):
+ return MockCompiledFileSystem()
+
+ def GetFromFile(self, path):
+ if path == 'top/topfile.html':
+ return 'topfile'
+ elif path == 'top/dir-one/file.html':
+ return 'dir-one-file'
+
+ raise FileNotFoundError("not important")
+ def GetFromFileListing(self, path):
+ if path == 'top/dir-one':
+ return True
+
+class IntroDataSourceTest(unittest.TestCase):
def testIntro(self):
- intro_data_source = self._server.intro_data_source_factory.Create()
- data = intro_data_source.get('test')
+ data = _MakeIntroDict(MockRefResolver(), 'path',
+ '<h1>hello</h1>world<h2>first</h2><h3>inner</h3><h2>second</h2>')
self.assertEqual('hello', data['title'])
- # TODO(kalman): test links.
expected_toc = [{'subheadings': [{'link': '', 'title': u'inner'}],
- 'link': '',
- 'title': u'first'},
+ 'link': '', 'title': u'first'},
{'subheadings': [], 'link': '', 'title': u'second'}]
self.assertEqual(expected_toc, data['apps_toc'])
self.assertEqual(expected_toc, data['extensions_toc'])
- self.assertEqual('world<h2>first</h2><h3>inner</h3><h2>second</h2>',
- data['intro'].render().text)
+
+ def testLookup(self):
+ ids = IntroDataSource.Factory(
+ MockCompiledFileSystem.Factory(), MockRefResolver.Factory(),
+ ['top']).Create()
+
+ self.assertEqual('topfile', ids.get('topfile'))
+ # Simulates how a template would access a subdirectory.
+ self.assertEqual('dir-one-file', ids.get('dir-one').get('file'))
if __name__ == '__main__':
unittest.main()

Powered by Google App Engine
This is Rietveld 408576698