Mercurial > p > roundup > code
diff test/test_templating.py @ 6338:a70a0c138dd9
Test hyperlinked method on designators
Smarter definition of hasnode in mock database.
Designators with id's > 10 will return False from hasnode.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Fri, 12 Mar 2021 02:47:13 -0500 |
| parents | 316c2c32dace |
| children | ab18fe956d45 |
line wrap: on
line diff
--- a/test/test_templating.py Fri Mar 12 01:49:38 2021 -0500 +++ b/test/test_templating.py Fri Mar 12 02:47:13 2021 -0500 @@ -49,7 +49,7 @@ raise KeyError('There is no class called "%s"' % name) # Class returned must have hasnode(id) method that returns true # otherwise designators like 'issue1' can't be hyperlinked. - self.classes[name].hasnode = lambda id: True + self.classes[name].hasnode = lambda id: True if int(id) < 10 else False return self.classes[name] # setup for csrf testing of otks database api @@ -252,6 +252,26 @@ self.assertEqual(p.plain(escape=1, hyperlink=1), 'A string <b> with <a href="mailto:rouilj@example.com">rouilj@example.com</a> embedded &lt; html</b>') self.assertEqual(p.hyperlinked(), 'A string <b> with <a href="mailto:rouilj@example.com">rouilj@example.com</a> embedded &lt; html</b>') + # check designators + for designator in [ "issue1", "issue 1" ]: + p = StringHTMLProperty(self.client, 'test', '1', None, 'test', designator) + self.assertEqual(p.hyperlinked(), + '<a href="issue1">%s</a>'%designator) + + # issue 100 > 10 which is a magic number for the mocked hasnode + # If id number is greater than 10 hasnode reports it does not have + # the node. + for designator in ['issue100', 'issue 100']: + p = StringHTMLProperty(self.client, 'test', '1', None, 'test', + designator) + self.assertEqual(p.hyperlinked(), designator) + + # zoom class does not exist + for designator in ['zoom1', 'zoom100', 'zoom 1']: + p = StringHTMLProperty(self.client, 'test', '1', None, 'test', + designator) + self.assertEqual(p.hyperlinked(), designator) + @skip_rst def test_string_rst(self):
