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

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..ad0a3c3f84a20e1583b760952e85b840aff93500
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/owners_data_source_test.py
@@ -0,0 +1,112 @@
+#!/usr/bin/env python
+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': {
+ 'api': {
+ 'some_api': {
+ 'OWNERS': '\n'.join([
+ 'matoi@owner.org'
+ ]),
+ 'some_api.cc': ''
+ },
+ 'another_api': {
+ 'another_api.cc': '',
+ 'another_api.h': ''
+ },
+ 'moar_apis': {
+ 'OWNERS': '\n'.join([
+ '# For editing moar_apis.',
+ 'satsuki@revocs.org'
+ ])
+ }
+ }
+ }
+ }
+ },
+ 'extensions': {
+ 'browser': {
+ 'api': {
+ 'a_different_api': {
+ 'OWNERS': '\n'.join([
+ '# Hallo!',
+ 'nonon@owner.org',
+ 'matoi@owner.org'
+ ])
+ }
+ }
+ }
+ }
+}
+
+
+class OwnersDataSourceTest(unittest.TestCase):
+ def setUp(self):
+ server_instance = ServerInstance.ForTest(
+ file_system=TestFileSystem(_TEST_FS))
+ self._owners_ds= OwnersDataSource(server_instance, Request.ForTest('/'))
+
+ def testParseOwnersFile(self):
+ owners_content = '\n'.join([
+ 'satsuki@revocs.org',
+ 'mankanshoku@owner.org',
+ '',
+ 'matoi@owner.org'
+ ])
+ owners, notes = _ParseOwnersFile(owners_content)
+ self.assertEqual(owners, [
+ 'satsuki@revocs.org',
+ 'mankanshoku@owner.org',
+ 'matoi@owner.org'
+ ])
+ self.assertEqual(notes, '')
+
+ owners_content_with_comments = '\n'.join([
+ '# This is a comment concerning this file',
+ '# that should not be ignored.',
+ 'matoi@owner.org',
+ 'mankanshoku@owner.org',
+ '',
+ '# Only bug satsuki if matoi or mankanshoku are unavailable.',
+ 'satsuki@revocs.org'
+ ])
+ owners, notes = _ParseOwnersFile(owners_content_with_comments)
+ self.assertEqual(owners, [
+ 'matoi@owner.org',
+ 'mankanshoku@owner.org',
+ 'satsuki@revocs.org'
+ ])
+ 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):
+ self.assertEqual(self._owners_ds.get('apis'), [{
+ 'api_name': 'some_api',
+ 'owners': 'matoi@owner.org',
+ 'notes': ''
+ },
+ {
+ 'api_name': 'moar_apis',
+ 'owners': 'satsuki@revocs.org',
+ 'notes': 'For editing moar_apis.'
+ },
+ {
+ 'api_name': 'a_different_api',
+ 'owners': 'nonon@owner.org, matoi@owner.org',
+ 'notes': 'Hallo!'
+ }])
+
+if __name__ == '__main__':
+ unittest.main()

Powered by Google App Engine
This is Rietveld 408576698