Skip to content

Commit

Permalink
Test that we don't render links inside links
Browse files Browse the repository at this point in the history
  • Loading branch information
mgedmin committed Jan 3, 2017
1 parent 799e002 commit 0f57fef
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions src/zodbbrowser/tests/test_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@

from ZODB.utils import p64
from persistent import Persistent
from persistent.dict import PersistentDict
from zope.app.testing import setup
from zope.interface.verify import verifyObject
from zope.interface import implements, alsoProvides, Interface
from zope.component import adapts, provideAdapter

from zodbbrowser.interfaces import IValueRenderer
from zodbbrowser.value import (GenericValue, TupleValue, ListValue, DictValue,
PersistentValue, ProvidesValue, StringValue,
MAX_CACHE_SIZE,
TRUNCATIONS, TRUNCATIONS_IN_ORDER, truncate,
resetTruncations, pruneTruncations)
from zodbbrowser.value import (
GenericValue, TupleValue, ListValue, DictValue, PersistentValue,
PersistentDictValue, ProvidesValue, StringValue, MAX_CACHE_SIZE,
TRUNCATIONS, TRUNCATIONS_IN_ORDER, truncate, resetTruncations,
pruneTruncations)


class OldStyle:
Expand Down Expand Up @@ -411,6 +412,7 @@ class TestPersistentValue(unittest.TestCase):
def setUp(self):
setup.placelessSetUp()
provideAdapter(GenericValue)
provideAdapter(PersistentValue)

def tearDown(self):
setup.placelessTearDown()
Expand All @@ -429,6 +431,30 @@ def test_tid_is_preserved(self):
'<a class="objlink" href="@@zodbbrowser?oid=0x17&amp;tid=42">'
'&lt;PersistentFrob&gt;</a>')

def test_rendering_no_nested_links(self):
self.assertEqual(
PersistentValue(PersistentFrob()).render(can_link=False),
'&lt;PersistentFrob&gt;')


class TestPersistentDictValue(unittest.TestCase):

def setUp(self):
setup.placelessSetUp()
provideAdapter(GenericValue)
provideAdapter(PersistentValue)

def tearDown(self):
setup.placelessTearDown()

def test_rendering_no_nested_links(self):
obj = PersistentDict({1: PersistentFrob()})
obj._p_oid = p64(0x18)
self.assertEqual(
PersistentDictValue(obj).render(),
'<a class="objlink" href="@@zodbbrowser?oid=0x18">'
'{1: &lt;PersistentFrob&gt;}</a>')


class TestProvidesValue(unittest.TestCase):

Expand Down

0 comments on commit 0f57fef

Please sign in to comment.