class TestGetArticles(unittest.TestCase): """ Test method VimBlogger.get_articles """ def setUp(self): """ Create VimBlogger object """ self.vimob = VimBlogger(None, shared.LOGIN, shared.PASS) def test_get_articles(self): """ Test removing article without id """ articles = self.vimob.get_articles() self.assertEqual(len(articles), 4) articles = self.vimob.get_articles(maxarticles=2) self.assertEqual(len(articles), 2)
def delete(self): """ Get list of articles, display it to the user, make him choose one and delete """ if not self.password: self.password = \ vim.eval('inputsecret("Enter your gmail password: "******"inputlist([" for index, entries in enumerate(posts): line = "%2d %s %s" % (index + 1, entries[1], entries[2]) msg += u'"' + line.replace('"', '\\"') + u'",' msg = msg[:-1] msg += u"])" msg = unicode(msg).encode(self.vim_encoding) choice = int(vim.eval(msg)) if choice: art = posts[choice - 1] msg = 'confirm("You are about to delete article \'%s\'. ' msg += 'Are you sure?"' msg = unicode(msg % art[1]).encode(self.vim_encoding) msg += ', "&No\n&Yes")' if self.confirm_del: choice = int(vim.eval(msg)) else: choice = 2 if choice == 2: blog.delete_article(art[0]) return "Article deleted" return "No articles deleted"