class TestBlog(unittest.TestCase): def setUp(self) -> None: self.blog = Blog('Test', 'Test Author') def tearDown(self) -> None: del self.blog def test_create_post_in_blog(self): self.blog.create_post('Test post', 'Test Content') self.assertEqual(len(self.blog.posts), 1) self.assertEqual(self.blog.posts[0].title, 'Test post') self.assertEqual(self.blog.posts[0].content, 'Test Content') def test_json_no_post(self): expected = {'title': 'Test', 'author': 'Test Author', 'posts': []} self.assertDictEqual(expected, self.blog.json()) def test_json(self): self.blog.create_post('Test post', 'Test Content') expected = { 'title': 'Test', 'author': 'Test Author', 'posts': [{ 'title': 'Test post', 'content': 'Test Content' }] } self.assertDictEqual(expected, self.blog.json())
def test_json(self): b = Blog('TestTitle', 'TestAuthor') self.assertDictEqual(b.json(), { 'title': 'TestTitle', 'author': 'TestAuthor', 'posts': [] })
def test_json_no_posts(self): b = Blog("Test", "Test Author") expected = { "title": "Test", "author": "Test Author", "posts": [], } self.assertDictEqual(expected, b.json())
def test_json(self): b = Blog("Test", "Test Author") b.create_post("Test Post", "Test Content") expected = {"title": "Test", "author": "Test Author", "posts": [{"title": "Test Post", "content": "Test Content"}]} self.assertDictEqual(expected, b.json())
def test_json_no_posts(self): b = Blog("Testbloggen", "Alexandra Wåhlander") expected = {"Title": "Testbloggen", "Author": "Alexandra Wåhlander", "Posts": [] } self.assertDictEqual(expected, b.json())
def test_json(self): post1 = Post("post1 title", "post1 content") post2 = Post("post2 title", "post2 content") posts = [post1, post2] expected_json = { "title": "Test", "author": "Author", "posts": [Post("post1 title", "post1 content"), Post("post2 title", "post2 content")] } b = Blog("Test", "Author", posts) print(b.json().__repr__()) print(expected_json.__repr__()) self.assertEqual(expected_json.__repr__(), b.json().__repr__(), "Blog json is incorrect!")
def test_json_no_posts(self): b = Blog('Test', 'Test author') self.assertDictEqual(b.json(), { 'title': b.title, 'author': b.author, 'posts': [], })
def test_json_no_posts(self): b = Blog('Test', 'Test Author') expected = { 'title': 'Test', 'author': 'Test Author', 'posts': [] } self.assertDictEqual(expected, b.json())
def test_json(self): b = Blog("Testing Json", "Neto") b.create_post("Testing Post", "Testing Post Content") self.assertDictEqual({"title": "Testing Json", "author": "Neto", "posts": [{"title": "Testing Post", "content": "Testing Post Content"}]}, b.json(), "The json was not created")
def test_json_no_posts(self): b = Blog('Test', 'Test Author') expected = { "title": "Test", "author": "Test Author", "posts": [] } self.assertDictEqual(b.json(), expected)
def test_json_with_no_posts(self): b = Blog('My Blog', 'John Smith') expected = {'title': 'My Blog', 'author': 'John Smith', 'posts': [] } self.assertDictEqual(expected, b.json())
def test_json_no_posts(self): b = Blog('My blog', 'VV') exp_json = { 'title': 'My blog', 'author': 'VV', 'posts': [] } self.assertDictEqual(exp_json, b.json())
def test_json_with_posts(self): b = Blog('Test', 'Test author') b.create_post('Test Post', 'Test Content') self.assertDictEqual(b.json(), { 'title': b.title, 'author': b.author, 'posts': [{'title': 'Test Post', 'content': 'Test Content'}], })
def test_json_no_posts(self): new_blog = Blog("Test Title", "Test Author") expected = { 'title': 'Test Title', 'author': 'Test Author', 'posts': [] } self.assertDictEqual(expected, new_blog.json())
def test_json_no_post(self): blog_object = Blog('test_title', 'test_author') # Given data to test expected = { 'title': 'test_title', 'author': 'test_author', 'posts': [] } self.assertDictEqual(expected, blog_object.json())
def test_json(self): b = Blog('Test Blog', 'Manuel') b.create_post('foo', 'bar') expected = { 'title': "Test Blog", "author": "Manuel", "posts": [{ "title": 'foo', "content": "bar" }] } self.assertEqual('Test Blog', b.json()['title']) self.assertEqual("Manuel", b.json()['author']) self.assertEqual(1, len(b.json()["posts"])) self.assertEqual('foo', b.json()['posts'][0].title) self.assertEqual('bar', b.json()['posts'][0].content)
def test_json(self): b = Blog('Test', 'Test Author') b.create_post('Test Post', 'Test Content') expected = {'title': 'Test', 'author': 'Test Author', 'posts': [{'title': 'Test Post', 'content': 'Test Content'}]} self.assertDictEqual(expected, b.json())
def test_json_no_post(self): b = Blog("Title blog", "Author blog") expected = { "title": "Title blog", "author": "Author blog", "posts": [] } self.assertDictEqual(b.json(), expected)
def test_json(self): b = Blog("Test", "Test Author") b.create_post("Test Post", "Test Content") expected = { "title": "Test", "author": "Test Author", "posts": [ {"title": "Test Post", "content": "Test Content"}] } self.assertDictEqual(expected, b.json())
def test_json(self): b = Blog('My Blog', 'John Smith') b.create_post('Post Title', 'Post Content') expected = {'title': 'My Blog', 'author': 'John Smith', 'posts': [{'title': 'Post Title', 'content': 'Post Content'} ], } self.assertDictEqual(expected, b.json())
def test_json(self): b = Blog("Testbloggen", "Alexandra Wåhlander") b.create_post("Test post", "Test Content") expected = {"Title": "Testbloggen", "Author": "Alexandra Wåhlander", "Posts": [ {"title": "Test post", "content": "Test Content"}] } self.assertDictEqual(expected, b.json())
def test_blog_json(): b = Blog('Test', 'Test Author') b.create_post('Test Post', 'Test Content') expected = { 'title': 'Test', 'author': 'Test Author', 'posts': [{ 'title': 'Test Post', 'content': 'Test Content' }] } assert b.json() == expected
def test_json(self): b = Blog('Test', 'Test Author') b.create_post('Test Post', 'Test Content') expected = { "title": "Test", "author": "Test Author", "posts": [{ "title": "Test Post", "content": "Test Content", }] } self.assertDictEqual(b.json(), expected)
def test_json_with_post(self): b = Blog('TestTitle', 'TestAuthor') b.create_post('TestPostTitle', 'TestContent') self.assertDictEqual( b.json(), { 'title': 'TestTitle', 'author': 'TestAuthor', 'posts': [{ 'title': 'TestPostTitle', 'content': 'TestContent' }] })
def test_json(self): b = Blog('The best book', 'John Doe') b.create_post('Test Post', 'Test content') expect = { 'title': 'The best book', 'author': 'John Doe', 'posts': [{ 'title': 'Test Post', 'content': 'Test content', }] } self.assertDictEqual(expect, b.json())
def test_json(self): blog_object = Blog('test_title', 'test_author') # Given data to test blog_object.create_post('post_title', 'post_content') expected = { 'title': 'test_title', 'author': 'test_author', 'posts': [{ 'title': 'post_title', 'content': 'post_content' }] } self.assertDictEqual(expected, blog_object.json())
def test_json_no_posts(self): b = Blog('Test', 'Test Author') b.posts = [Post('', '')] expected_json = { 'title': 'Test', 'author': 'Test Author', 'posts': [ { 'title': '', 'content': '' } ] } self.assertEqual(expected_json, b.json())
def test_json(self): my_blog = Blog('BlogName', 'BlogAuthor') my_blog.create_post('PostTitle', 'PostContent') expected = { 'title': 'BlogName', 'author': 'BlogAuthor', 'posts': [{ 'title': 'PostTitle', 'content': 'PostContent' }] } self.assertDictEqual(expected, my_blog.json())
def test_json_no_post(self): """ Unit test for json method when no posts """ b_1 = Blog('Test title', 'Test author') expected = { 'Title': 'Test title', 'Author': 'Test author', 'Posts': [post.json() for post in b_1.posts], } self.assertDictEqual(b_1.json(), expected)
def test_json(self): b = Blog("Love", "Kingsman") b.create_post("love", "siblings") expected = { "title": "Love", "author": "Kingsman", "posts": [{ "title": "love", "content": "siblings" }] } self.assertDictEqual(expected, b.json())
def test_json(self): b = Blog('Test Title', 'Author') b.create_post("Kenya", "Amazing Kenya") expected = { 'title': 'Test Title', 'author': 'Author', 'posts': [{ 'title': "Kenya", 'content': 'Amazing Kenya' }] } self.assertDictEqual(expected, b.json())
def test_json(self): blog = Blog('Title', 'Author') blog.create_post('PostTitle', 'PostContent') expected = { 'title': 'Title', 'author': 'Author', 'posts': [{'Title': 'PostTitle', 'Content': 'PostContent', }, ] } self.assertEqual(blog.json(), expected)
def test_json_no_posts(self): b = Blog("Test", "Test Author") expected = {"title": "Test", "author": "Test Author", "posts": []} self.assertDictEqual(expected, b.json())