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

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

Issue 14273041: Doc server manifest page generation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Codereview and polish Created 7 years, 7 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/manifest_data_source_test.py
diff --git a/chrome/common/extensions/docs/server2/manifest_data_source_test.py b/chrome/common/extensions/docs/server2/manifest_data_source_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..601e88ebae11037c528fc0cd1015bd50bd5a276c
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/manifest_data_source_test.py
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+# Copyright 2013 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 json
+import types
+import unittest
+
+from compiled_file_system import CompiledFileSystem
+from manifest_data_source import ManifestDataSource
+from object_store_creator import ObjectStoreCreator
+from test_file_system import TestFileSystem
+
+file_system = TestFileSystem({
+ "_manifest_features.json": json.dumps({
+ 'req0': {
+ 'channl': 'stable',
+ 'extension_types': ['platform_app', 'extension']
+ },
+ 'req1': {
+ 'channel': 'dev',
+ 'extension_types': 'all'
+ },
+ 'opt0': {
+ 'channel': 'trunk',
+ 'extension_types': ['extension']
+ },
+ 'opt1': {
+ 'channel': 'stable',
+ 'extension_types': ['hosted_app']
+ },
+ 'free0': {
+ 'channel': 'stable',
+ 'extension_types': ['platform_app']
+ },
+ 'free1': {
+ 'channel': 'dev',
+ 'extension_types': ['platform_app', 'hosted_app', 'extension']
+ }
+ }),
+ "manifest.json": json.dumps({
+ 'required': [
+ {'name': 'req0'},
+ {'name': 'req1'}
+ ],
+ 'optional': [
+ {'name': 'opt0'},
+ {'name': 'opt1'}
+ ]
+ })
+})
+
+def Nothing(self, _):
+ # Do nothing. We don't care what Apply{Apps,Extensions}Transformations methods
+ # do because they change depending on data.
+ pass
+
+class ManifestDataSourceTest(unittest.TestCase):
+ def testCreateManifestData(self):
+ expected_extensions = {
+ 'required': [
+ {'name': 'req0'},
+ {'name': 'req1'}
+ ],
+ 'optional': [
+ {'name': 'free1'},
+ {'name': 'opt0'}
+ ]
+ }
+
+ expected_apps = {
+ 'required': [
+ {'name': 'req0'},
+ {'name': 'req1'}
+ ],
+ 'optional': [
+ {'name': 'free0'},
+ {'name': 'free1'}
+ ]
+ }
+
+ mds = ManifestDataSource(
+ CompiledFileSystem.Factory(file_system, ObjectStoreCreator.ForTest()),
+ file_system, 'manifest.json', '_manifest_features.json', 'dev')
+
+ # Prevent an actual file load by patching in our load function.
+ mds._ApplyAppsTransformations = types.MethodType(Nothing, mds)
+ mds._ApplyExtensionsTransformations = types.MethodType(Nothing, mds)
not at google - send to devlin 2013/05/11 18:32:01 pls never override private methods. it greatly red
jshumway 2013/05/11 22:08:20 Fixed that.
+
+ self.assertEqual(expected_extensions, dict(mds.get('extensions')))
+ self.assertEqual(expected_apps, dict(mds.get('apps')))
+
+if __name__ == '__main__':
+ unittest.main()

Powered by Google App Engine
This is Rietveld 408576698