コード例 #1
0
 def test_Formatter_GivenNoImages_ReturnsCorrectFullReply(self):
     expected_reply = (
         'This Craigslist post has been archived so it can continue to be viewed after expiration.\n\n'
         '[original post](http://indianapolis.craigslist.org/bar/d/bears/6451661128.html) | [imgur album](https://imgur.com/a/zzzz1) | [screenshot](https://i.imgur.com/abcd000.jpg)\n\n'
         '> ### Post title ###\n'
         '>\n'
         '> Post description line 1.\n'
         '>\n'
         '> Post description line 2.\n\n'
         '***\n\n'
         '[^github](https://github.com/darricktheprogrammer/reddit-cl-bot) ^| [^send ^message/report](/#)'
     )
     a = deepcopy(self.archive)
     a.images = []
     formatter = bot.PostFormatter()
     self.assertEqual(expected_reply, formatter.format(a))
コード例 #2
0
 def test_Formatter_GivenMultipleImage_FormatsImagesAsQuote(self):
     formatter = bot.PostFormatter()
     text = '> [image 1](https://i.imgur.com/abcd001.jpg) | [image 2](https://i.imgur.com/abcd002.jpg) | [image 3](https://i.imgur.com/abcd003.jpg)'
     self.assertIn(text, formatter.format(self.archive))
コード例 #3
0
 def test_Formatter_GivenNoImages_HasNoTrailingQuoteMarks(self):
     formatter = bot.PostFormatter()
     a = deepcopy(self.archive)
     a.images = []
     self.assertIn('> Post description line 2.\n', formatter.format(a))
     self.assertNotIn('> Post description line 2.\n>', formatter.format(a))
コード例 #4
0
 def test_Formatter_GivenMultiLineAdBody_FormatsAllLinesAsQuote(self):
     formatter = bot.PostFormatter()
     text = '> Post description line 1.\n>\n> Post description line 2.'
     self.assertIn(text, formatter.format(self.archive))
コード例 #5
0
 def test_Formatter_GivenImage_FormatsImagesAsQuote(self):
     formatter = bot.PostFormatter()
     a = deepcopy(self.archive)
     a.images = a.images[:1]
     text = '> [image 1](https://i.imgur.com/abcd001.jpg)'
     self.assertIn(text, formatter.format(a))
コード例 #6
0
 def test_Formatter_GivenAdBody_FormatsAdBodyAsQuote(self):
     formatter = bot.PostFormatter()
     text = '> Post description line 1'
     self.assertIn(text, formatter.format(self.archive))
コード例 #7
0
 def test_Formatter_GivenScreenshot_FormatsScreenshot(self):
     formatter = bot.PostFormatter()
     linktext = '[screenshot](https://i.imgur.com/abcd000.jpg)'
     self.assertIn(linktext, formatter.format(self.archive))
コード例 #8
0
 def test_Formatter_GivenAlbumUrl_FormatsAlbumUrl(self):
     formatter = bot.PostFormatter()
     linktext = '[imgur album](https://imgur.com/a/zzzz1)'
     self.assertIn(linktext, formatter.format(self.archive))
コード例 #9
0
 def test_Formatter_GivenOriginalPost_FormatsOriginalPost(self):
     formatter = bot.PostFormatter()
     linktext = '[original post](http://indianapolis.craigslist.org/bar/d/bears/6451661128.html)'
     self.assertIn(linktext, formatter.format(self.archive))
コード例 #10
0
 def test_Formatter_GivenArchive_FormatsTitleAsQuote(self):
     formatter = bot.PostFormatter()
     self.assertIn('> ### Post title ###', formatter.format(self.archive))