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

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

Issue 12025022: Add support for $ref'ing namespaces to server2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 | 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
(...skipping 21 matching lines...) Expand all
32 with open(os.path.join(self._base_path, filename), 'r') as f: 32 with open(os.path.join(self._base_path, filename), 'r') as f:
33 return f.read() 33 return f.read()
34 34
35 def testGetLink(self): 35 def testGetLink(self):
36 data_source = FakeAPIDataSource( 36 data_source = FakeAPIDataSource(
37 json.loads(self._ReadLocalFile('fake_data_source.json'))) 37 json.loads(self._ReadLocalFile('fake_data_source.json')))
38 resolver = ReferenceResolver(data_source, 38 resolver = ReferenceResolver(data_source,
39 data_source, 39 data_source,
40 InMemoryObjectStore('')) 40 InMemoryObjectStore(''))
41 self.assertEqual({ 41 self.assertEqual({
42 'href': 'foo.html',
43 'text': 'foo',
44 'name': 'foo'
45 }, resolver.GetLink('foo', namespace='baz'))
46 self.assertEqual({
42 'href': 'foo.html#type-foo_t1', 47 'href': 'foo.html#type-foo_t1',
43 'text': 'foo.foo_t1', 48 'text': 'foo.foo_t1',
44 'name': 'foo_t1' 49 'name': 'foo_t1'
45 }, resolver.GetLink('foo.foo_t1', namespace='baz')) 50 }, resolver.GetLink('foo.foo_t1', namespace='baz'))
46 self.assertEqual({ 51 self.assertEqual({
47 'href': 'baz.html#event-baz_e1', 52 'href': 'baz.html#event-baz_e1',
48 'text': 'baz_e1', 53 'text': 'baz_e1',
49 'name': 'baz_e1' 54 'name': 'baz_e1'
50 }, resolver.GetLink('baz.baz_e1', namespace='baz')) 55 }, resolver.GetLink('baz.baz_e1', namespace='baz'))
51 self.assertEqual({ 56 self.assertEqual({
(...skipping 25 matching lines...) Expand all
77 'href': 'bar.bon.html#property-bar_bon_p3', 82 'href': 'bar.bon.html#property-bar_bon_p3',
78 'text': 'bar_bon_p3', 83 'text': 'bar_bon_p3',
79 'name': 'bar_bon_p3' 84 'name': 'bar_bon_p3'
80 }, resolver.GetLink('bar.bon.bar_bon_p3', namespace='bar.bon')) 85 }, resolver.GetLink('bar.bon.bar_bon_p3', namespace='bar.bon'))
81 self.assertEqual({ 86 self.assertEqual({
82 'href': 'bar.html#event-bar_e2', 87 'href': 'bar.html#event-bar_e2',
83 'text': 'bar_e2', 88 'text': 'bar_e2',
84 'name': 'bar_e2' 89 'name': 'bar_e2'
85 }, resolver.GetLink('bar.bar_e2', namespace='bar')) 90 }, resolver.GetLink('bar.bar_e2', namespace='bar'))
86 self.assertEqual({ 91 self.assertEqual({
87 'href': 'bar.html#type-bon', 92 'href': 'bar.bon.html',
88 'text': 'bon', 93 'text': 'bar.bon',
89 'name': 'bon' 94 'name': 'bar.bon'
90 }, resolver.GetLink('bar.bon', namespace='bar')) 95 }, resolver.GetLink('bar.bon', namespace='bar'))
91 self.assertEqual({ 96 self.assertEqual({
92 'href': 'foo.html#event-foo_t3-foo_t3_e1', 97 'href': 'foo.html#event-foo_t3-foo_t3_e1',
93 'text': 'foo_t3.foo_t3_e1', 98 'text': 'foo_t3.foo_t3_e1',
94 'name': 'foo_t3_e1' 99 'name': 'foo_t3_e1'
95 }, resolver.GetLink('foo_t3.foo_t3_e1', namespace='foo')) 100 }, resolver.GetLink('foo_t3.foo_t3_e1', namespace='foo'))
96 self.assertEqual({ 101 self.assertEqual({
97 'href': 'foo.html#event-foo_t3-foo_t3_e1', 102 'href': 'foo.html#event-foo_t3-foo_t3_e1',
98 'text': 'foo_t3.foo_t3_e1', 103 'text': 'foo_t3.foo_t3_e1',
99 'name': 'foo_t3_e1' 104 'name': 'foo_t3_e1'
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 '<a href="bar.bon.html#property-bar_bon_p3">Bon Bon</a>, ' 138 '<a href="bar.bon.html#property-bar_bon_p3">Bon Bon</a>, '
134 '<a href="bar.bon.html#property-bar_bon_p3">bar_bon_p3</a>', 139 '<a href="bar.bon.html#property-bar_bon_p3">bar_bon_p3</a>',
135 resolver.ResolveAllLinks( 140 resolver.ResolveAllLinks(
136 'Hello $ref:bar_bon_p3, $ref:[bar_bon_p3 Bon Bon], $ref:bar_bon_p3', 141 'Hello $ref:bar_bon_p3, $ref:[bar_bon_p3 Bon Bon], $ref:bar_bon_p3',
137 namespace='bar.bon')) 142 namespace='bar.bon'))
138 self.assertEqual( 143 self.assertEqual(
139 'I like <a href="bar.html#property-bar_t1-bar_t1_p1">food</a>.', 144 'I like <a href="bar.html#property-bar_t1-bar_t1_p1">food</a>.',
140 resolver.ResolveAllLinks('I like $ref:[bar.bar_p3.bar_t1_p1 food].', 145 resolver.ResolveAllLinks('I like $ref:[bar.bar_p3.bar_t1_p1 food].',
141 namespace='foo')) 146 namespace='foo'))
142 self.assertEqual( 147 self.assertEqual(
143 'Ref <a href="bar.html#type-bon">bon</a>', 148 'Ref <a href="bar.bon.html">Bon</a>',
144 resolver.ResolveAllLinks('Ref $ref:[bar.bon]', namespace='bar')) 149 resolver.ResolveAllLinks('Ref $ref:[bar.bon Bon]', namespace='bar'))
145 150
146 if __name__ == '__main__': 151 if __name__ == '__main__':
147 unittest.main() 152 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698