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

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

Issue 220023002: Cleanup ReferenceResolver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add documentation in document_renderer.py Created 6 years, 7 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
« no previous file with comments | « chrome/common/extensions/docs/server2/reference_resolver.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 os 6 import os
7 import unittest 7 import unittest
8 8
9 from future import Future 9 from future import Future
10 from reference_resolver import ReferenceResolver 10 from reference_resolver import ReferenceResolver
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 resolver.GetLink('bar.bon.bar_e3', namespace='bar')) 351 resolver.GetLink('bar.bon.bar_e3', namespace='bar'))
352 self.assertEqual( 352 self.assertEqual(
353 None, 353 None,
354 resolver.GetLink('bar_p3', namespace='baz.bon')) 354 resolver.GetLink('bar_p3', namespace='baz.bon'))
355 self.assertEqual( 355 self.assertEqual(
356 None, 356 None,
357 resolver.GetLink('falafel.faf', namespace='a')) 357 resolver.GetLink('falafel.faf', namespace='a'))
358 self.assertEqual( 358 self.assertEqual(
359 None, 359 None,
360 resolver.GetLink('bar_p3', namespace='foo')) 360 resolver.GetLink('bar_p3', namespace='foo'))
361 self.assertEqual(
362 'Hello <a href="bar.bon#property-bar_bon_p3">bar_bon_p3</a>, '
363 '<a href="bar.bon#property-bar_bon_p3">Bon Bon</a>, '
364 '<a href="bar.bon#property-bar_bon_p3">bar_bon_p3</a>',
365 resolver.ResolveAllLinks(
366 'Hello $ref:bar_bon_p3, $ref:[bar_bon_p3 Bon Bon], $ref:bar_bon_p3',
367 namespace='bar.bon'))
368 self.assertEqual(
369 'I like <a href="bar#property-bar_t1-bar_t1_p1">food</a>.',
370 resolver.ResolveAllLinks('I like $ref:[bar.bar_p3.bar_t1_p1 food].',
371 namespace='foo'))
372 self.assertEqual(
373 'Ref <a href="foo">It\'s foo!</a>',
374 resolver.ResolveAllLinks('Ref $ref:[foo It\'s foo!]', namespace='bar'))
375 self.assertEqual(
376 'Ref <a href="bar#type-bon">Bon</a>',
377 resolver.ResolveAllLinks('Ref $ref:[bar.bon Bon]', namespace='bar'))
378
379 # Different kinds of whitespace can be significant inside <pre> tags.
380 self.assertEqual(
381 '<pre><a href="bar#type-bon">bar.bon</a>({\nkey: value})',
382 resolver.ResolveAllLinks('<pre>$ref:[bar.bon]({\nkey: value})',
383 namespace='baz'))
384
385 # Allow bare "$ref:foo.bar." at the end of a string.
386 self.assertEqual(
387 '<a href="bar#type-bon">bar.bon</a>.',
388 resolver.ResolveAllLinks('$ref:bar.bon.',
389 namespace='baz'))
390
391 # If a request is provided it should construct an appropriate relative link.
392 self.assertEqual(
393 'Hi <a href="../../bar.bon#property-bar_bon_p3">bar_bon_p3</a>, '
394 '<a href="../../bar.bon#property-bar_bon_p3">Bon Bon</a>, '
395 '<a href="../../bar.bon#property-bar_bon_p3">bar_bon_p3</a>',
396 resolver.ResolveAllLinks(
397 'Hi $ref:bar_bon_p3, $ref:[bar_bon_p3 Bon Bon], $ref:bar_bon_p3',
398 relative_to='big/long/path/bar.html',
399 namespace='bar.bon'))
400 self.assertEqual(
401 'Hi <a href="bar.bon#property-bar_bon_p3">bar_bon_p3</a>, '
402 '<a href="bar.bon#property-bar_bon_p3">Bon Bon</a>, '
403 '<a href="bar.bon#property-bar_bon_p3">bar_bon_p3</a>',
404 resolver.ResolveAllLinks(
405 'Hi $ref:bar_bon_p3, $ref:[bar_bon_p3 Bon Bon], $ref:bar_bon_p3',
406 relative_to='',
407 namespace='bar.bon'))
408 self.assertEqual(
409 'Hi <a href="bar.bon#property-bar_bon_p3">bar_bon_p3</a>, '
410 '<a href="bar.bon#property-bar_bon_p3">Bon Bon</a>, '
411 '<a href="bar.bon#property-bar_bon_p3">bar_bon_p3</a>',
412 resolver.ResolveAllLinks(
413 'Hi $ref:bar_bon_p3, $ref:[bar_bon_p3 Bon Bon], $ref:bar_bon_p3',
414 relative_to='bar.html',
415 namespace='bar.bon'))
416 self.assertEqual(
417 'Hi <a href="bar.bon#property-bar_bon_p3">bar_bon_p3</a>, '
418 '<a href="bar.bon#property-bar_bon_p3">Bon Bon</a>, '
419 '<a href="bar.bon#property-bar_bon_p3">bar_bon_p3</a>',
420 resolver.ResolveAllLinks(
421 'Hi $ref:bar_bon_p3, $ref:[bar_bon_p3 Bon Bon], $ref:bar_bon_p3',
422 relative_to='foo/bar.html',
423 namespace='bar.bon'))
424 self.assertEqual(
425 'Hi <a href="../bar.bon#property-bar_bon_p3">bar_bon_p3</a>, '
426 '<a href="../bar.bon#property-bar_bon_p3">Bon Bon</a>, '
427 '<a href="../bar.bon#property-bar_bon_p3">bar_bon_p3</a>',
428 resolver.ResolveAllLinks(
429 'Hi $ref:bar_bon_p3, $ref:[bar_bon_p3 Bon Bon], $ref:bar_bon_p3',
430 relative_to='foo/baz/bar.html',
431 namespace='bar.bon'))
432 361
433 if __name__ == '__main__': 362 if __name__ == '__main__':
434 unittest.main() 363 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/reference_resolver.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698