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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import unittest
7
8 from extensions_paths import BROWSER_CHROME_EXTENSIONS
9 from owners_data_source import _ParseOwnersFile, OwnersDataSource
10 from server_instance import ServerInstance
11 from servlet import Request
12 from test_file_system import TestFileSystem
13
14
15 _TEST_FS = {
16 'chrome': {
17 'browser': {
18 'extensions': {
19 'OWNERS': '\n'.join([
20 '# Core owners.',
21 'satsuki@revocs.tld'
22 ]),
23 'api': {
24 'some_api': {
25 'OWNERS': '\n'.join([
26 'matoi@owner.tld'
27 ]),
28 'some_api.cc': ''
29 },
30 'another_api': {
31 'another_api.cc': '',
32 'another_api.h': ''
33 },
34 'moar_apis': {
35 'OWNERS': '\n'.join([
36 '# For editing moar_apis.',
37 'satsuki@revocs.tld'
38 ])
39 }
40 }
41 }
42 }
43 },
44 'extensions': {
45 'browser': {
46 'api': {
47 'a_different_api': {
48 'OWNERS': '\n'.join([
49 '# Hallo!',
50 'nonon@owner.tld',
51 'matoi@owner.tld'
52 ])
53 }
54 }
55 }
56 }
57 }
58
59
60 class OwnersDataSourceTest(unittest.TestCase):
61 def setUp(self):
62 server_instance = ServerInstance.ForTest(
63 file_system=TestFileSystem(_TEST_FS))
64 self._owners_ds= OwnersDataSource(server_instance, Request.ForTest('/'))
65 self._owner_link = '<a href=https://codereview.chromium.org/user/%s>%s</a>'
66
67 def testParseOwnersFile(self):
68 owners_content = '\n'.join([
69 'satsuki@revocs.tld',
70 'mankanshoku@owner.tld',
71 '',
72 'matoi@owner.tld'
73 ])
74 owners, notes = _ParseOwnersFile(owners_content)
75 self.assertEqual(owners, ', '.join([
76 self._owner_link % ('satsuki@revocs.tld', 'satsuki'),
77 self._owner_link % ('mankanshoku@owner.tld', 'mankanshoku'),
78 self._owner_link % ('matoi@owner.tld', 'matoi')
79 ]))
80 self.assertEqual(notes, '')
81
82 owners_content_with_comments = '\n'.join([
83 '# This is a comment concerning this file',
84 '# that should not be ignored.',
85 'matoi@owner.tld',
86 'mankanshoku@owner.tld',
87 '',
88 '# Only bug satsuki if matoi or mankanshoku are unavailable.',
89 'satsuki@revocs.tld'
90 ])
91 owners, notes = _ParseOwnersFile(owners_content_with_comments)
92 self.assertEqual(owners, ', '.join([
93 self._owner_link % ('matoi@owner.tld', 'matoi'),
94 self._owner_link % ('mankanshoku@owner.tld', 'mankanshoku'),
95 self._owner_link % ('satsuki@revocs.tld', 'satsuki')
96 ]))
97 self.assertEqual(notes, ' '.join([
98 'This is a comment concerning this file that should not be ignored.',
99 'Only bug satsuki if matoi or mankanshoku are unavailable.'
100 ]))
101
102
103 def testCollectOwners(self):
104 # NOTE: Order matters. The list should be sorted by 'apiName'.
105 self.assertEqual(self._owners_ds.get('apis'), [{
106 'apiName': 'Core Extensions/Apps Owners',
107 'owners': self._owner_link % ('satsuki@revocs.tld', 'satsuki'),
108 'notes': 'Core owners.'
109 },
110 {
111 'apiName': 'a_different_api',
112 'owners': ', '.join([
113 self._owner_link % ('nonon@owner.tld', 'nonon'),
114 self._owner_link % ('matoi@owner.tld', 'matoi')
115 ]),
116 'notes': 'Hallo!'
117 },
118 {
119 'apiName': 'another_api',
120 'owners': '<span class="warning">No owner.</span>',
121 'notes': 'See core extensions owners.'
122 },
123 {
124 'apiName': 'moar_apis',
125 'owners': self._owner_link % ('satsuki@revocs.tld', 'satsuki'),
126 'notes': 'For editing moar_apis.'
127 },
128 {
129 'apiName': 'some_api',
130 'owners': self._owner_link % ('matoi@owner.tld', 'matoi'),
131 'notes': ''
132 }])
133
134 if __name__ == '__main__':
135 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698