|
59 | 59 | </rss> |
60 | 60 | """ |
61 | 61 |
|
62 | | - |
63 | 62 | class MockResponse: |
64 | 63 | headers = {} |
65 | 64 | url = '' |
@@ -359,6 +358,98 @@ def testDescription(self, mock): |
359 | 358 | self.assertRegexp('rss http://xkcd.com/rss.xml', |
360 | 359 | 'On the other hand, the refractor\'s') |
361 | 360 |
|
| 361 | + @mock_urllib |
| 362 | + def testContentHtmlOnly(self, mock): |
| 363 | + timeFastForward(1.1) |
| 364 | + with conf.supybot.plugins.RSS.format.context('$content'): |
| 365 | + mock._data = """ |
| 366 | +<?xml version="1.0" encoding="UTF-8"?> |
| 367 | +<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="en-US"> |
| 368 | + <title>Recent Commits to anope:2.0</title> |
| 369 | + <updated>2023-10-04T16:14:39Z</updated> |
| 370 | + <entry> |
| 371 | + <title>title with <pre>HTML<pre></title> |
| 372 | + <updated>2023-10-04T16:14:39Z</updated> |
| 373 | + <content type="html"> |
| 374 | + content with <pre>HTML<pre> |
| 375 | + </content> |
| 376 | + </entry> |
| 377 | +</feed>""" |
| 378 | + self.assertRegexp('rss https://example.org', |
| 379 | + 'content with HTML') |
| 380 | + |
| 381 | + @mock_urllib |
| 382 | + def testContentXhtmlOnly(self, mock): |
| 383 | + timeFastForward(1.1) |
| 384 | + with conf.supybot.plugins.RSS.format.context('$content'): |
| 385 | + mock._data = """ |
| 386 | +<?xml version="1.0" encoding="UTF-8"?> |
| 387 | +<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="en-US"> |
| 388 | + <title>Recent Commits to anope:2.0</title> |
| 389 | + <updated>2023-10-04T16:14:39Z</updated> |
| 390 | + <entry> |
| 391 | + <title>title with <pre>HTML<pre></title> |
| 392 | + <updated>2023-10-04T16:14:39Z</updated> |
| 393 | + <content type="xhtml"> |
| 394 | + <div xmlns="http://www.w3.org/1999/xhtml"> |
| 395 | + content with <pre>XHTML<pre> |
| 396 | + </div> |
| 397 | + </content> |
| 398 | + </entry> |
| 399 | +</feed>""" |
| 400 | + self.assertRegexp('rss https://example.org', |
| 401 | + 'content with XHTML') |
| 402 | + |
| 403 | + @mock_urllib |
| 404 | + def testContentHtmlAndPlaintext(self, mock): |
| 405 | + timeFastForward(1.1) |
| 406 | + with conf.supybot.plugins.RSS.format.context('$content'): |
| 407 | + mock._data = """ |
| 408 | +<?xml version="1.0" encoding="UTF-8"?> |
| 409 | +<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="en-US"> |
| 410 | + <title>Recent Commits to anope:2.0</title> |
| 411 | + <updated>2023-10-04T16:14:39Z</updated> |
| 412 | + <entry> |
| 413 | + <title>title with <pre>HTML<pre></title> |
| 414 | + <updated>2023-10-04T16:14:39Z</updated> |
| 415 | + <!-- Atom spec says multiple contents is invalid, feedparser says it's not. |
| 416 | + I like having the option, so let's make sure we support it. --> |
| 417 | + <content type="html"> |
| 418 | + content with <pre>HTML<pre> |
| 419 | + </content> |
| 420 | + <content type="text"> |
| 421 | + content with plaintext |
| 422 | + </content> |
| 423 | + </entry> |
| 424 | +</feed>""" |
| 425 | + self.assertRegexp('rss https://example.org', |
| 426 | + 'content with plaintext') |
| 427 | + |
| 428 | + @mock_urllib |
| 429 | + def testContentPlaintextAndHtml(self, mock): |
| 430 | + timeFastForward(1.1) |
| 431 | + with conf.supybot.plugins.RSS.format.context('$content'): |
| 432 | + mock._data = """ |
| 433 | +<?xml version="1.0" encoding="UTF-8"?> |
| 434 | +<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="en-US"> |
| 435 | + <title>Recent Commits to anope:2.0</title> |
| 436 | + <updated>2023-10-04T16:14:39Z</updated> |
| 437 | + <entry> |
| 438 | + <title>title with <pre>HTML<pre></title> |
| 439 | + <updated>2023-10-04T16:14:39Z</updated> |
| 440 | + <!-- Atom spec says multiple contents is invalid, feedparser says it's not. |
| 441 | + I like having the option, so let's make sure we support it. --> |
| 442 | + <content type="text"> |
| 443 | + content with plaintext |
| 444 | + </content> |
| 445 | + <content type="html"> |
| 446 | + content with <pre>HTML<pre> |
| 447 | + </content> |
| 448 | + </entry> |
| 449 | +</feed>""" |
| 450 | + self.assertRegexp('rss https://example.org', |
| 451 | + 'content with plaintext') |
| 452 | + |
362 | 453 | @mock_urllib |
363 | 454 | def testFeedAttribute(self, mock): |
364 | 455 | timeFastForward(1.1) |
|
0 commit comments