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_create_blog(self): b = Blog('Test', 'Test Author') self.assertEqual('Test', b.title) self.assertEqual('Test Author', b.author) self.assertListEqual([], b.posts) self.assertEqual(0, len(b.posts))
def setUp(self): blog = Blog('Test', 'Test Author') app.blogs = {'Test': blog}
def test_repr_multiple_posts(self): b = Blog('Test', 'Test Author') b.posts = ['test'] self.assertEqual(b.__repr__(), 'Test by Test Author (1 post)')
def test_repr(self): b = Blog('Test', 'Test Author') self.assertEqual(b.__repr__(), '{} by {} (0 posts)'.format(b.title, b.author))
def test_create_post_in_blog(self): b = Blog('Test', 'Test Author') b.create_post('Test Post', 'Test Content') self.assertEqual(len(b.posts), 1) self.assertEqual(b.posts[0].title, 'Test Post')
def ask_create_blog(): title = input('Enter your blog title: ') author = input('Enter your name: ') blogs[title] = Blog(title, author)