def test_user_create_same_uname(self): b = blog.Blogs() b.init() b.user.create("test_user", "test_password", "Testname", "Testlname") with self.assertRaises(ValueError): b.user.create("test_user", "test_password", "Testname", "Testlname")
def test_delete_list(self): b = blog.Blogs() b.init() b.auth("etillshi", "ko28nA0GsRH2") b.blog.delete(45) self.assertFalse(any(bl["id"] == 45 for bl in b.blog.list_user())) self.assertFalse(any(bl["id"] == 45 for bl in b.blog.list()))
def test_blog_edit(self): b = blog.Blogs() b.init() with self.assertRaises(RuntimeError): b.blog.edit(2, "Hmmm") b.auth("btaunton1u", "yudD6qmd5I") b.blog.edit(5, "Hmmm") self.assertEqual("Hmmm", b.blog.get(5)["name"])
def test_user_list(self): b = blog.Blogs() b.init() users = b.user.list() self.assertEqual(1002, len(users)) self.assertTrue(any(user["username"]=="test_user" and \ user["password"] == "test_password" and \ user["last_name"] == "Testlname" and \ user["first_name"] == "Testname"\ for user in users))
def test_tree(self): b = blog.Blogs() b.init() b.auth("btaunton1u", "yudD6qmd5I") b.comment.post(1000, "Root_Comment") b.comment.comment(100002, "Comment_level_1") b.comment.comment(100003, "Comment_level_2") check = [ b.comment.get(100002), { 'pid': 100002, 'cid': 100003, 'User_id': 67, 'data': 'Comment_level_1' }, { 'pid': 100003, 'cid': 100004, 'User_id': 67, 'data': 'Comment_level_2' }, ] self.assertEqual(check, b.comment.list_tree(100002))
def test_create(self): b = blog.Blogs() b.init() b.auth("btaunton1u", "yudD6qmd5I") with self.assertRaises(ValueError): b.comment.post(10002, "Test wrong comment")
def test_create_wrong(self): b = blog.Blogs() b.init() b.auth("btaunton1u", "yudD6qmd5I") with self.assertRaises(ValueError): b.post.create("Test_post", (1, 2, 10002), "TestDATA")
def test_create(self): b = blog.Blogs() b.init() b.auth("btaunton1u", "yudD6qmd5I") b.post.create("Test_post", (1, 2), "TestDATA")
def test_delete_unauth(self): b = blog.Blogs() b.init() with self.assertRaises(RuntimeError): b.blog.delete(45)
def test_user_create(self): b = blog.Blogs() b.init() b.user.create("test_user1", "test_password1", "Testname1", "Testlname1") b.auth("test_user1", "test_password1")