Mercurial > p > roundup > code
comparison test/test_mailgw.py @ 6657:2453d7b58a92
Start work on supporting testing of beautifulsoup
Change original dehtml only test into a method to be called by a test
method. Converter to be used is passed in and selects the right
comparison text.
All this change does is set things up to run the dehtml test
parameterized. It also provdes the stub for the beautiful soup test.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 02 May 2022 17:04:27 -0400 |
| parents | 7f00fc5958ca |
| children | 0ef688717613 |
comparison
equal
deleted
inserted
replaced
| 6656:b83b90d57846 | 6657:2453d7b58a92 |
|---|---|
| 1379 | 1379 |
| 1380 %s | 1380 %s |
| 1381 --001485f339f8f361fb049188dbba-- | 1381 --001485f339f8f361fb049188dbba-- |
| 1382 '''%html_doc | 1382 '''%html_doc |
| 1383 | 1383 |
| 1384 def testMultipartTextifyHTML(self): | 1384 def disabletestMultipartTextifyHTMLBeautifulSoup(self): |
| 1385 text_fragments = ['Roundup\n Home\nDownload\nDocs\nRoundup Features\nInstalling Roundup\nUpgrading to newer versions of Roundup\nRoundup FAQ\nUser Guide\nCustomising Roundup\nAdministration Guide\nPrerequisites\n\nRoundup requires Python 2.5 or newer (but not Python 3) with a functioning\nanydbm module. Download the latest version from http://www.python.org/.\nIt is highly recommended that users install the latest patch version\nof python as these contain many fixes to serious bugs.\n\nSome variants of Linux will need an additional ', ('python dev', u2s(u'\u201cpython dev\u201d')), ' package\ninstalled for Roundup installation to work. Debian and derivatives, are\nknown to require this.\n\nIf you', (u2s(u'\u2019'), ''), 're on windows, you will either need to be using the ActiveState python\ndistribution (at http://www.activestate.com/Products/ActivePython/), or you', (u2s(u'\u2019'), ''), 'll\nhave to install the win32all package separately (get it from\nhttp://starship.python.net/crew/mhammond/win32/).\n\numlaut'] | 1385 self.maxDiff = None |
| 1386 self.MultipartTextifyHTML(converter="beautifulsoup") | |
| 1387 | |
| 1388 def testMultipartTextifyHTMLDehtml(self): | |
| 1389 self.MultipartTextifyHTML(converter="dehtml") | |
| 1390 | |
| 1391 def MultipartTextifyHTML(self, converter='dehtml'): | |
| 1392 text_fragments = {} | |
| 1393 text_fragments['dehtml'] = ['Roundup\n Home\nDownload\nDocs\nRoundup Features\nInstalling Roundup\nUpgrading to newer versions of Roundup\nRoundup FAQ\nUser Guide\nCustomising Roundup\nAdministration Guide\nPrerequisites\n\nRoundup requires Python 2.5 or newer (but not Python 3) with a functioning\nanydbm module. Download the latest version from http://www.python.org/.\nIt is highly recommended that users install the latest patch version\nof python as these contain many fixes to serious bugs.\n\nSome variants of Linux will need an additional ', ('python dev', u2s(u'\u201cpython dev\u201d')), ' package\ninstalled for Roundup installation to work. Debian and derivatives, are\nknown to require this.\n\nIf you', (u2s(u'\u2019'), ''), 're on windows, you will either need to be using the ActiveState python\ndistribution (at http://www.activestate.com/Products/ActivePython/), or you', (u2s(u'\u2019'), ''), 'll\nhave to install the win32all package separately (get it from\nhttp://starship.python.net/crew/mhammond/win32/).\n\numlaut'] + [b2s(b" \xc3\xa4\xc3\xb6\xc3\xbc\xc3\x84\xc3\x96\xc3\x9c\xc3\x9f")] | |
| 1386 | 1394 |
| 1387 # \xc3\xa4\xc3\xb6\xc3\xbc\xc3\x84\xc3\x96\xc3\x9c\xc3\x9f | 1395 # \xc3\xa4\xc3\xb6\xc3\xbc\xc3\x84\xc3\x96\xc3\x9c\xc3\x9f |
| 1388 # append above with leading space to end of mycontent. It is the | 1396 # append above with leading space to end of mycontent. It is the |
| 1389 # translated content when =E4=F6=FC=C4=D6=DC=DF is added to the html | 1397 # translated content when =E4=F6=FC=C4=D6=DC=DF is added to the html |
| 1390 # input. | 1398 # input. |
| 1391 self.doNewIssue() | 1399 self.doNewIssue() |
| 1392 self.db.config.MAILGW_CONVERT_HTMLTOTEXT = 'dehtml' | 1400 self.db.config.MAILGW_CONVERT_HTMLTOTEXT = converter |
| 1393 self._handle_mail(self.multipart_msg_notext) | 1401 self._handle_mail(self.multipart_msg_notext) |
| 1394 messages = self.db.issue.get('1', 'messages') | 1402 messages = self.db.issue.get('1', 'messages') |
| 1395 messages.sort() | 1403 messages.sort() |
| 1396 msg = self.db.msg.getnode(messages[-1]) | 1404 msg = self.db.msg.getnode(messages[-1]) |
| 1405 | |
| 1406 print(msg.content) | |
| 1407 print(text_fragments[converter][0]) | |
| 1397 # html converted to utf-8 text | 1408 # html converted to utf-8 text |
| 1398 self.compareStringFragments(msg.content, | 1409 self.compareStringFragments(msg.content, |
| 1399 text_fragments + [b2s(b" \xc3\xa4\xc3\xb6\xc3\xbc\xc3\x84\xc3\x96\xc3\x9c\xc3\x9f")]) | 1410 text_fragments[converter]) |
| 1400 self.assertEqual(msg.type, None) | 1411 self.assertEqual(msg.type, None) |
| 1401 self.assertEqual(len(msg.files), 2) | 1412 self.assertEqual(len(msg.files), 2) |
| 1402 name = "unnamed" # no name for any files | 1413 name = "unnamed" # no name for any files |
| 1403 types = { 0: "text/csv", 1: "text/html" } | 1414 types = { 0: "text/csv", 1: "text/html" } |
| 1404 # replace quoted printable string at end of html document | 1415 # replace quoted printable string at end of html document |
