Beispiel #1
0
 def test_ask_read_blog(self):
     blog = Blog("Test", "Test author")
     app.blogs = {"Test": blog}
     with patch("builtins.input", return_value = "Test"):
         with patch("app.print_posts") as mocked_print_posts:
             app.ask_read_blog()
             mocked_print_posts.assert_called_with(blog)
 def test_read_blog(self):
     blog = Blog("Test", "Sergiy Mushtyn")
     app.blogs = {'Test': blog}
     with patch('builtins.input', return_value='Test'):
         with patch('app.print_posts') as mocked_print_posts:
             app.ask_read_blog()
             mocked_print_posts.assert_called_with(blog)
 def test_ask_read_blog(self):
     blog = Blog("Blog Title", "Blog Author")
     app.blogs = {'Blog Title': blog}
     with patch('builtins.input', return_value='Blog Title'):
         with patch('app.print_posts') as mocked_print_posts:
             app.ask_read_blog()
             mocked_print_posts.assert_called_with(blog)
Beispiel #4
0
    def test_ask_read_blog(self):
        test_blog = app.blogs["Test"]
        with patch("builtins.input", return_value="Test"):
            with patch("app.print_posts") as mocked_print_posts:
                app.ask_read_blog()

                mocked_print_posts.assert_called_with(test_blog)
    def test_ask_read_blog(self):

        with patch('builtins.input', return_value='Test'):
            with patch('app.print_posts') as mocked_print_posts:
                app.ask_read_blog()

                mocked_print_posts.assert_called_with(app.blogs['Test'])
    def test_ask_read_blog(self):
        blog = app.Blogs[BLOG_TITLE]
        with patch('builtins.input', return_value=BLOG_TITLE):
            with patch('app.print_posts') as mocked_print_posts:
                app.ask_read_blog()

                mocked_print_posts.assert_called_with(blog)
Beispiel #7
0
 def test_ask_read_blog(self):
     blog = Blog('Test', 'Test Author')
     app.blogs = {'Test': blog}
     with patch('builtins.input', return_value='Test'):
         with patch('app.print_posts') as mock_print_posts:
             app.ask_read_blog()
             mock_print_posts.assert_called_with(blog)
 def test_ask_read_blog(self):
     # b = Blog('Blog Title', 'Blog aUthor')
     # app.blogs = {'Blog Title': b}
     with patch('builtins.input',
                return_value='Blog Title') as mocked_input:
         with patch('app.print_posts') as mocked_print_posts:
             app.ask_read_blog()
             mocked_print_posts.assert_called_with(app.blogs['Blog Title'])
    def test_ask_read_blog(self):
        app.blogs['Test'].create_post('Test Title', 'Test Content')

        with patch('builtins.input') as mocked_input:
            mocked_input.side_effect = ('Test', )
            with patch('app.print_posts') as mocked_print_posts:
                app.ask_read_blog()
                mocked_print_posts.assert_called_with(app.blogs['Test'])
Beispiel #10
0
 def test_ask_read_blog(self):
     title = 'Test Blog'
     blog = Blog(title, 'Test Author')
     app.blogs = {title: blog}
     with patch('builtins.input', return_value=title):
         with patch('app.print_posts') as mocked_print_posts:
             app.ask_read_blog()
             mocked_print_posts.assert_called_with(blog)
    def test_ask_read_blog(self):
        #blog =  Blog("Test",'Test Author')
        #app.blogs = {"Test":blog}

        with patch('builtins.input', return_value='Test'):
            with patch('app.print_posts') as mocked_print_posts:
                app.ask_read_blog()
                mocked_print_posts.assert_called_with(app.blogs['Test'])
