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

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

Issue 453713002: Docserver: Generate a table of extension/app API owners (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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/owners_data_source_test.py
diff --git a/chrome/common/extensions/docs/server2/owners_data_source_test.py b/chrome/common/extensions/docs/server2/owners_data_source_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..540b764c22d3ff76f1160ff300731f8f85086b6c
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/owners_data_source_test.py
@@ -0,0 +1,135 @@
+#!/usr/bin/env python
+# Copyright 2014 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 unittest
+
+from extensions_paths import BROWSER_CHROME_EXTENSIONS
+from owners_data_source import _ParseOwnersFile, OwnersDataSource
+from server_instance import ServerInstance
+from servlet import Request
+from test_file_system import TestFileSystem
+
+
+_TEST_FS = {
+ 'chrome': {
+ 'browser': {
+ 'extensions': {
+ 'OWNERS': '\n'.join([
+ '# Core owners.',
+ 'satsuki@revocs.tld'
+ ]),
+ 'api': {
+ 'some_api': {
+ 'OWNERS': '\n'.join([
+ 'matoi@owner.tld'
+ ]),
+ 'some_api.cc': ''
+ },
+ 'another_api': {
+ 'another_api.cc': '',
+ 'another_api.h': ''
+ },
+ 'moar_apis': {
+ 'OWNERS': '\n'.join([
+ '# For editing moar_apis.',
+ 'satsuki@revocs.tld'
+ ])
+ }
+ }
+ }
+ }
+ },
+ 'extensions': {
+ 'browser': {
+ 'api': {
+ 'a_different_api': {
+ 'OWNERS': '\n'.join([
+ '# Hallo!',
+ 'nonon@owner.tld',
+ 'matoi@owner.tld'
+ ])
+ }
+ }
+ }
+ }
+}
+
+
+class OwnersDataSourceTest(unittest.TestCase):
+ def setUp(self):
+ server_instance = ServerInstance.ForTest(
+ file_system=TestFileSystem(_TEST_FS))
+ self._owners_ds= OwnersDataSource(server_instance, Request.ForTest('/'))
+ self._owner_link = '<a href=https://codereview.chromium.org/user/%s>%s</a>'
+
+ def testParseOwnersFile(self):
+ owners_content = '\n'.join([
+ 'satsuki@revocs.tld',
+ 'mankanshoku@owner.tld',
+ '',
+ 'matoi@owner.tld'
+ ])
+ owners, notes = _ParseOwnersFile(owners_content)
+ self.assertEqual(owners, ', '.join([
+ self._owner_link % ('satsuki@revocs.tld', 'satsuki'),
+ self._owner_link % ('mankanshoku@owner.tld', 'mankanshoku'),
+ self._owner_link % ('matoi@owner.tld', 'matoi')
+ ]))
+ self.assertEqual(notes, '')
+
+ owners_content_with_comments = '\n'.join([
+ '# This is a comment concerning this file',
+ '# that should not be ignored.',
+ 'matoi@owner.tld',
+ 'mankanshoku@owner.tld',
+ '',
+ '# Only bug satsuki if matoi or mankanshoku are unavailable.',
+ 'satsuki@revocs.tld'
+ ])
+ owners, notes = _ParseOwnersFile(owners_content_with_comments)
+ self.assertEqual(owners, ', '.join([
+ self._owner_link % ('matoi@owner.tld', 'matoi'),
+ self._owner_link % ('mankanshoku@owner.tld', 'mankanshoku'),
+ self._owner_link % ('satsuki@revocs.tld', 'satsuki')
+ ]))
+ self.assertEqual(notes, ' '.join([
+ 'This is a comment concerning this file that should not be ignored.',
+ 'Only bug satsuki if matoi or mankanshoku are unavailable.'
+ ]))
+
+
+ def testCollectOwners(self):
+ # NOTE: Order matters. The list should be sorted by 'apiName'.
+ self.assertEqual(self._owners_ds.get('apis'), [{
+ 'apiName': 'Core Extensions/Apps Owners',
+ 'owners': self._owner_link % ('satsuki@revocs.tld', 'satsuki'),
+ 'notes': 'Core owners.'
+ },
+ {
+ 'apiName': 'a_different_api',
+ 'owners': ', '.join([
+ self._owner_link % ('nonon@owner.tld', 'nonon'),
+ self._owner_link % ('matoi@owner.tld', 'matoi')
+ ]),
+ 'notes': 'Hallo!'
+ },
+ {
+ 'apiName': 'another_api',
+ 'owners': '<span class="warning">No owner.</span>',
+ 'notes': 'See core extensions owners.'
+ },
+ {
+ 'apiName': 'moar_apis',
+ 'owners': self._owner_link % ('satsuki@revocs.tld', 'satsuki'),
+ 'notes': 'For editing moar_apis.'
+ },
+ {
+ 'apiName': 'some_api',
+ 'owners': self._owner_link % ('matoi@owner.tld', 'matoi'),
+ 'notes': ''
+ }])
+
+if __name__ == '__main__':
+ unittest.main()

Powered by Google App Engine
This is Rietveld 408576698