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

Side by Side Diff: chrome/common/extensions/docs/server2/reference_resolver_test.py

Issue 80183002: Correct $ref links in extensions documentation server relative location. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Feedback Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import json 6 import json
7 import os 7 import os
8 import sys 8 import sys
9 import unittest 9 import unittest
10 10
11 from file_system import FileNotFoundError 11 from file_system import FileNotFoundError
12 from reference_resolver import ReferenceResolver 12 from reference_resolver import ReferenceResolver
13 from test_object_store import TestObjectStore 13 from test_object_store import TestObjectStore
14 14
15
not at google - send to devlin 2013/11/22 20:16:10 ditto blank line
benwells 2013/11/27 07:28:31 Done.
16 class FakeAPIDataSource(object): 15 class FakeAPIDataSource(object):
17 def __init__(self, json_data): 16 def __init__(self, json_data):
18 self._json = json_data 17 self._json = json_data
19 18
20 def get(self, key, disable_refs=False): 19 def get(self, key, disable_refs=False):
21 assert disable_refs, 'ReferenceResolve should be disabling refs' 20 assert disable_refs, 'ReferenceResolve should be disabling refs'
22 if key not in self._json: 21 if key not in self._json:
23 raise FileNotFoundError(key) 22 raise FileNotFoundError(key)
24 return self._json[key] 23 return self._json[key]
25 24
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 self.assertEqual( 161 self.assertEqual(
163 '<pre><a href="bar.html#type-bon">bar.bon</a>({\nkey: value})', 162 '<pre><a href="bar.html#type-bon">bar.bon</a>({\nkey: value})',
164 resolver.ResolveAllLinks('<pre>$ref:[bar.bon]({\nkey: value})', 163 resolver.ResolveAllLinks('<pre>$ref:[bar.bon]({\nkey: value})',
165 namespace='baz')) 164 namespace='baz'))
166 165
167 # Allow bare "$ref:foo.bar." at the end of a string. 166 # Allow bare "$ref:foo.bar." at the end of a string.
168 self.assertEqual( 167 self.assertEqual(
169 '<a href="bar.html#type-bon">bar.bon</a>.', 168 '<a href="bar.html#type-bon">bar.bon</a>.',
170 resolver.ResolveAllLinks('$ref:bar.bon.', 169 resolver.ResolveAllLinks('$ref:bar.bon.',
171 namespace='baz')) 170 namespace='baz'))
171
172 # If a request is provided it should construct an appropriate relative link.
173 self.assertEqual(
174 'Hi <a href="../../bar.bon.html#property-bar_bon_p3">bar_bon_p3</a>, '
175 '<a href="../../bar.bon.html#property-bar_bon_p3">Bon Bon</a>, '
176 '<a href="../../bar.bon.html#property-bar_bon_p3">bar_bon_p3</a>',
177 resolver.ResolveAllLinks(
178 'Hi $ref:bar_bon_p3, $ref:[bar_bon_p3 Bon Bon], $ref:bar_bon_p3',
179 requestPath='big/long/path/bar.html',
180 namespace='bar.bon'))
172 181
173 if __name__ == '__main__': 182 if __name__ == '__main__':
174 unittest.main() 183 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698