def test_ask_create_blog(self): blog = app.blogs["Test"] with patch("builtins.input") as mocked_input: mocked_input.side_effect = ("Test", "Test Title", "Test Content") app.ask_create_post() self.assertEqual(blog.posts[0].title, "Test Title") self.assertEqual(blog.posts[0].content, "Test Content")
def test_ask_create_post(self, mocked_input): #blog = Blog('Test','Author') app.blogs = {'Test': self.blog} mocked_input.side_effect = ('Test', 'Test Title', 'Test Content') app.ask_create_post() self.assertEqual(self.blog.posts[0].title, 'Test Title') self.assertEqual(self.blog.posts[0].content, 'Test Content')
def test_ask_create_post(self): with patch('builtins.input') as mocked_input: mocked_input.side_effect = ('Test', 'Test title', 'Test Content') app.ask_create_post() self.assertEqual(app.blogs['Test'].posts[0].title, 'Test title') self.assertEqual(app.blogs['Test'].posts[0].content, 'Test Content')
def test_create_post(self): with patch('builtins.input') as mocked_input: mocked_input.side_effect = ('Test', 'Test Title', 'Test Content') app.ask_create_post() self.assertEqual(app.blogs['Test'].__repr__(), 'Test by Test Author (1 posts)')
def test_ask_create_post(self): with patch("builtins.input") as mocked_input: mocked_input.side_effect = ("Test", "Test Title", "Test Content") app.ask_create_post() self.assertEqual(app.blogs["Test"].posts[0].title, "Test Title") self.assertEqual(app.blogs["Test"].posts[0].content, "Test Content")
def test_ask_create_post(): blog = Blog('Test', 'Test Author') app.blogs = {'Test': blog} with patch('builtins.input', side_effect=['Test', 'Test Post Title', 'Test Post Content']): app.ask_create_post() assert blog.posts[0].title == 'Test Post Title' assert blog.posts[0].content == 'Test Post Content'
def test_ask_create_post(self): # review this one hard blog = app.blogs['Test'] with patch('builtins.input') as mocked_input: mocked_input.side_effect = ('Test', 'Test Title', 'Test Content') app.ask_create_post() self.assertEqual(blog.posts[0].title, 'Test Title') self.assertEqual(blog.posts[0].content, 'Test Content')
def test_ask_create_post(self): blog = Blog("Test", "Test author") app.blogs = {"Test": blog} with patch("builtins.input") as mocked_input: mocked_input.side_effect = ('Test', 'Title_post', 'Content') app.ask_create_post() self.assertEqual(blog.posts[0].title,'Title_post') self.assertEqual(blog.posts[0].content, 'Content' ) self.assertEqual(blog.title,'Test')
def test_ask_create_blog(self): with patch('builtins.input') as mocked_input: mocked_input.side_effect = ('Test', "Test Title", "Test Content") app.ask_create_post() self.assertEqual('Test Title', app.blogs['Test'].posts[0].title) self.assertTrue( 'Test Content' == app.blogs['Test'].posts[0].content)
def test_ask_create_post(self): blog = app.blogs['Test Blog'] with patch('builtins.input') as mocked_input: mocked_input.side_effect = ('Test Blog', 'Test Post 1', 'Test Content 1') app.ask_create_post() self.assertEqual(blog.posts[0].title, 'Test Post 1') self.assertEqual(blog.posts[0].content, 'Test Content 1')
def test_ask_create_post(self): #blog = Blog('Test', 'Test Author') #app.blogs = {'Test': blog} with patch('builtins.input') as mocked_input: mocked_input.side_effect = ('Test', 'Test Title', 'Test Content') app.ask_create_post() self.assertEqual(app.blogs['Test'].posts[0].title, 'Test Title') self.assertEqual(app.blogs['Test'].posts[0].content, "Test Content")
def test_ask_create_post(self): blog = app.blogs['Test'] app.print_posts(blog) with patch('builtins.input') as mocked_input: mocked_input.side_effect = ('Test', 'Post Title', 'Post Content') app.ask_create_post() self.assertEqual(blog.posts[0].title, 'Post Title') self.assertEqual(blog.posts[0].content, 'Post Content')
def test_ask_create_post(self): p = Post(POST_TITLE, POST_CONTENT) with patch('builtins.input') as mocked_input: mocked_input.side_effect = (BLOG_TITLE, POST_TITLE, POST_CONTENT) app.ask_create_post() # self.assertIsNotNone(app.Blogs.get('Blog Title').posts) post_in_blog = app.Blogs[BLOG_TITLE].posts[0] self.assertEqual(post_in_blog.title, POST_TITLE) self.assertEqual(post_in_blog.content, POST_CONTENT)
def test_ask_create_post(self): with patch("builtins.input") as mocked_input: mocked_input.side_effect = ("Test", "Test Title", "Test Content") app.ask_create_post() post = app.blogs["Test"].posts[0] self.assertIsNotNone(post) self.assertEqual("Test Title", post.title) self.assertEqual("Test Content", post.content)
def test_ask_create_post(self): blog = app.blogs['Test'] with patch('builtins.input') as mocked_input: mocked_input.side_effect = {'Test', 'Sample blog name', 'Sample blog content'} app.ask_create_post() self.assertEqual(blog.posts[0].title, 'Sample blog name') self.assertEqual(blog.posts[0].content, 'Sample blog content')
def test_ask_create_post(self, blog=None): # post = Post('Post title', 'Post content') # app.blogs ={"Test":blog} with patch("builtins.input") as mocked_input: mocked_input.side_effect = ('Test', 'Test Title', 'Test Content') app.ask_create_post() self.assertEqual(app.blogs['Test'].posts[0].title, 'Test Title') self.assertEqual(app.blogs['Test'].posts[0].content, 'Test Content')
def test_ask_create_post(self): # b = Blog('Blog Title', 'Blog aUthor') # app.blogs = {'Blog Title': b} with patch('builtins.input') as mocked_input: mocked_input.side_effect = ('Blog Title', 'Test Post Title', 'Test Post Content') app.ask_create_post() self.assertEqual(app.blogs['Blog Title'].posts[0].title, 'Test Post Title') self.assertEqual(app.blogs['Blog Title'].posts[0].content, 'Test Post Content')
def test_ask_create_post(self): blog = Blog("Love", "Kingsman") app.blogs = dict({"Love": blog}) with patch("builtins.input") as mocked_input: mocked_input.side_effect = ("Love", "Love Forever2", "Friendship") app.ask_create_post() #self.assertEqual(blog.posts[0].name, "Love Forever2") mocked_input.assert_called()
def test_app_create_post(self): with patch('builtins.input') as mocked_input: mocked_input.side_effect = ('Test', 'Test Title', 'Test Content') app.ask_create_post() blog_post = str(app.blogs['Test'].posts[0]) expected = '<title: Test Title, content: Test Content>' self.assertEqual(blog_post, expected)
def test_ask_create_post(self): blog = app.blogs['Test'] with patch('builtins.input') as mocked_input: mocked_input.side_effect = ('Test', 'Test Title', 'Test Content') app.ask_create_post() self.assertEqual(blog.posts[0].title, 'Test Title') self.assertEqual(blog.posts[0].content, 'Test Content') # mock : 의존성이 있는 것들을 실제로 실행시키지 말고 호출 여부, 인터페이스만 확인!
def test_ask_create_post(self): b = Blog('MyNote', 'Nat') b.create_post('Programming Tips', 'Be Lazy!!') b.create_post('Work Tips', 'Work Hard...') target_post = b.posts[0] with patch('builtins.input') as mocked_input: mocked_input.side_effect = ('MyNote', 'Programming Tips', 'Be Lazy!!') with patch('blog.Blog.create_post') as mocked_create_post: app.ask_create_post() mocked_create_post.assert_called_with(target_post.title, target_post.content)
def test_ask_create_post(self): blog_title = 'Test Blog' blog = Blog(blog_title, 'Test Author') post_title = 'Test Post' post_content = 'Test Content' blog.create_post(post_title, post_content) app.blogs = {blog_title: blog} with patch('builtins.input') as mocked_input: mocked_input.side_effect = (blog_title, post_title, post_content) app.ask_create_post() self.assertEqual(blog.posts[0].title, post_title) self.assertEqual(blog.posts[0].content, post_content)