def test_007_add_article(self): self.assertEqual(0, blog.get_sum_articles()) id_user = self.add_user('*****@*****.**') with self.assertRaises(blog.SlugNotValidException): blog.add_article('slug E! rorsti', 'Artical title', id_user,'', '') with self.assertRaises(blog.SlugNotValidException): blog.add_article('Slug Eror!@#!@#!@#!@#', 'Title with some char', id_user, '', '') with self.assertRaises(blog.TitleNotValidException): blog.add_article(' ', 'Title with Not valid Char !sdasd', id_user, '', '') with self.assertRaises(blog.TitleNotValidException): blog.add_article('correctslug', 'not Valid Title !sdasd', id_user, '', '') blog.add_article('correctslugsd', 'asda sdasd', id_user, '', '') self.assertEqual(1, blog.get_sum_articles()) with self.assertRaises(blog.ArticleAlreadyExistsException): blog.add_article('correctslugsd', 'asda sdasd', id_user, '', '') with self.assertRaises(blog.ArticleAlreadyExistsException): blog.add_article('', 'ispravan stitle', id_user, '', '') self.assertTrue(blog.delete_all_articles())
def test_005_delete_all_articles(self): self.assertEqual(0, blog.get_sum_articles()) id = self.add_article(None,'*****@*****.**') self.assertEqual(1, blog.get_sum_articles()) self.assertTrue(blog.delete_all_articles()) self.assertEqual(0, blog.get_sum_articles())
def test_006_delete_article(self): self.assertEqual(0, blog.get_sum_articles()) id_article = self.add_article(None, '*****@*****.**') self.assertEqual(1, blog.get_sum_articles()) self.assertTrue(blog.delete_article(id_article)) self.assertEqual(0, blog.get_sum_articles())
def test_008_get_articles(self): self.assertEqual(0, blog.get_sum_articles()) self.assertEqual(0, blog.get_sum_users()) self.add_article(None,'*****@*****.**') self.add_article(None,'*****@*****.**') self.add_article(None,'*****@*****.**') self.assertEqual(3, blog.get_sum_articles()) self.assertEqual(3, blog.get_sum_users()) self.assertTrue(blog.delete_all_articles())
def test_009_get_article(self): self.assertEqual(0, blog.get_sum_articles()) self.assertEqual(0, blog.get_sum_users()) id = self.add_article(None, '*****@*****.**') id2 =self.add_article(None, '*****@*****.**') #didati get artikal sa errorom self.assertEqual(2, blog.get_sum_articles()) self.assertEqual(2, blog.get_sum_users()) title = blog.get_article(id2).title self.assertEqual(title, blog.get_article(id2).title) self.assertFalse(blog.get_article('asdasdas')) self.assertTrue(blog.delete_all_articles())
def test_010_edit_article(self): self.assertEqual(0, blog.get_sum_articles()) self.assertEqual(0, blog.get_sum_users()) with self.assertRaises(blog.ArticleDoesntExist): blog.edit_article('psadasdsa','asdasdasd','asdasdasdasdasd') # self.assertTrue(blog.delete_all_articles()) id_article = self.add_article(None,'*****@*****.**') self.assertEqual(1, blog.get_sum_users()) self.assertEqual(1, blog.get_sum_articles()) title = blog.get_article(id_article).title self.assertEqual(title, blog.get_article(id_article).title) self.assertTrue(blog.edit_article(id_article, 'askkdakjkjsdasd', 'asdasdasdasdasd')) title = blog.get_article(id_article).title self.assertEqual(title, blog.get_article(id_article).title)