Beispiel #12
0
    def test_ask_read_blog(self):
        blog = Blog('Test', 'Test Author')
        app.blogs = {'Test': blog}

        with patch('builtins.input', return_value='Test'):
            with patch('builtins.print') as mocked_print:
                app.ask_read_blog()

                mocked_print.assert_called_with("Reading the Test's posts:\n")
    def test_ask_read_post(self):
        blog = Blog("Test", "Test Author")
        app.blogs = {"Test": blog}

        with patch('builtins.input', return_value='Test'):
            # 2 checks possible: 1) if print_posts was called; 2) if print was called
            with patch('app.print_posts') as mocked_print_posts:
                app.ask_read_blog()
                mocked_print_posts.asssert_called_with(blog)
    def test_ask_read_blog(self):
        blog = Blog('Test', 'Test Author')
        app.blogs = {'Test': blog}
        with patch('builtins.input', return_value='Test') as mocked_input:
            with patch('app.print_posts') as mocked_print:

                app.ask_read_blog()
                mocked_input.assert_called_with(
                    "Enter the title of the blog you wish to read: ")
                mocked_print.assert_called_with(blog)
Beispiel #15
0
 def test_ask_read_blog(self):
     blog = app.blogs['Test Blog']
     with patch('builtins.input', return_value='Test Blog'):
         blog.posts.append({
             'title': 'Test Post 1',
             'content': 'Test Content 1'
         })
         with patch('app.print_posts') as mocked_print_posts:
             app.ask_read_blog()
             mocked_print_posts.assert_called_with(blog)
    def test_ask_read_blog(self):
        # Now we have to create a blog post with Title and Author
        #blog = Blog('Test', 'Author')
        # Here we have to create a dictionary which key is 'Test-Blog' and value is the blog object
        app.blogs = {'Test': self.blog}
        with patch('builtins.input', return_value='Test'):
            with patch('app.print_posts') as mocked_print_posts:
                app.ask_read_blog()

                mocked_print_posts.assert_called_with(self.blog)
Beispiel #17
0
    def test_ask_read_blog(self):

        with patch('builtins.input', return_value='Test'):
            with patch('app.print_posts') as mocked_print_posts:
                # We're mocking the print_posts function from app.py
                # we're then naming that mocked_print_posts as a variabe?

                app.ask_read_blog()
                # What happens when this function runs?

                mocked_print_posts.assert_called_with(app.blogs['Test'])
    def test_ask_read_blog(self):
        """
        When the input() is called in app.py, it is going to return the value 'Test'
        def ask_read_blog():
            title = input('Enter the blog title you want to read: ')  --> title = 'Test'
            print_posts(blogs[title])                                 --> print_posts(blogs['Test'])

        """
        with patch('builtins.input', return_value='Test'):
            with patch('app.print_posts') as mocked_print_posts:
                app.ask_read_blog()

                mocked_print_posts.assert_called_with(app.blogs['Test'])
Beispiel #19
0
    def test_ask_read_blog(self):
        # blog with no posts
        with patch('builtins.input', return_value='Test'):
            with patch('builtins.print') as mokced_print:
                app.ask_read_blog()
                mokced_print.assert_not_called()

        # blog with posts
        app.blogs['Test'].create_post('Test post', 'Test Content')
        with patch('builtins.input', return_value='Test'):
            with patch('builtins.print') as mokced_print:
                app.ask_read_blog()
                mokced_print. \
                    assert_called_once_with(app.POST_TEMPLATE.format(
                    app.blogs['Test'].posts[0].title, app.blogs['Test'].posts[0].content))
    def test_ask_read_blog(self):
        with patch("builtins.input", return_value="Test"):
            with patch("app.print_posts") as mocked_print_posts:
                app.ask_read_blog()

                mocked_print_posts.assert_called_with(app.blogs["Test"])
Beispiel #21
0
 def test_ask_read_blog():
     with patch('builtins.input', return_value='Test'):
         with patch('builtins.print') as mocked_print:
             app.ask_read_blog()
             mocked_print.assert_called_with('{}\n{}'.format(
                 'Test Post', 'Test Content'))