Пример #1
0
 def test_print_blogs(self):
     b = Blog('Test Blog', 'Test Author')
     app.blogs = {'Test': b}
     with patch('builtins.print') as mocked_print:
         app.print_blogs()
         mocked_print.assert_called_with(
             '- Title: Test Blog by Author: Test Author (0 posts)')
Пример #2
0
 def test_print_blogs(self):
     blog = Blog("Blog Title", "Blog Author")
     app.blogs = {'Test': blog}
     with patch('builtins.print') as mocked_print:
         app.print_blogs()
         mocked_print.assert_called_with(
             '-Blog Title by Blog Author (0 posts)')
Пример #3
0
 def test_print_blogs(self):
     # b = Blog('Blog Title', 'Blog aUthor')
     # app.blogs = {'Test': b}
     with patch('builtins.print') as mocked_print:
         app.print_blogs()
         mocked_print.assert_called_with(
             '- Blog: Blog Title, Author: Blog aUthor, Posts: 0')
Пример #4
0
    def test_print_blogs(self):
        blog = Blog('Test', 'Test Author')
        app.blogs = {'Test': blog}

        with patch('builtins.print') as mocked_print:
            app.print_blogs()
            mocked_print.assert_called_with('- Test by Test Author (0 posts)')
Пример #5
0
    def test_print_blogs(self):
     #   blog = Blog("Test", "Test author")
      #  app.blogs = {"Test": blog}

        with patch("builtins.print") as mocked_print:
            app.print_blogs()
            mocked_print.assert_called_with("- Test by Test author (0 posts)")
 def test_print_blogs(self):
     blog = Blog("Test", "Sergiy Mushtyn")
     app.blogs = {'Test': blog}
     with patch('builtins.print') as mocked_print:
         app.print_blogs()
         mocked_print.assert_called_with(
             "- Test by Sergiy Mushtyn: 0 posts")
 def test_print_blogs(self):
     with patch('builtins.print') as mocked_print:
         # The 'print' function is replaced by a mocked print
         app.print_blogs()
         # To check if the 'print' function has been called with the right text
         # we check if the 'mocked_print' has been call with it
         mocked_print.assert_called_with(
             '- Blog Test by Test Author (0 post)')
Пример #8
0
 def test_print_blogs(self):
     blog = Blog("Test", "Test Author")
     app.blogs = {"Test": blog}
     # všechny funkce print v tomto bloku jsou mock
     with patch("builtins.print") as mocked_print:
         app.print_blogs()
         # pokud je výstupem argument test projde
         mocked_print.assert_called_with("- Test by Test Author (0 posts)")
Пример #9
0
    def test_print_blogs_many(self):
        blog1 = Blog("Title1", "Author1")
        blog2 = Blog("Title2", "Author2")
        app.blogs = {"Title1": blog1, "Title2": blog2}

        with patch("builtins.print") as mocked_print:
            app.print_blogs()
            assert mocked_print.call_args_list[0] == call("- Title1 by Author1 (0 posts)")
            assert mocked_print.call_args_list[1] == call("- Title2 by Author2 (0 posts)")
Пример #10
0
    def test_print_blogs(self):

        blog = Blog("Love", "Kingsman")
        app.blogs = dict({"title": blog})

        with patch("builtins.print") as mocked_print:
            app.print_blogs()
            mocked_print.assert_called_with("- Love by Kingsman (0 posts)")
            self.assertIsNotNone(app.blogs.items())
Пример #11
0
    def test_print_blogs(self):
        with patch('builtins.print') as mocked_print:
            # patching the print function as mocked print
            # the print function in app.py is being **REPLACED** by
            # my patched version then we're checking if it was called
            # PRINT is never really called, an imposter of Print, runs.
            # NO console check has been done.

            app.print_blogs()
            mocked_print.assert_called_with('- Test by Test Author (0 posts)')
Пример #12
0
    def test_print_blogs(self):
        """
        This is test for blog printing. In this example
        the "print_blog" function is not returning anything
        so the patch needs to be used on the print function
        """

        with patch("builtins.print") as mocked_print:
            app.print_blogs()
            mocked_print.assert_called_with(
                "- Title: Test, Author: Test Author (0 posts)")
Пример #13
0
    def test_print_multiple_blogs(self):
        blog = Blog('Test Blog', 'Test Author')
        blog_2 = Blog('Test Blog 2', 'Test Author 2')
        app.blogs = {'Test': blog, 'Test 2': blog_2}

        with patch('builtins.print') as mocked_print:
            app.print_blogs()
            assert mocked_print.call_args_list[0] == call(
                '- Test Blog by Test Author (0 posts)'
            )
            assert mocked_print.call_args_list[1] == call(
                '- Test Blog 2 by Test Author 2 (0 posts)'
            )
    def test_print_blogs(self):
        #blog = Blog("Test", "Test Author")
        # we setting up the dictionary equal to blog
        #app.blogs = {"Test": blog}

        # we have created a context manager,whatever the result  builtins.print=mocked_print
        """module.modify.function_to_be_patched"""
        with patch("builtins.print") as mocked_print:
            #blog = app.blogs["Test"]
            # what the result of print is now called mocked_print
            # patch recieves a modules
            app.print_blogs()
            # the above line calls print,from our app,with unit test it allows to seee if the module was called or not
            mocked_print.assert_called_with('-Test by Test Author (1 post)')
Пример #15
0
    def test_print_blogs(self):

        # Load class Blog
        blog = Blog('Test', 'Test Author')

        # Put the value in the app.py blogs dictionary
        app.blogs = {'Test': blog}

        # Here we go to compare what app.py prints with a string using the mock_print
        with patch('builtins.print') as mocked_print:
            # call function to print the dictionary content defined next by mocked_print
            app.print_blogs()

            # compares the previous print with the string
            mocked_print.assert_called_with('- Test by Test Author (0 posts)')
    def test_print_blogs(self):
        blog = Blog("Test", "Test Author")
        app.blogs = {
            "Test": blog
        }  # mapping of blog name to blog object (repr method),
        # so that the object contains this single blog

        # komplicirano je testirati sto se printa na konzolu (i print je builtin funkcija pa valjda radi),
        # a testirana metoda nema return
        # zato mockamo print i provjeravamo je li print metoda pozvana s ispravnom vrijednosti

        with patch('builtins.print'
                   ) as mocked_print:  # patch trazi i modul uz naziv funkcije
            app.print_blogs()
            mocked_print.assert_called_with(
                '- Test by Test Author (0 posts)')  # repr u blog.py
Пример #17
0
 def test_print_blogs_diffrent(self):
     blog = Blog("Test", "Test author")
     app.blogs = {"Test": blog}
     with patch("builtins.print") as mocked_print:
         app.print_blogs()
         mocked_print.assert_called_with('* Test by Test author (0 post )')
Пример #18
0
    def test_print_blogs_empty(self):
        app.blogs = {}

        with patch("builtins.print") as mocked_print:
            app.print_blogs()
            mocked_print.assert_called_with("No blogs")
Пример #19
0
    def test_print_blogs(self):
        with patch('builtins.print') as mocked_print:
            app.print_blogs()

            mocked_print.assert_called_with('- ' + BLOG_TITLE + ' by ' +
                                            AUTHOR + ' (0 posts)')
Пример #20
0
 def test_print_blogs(self):
     with patch('builtins.print') as mocked_print:
         app.print_blogs()
         mocked_print.assert_called_with('- Test by Test author (0 posts)')
Пример #21
0
 def test_print_blogs(self):
     with patch("builtins.print") as mocked_print:
         app.print_blogs()
         mocked_print.assert_called_with("- Test by Test Author (0 posts)")
Пример #22
0
 def test_print_blogs():
     b = app.blogs.get('Test')
     with patch('builtins.print') as mocked_print:
         app.print_blogs()
         mocked_print.assert_called_with('- {}'.format(b))
Пример #23
0
 def test_print_blogs(self):
     # patch takes a module.function as parameter
     with patch('builtins.print') as mocked_print:
         app.print_blogs()
         mocked_print.assert_called_with('- Test by Test Blog (0 posts)')
Пример #24
0
 def test_print_blogs(self):
     with patch('builtins.print') as mocked_print:  # Context manager
         app.print_blogs()
         mocked_print.assert_called_with('- Konza City by Allan (0 posts)')
Пример #25
0
	def test_print_blogs(self):
		with patch('builtins.print') as mocked_print:
			app.print_blogs()  # this is what method returns
			mocked_print.assert_called_with('- Test blog title by Test blog author (0 posts)')  # this is what should be
Пример #26
0
 def test_print_blogs(self):
     with patch("builtins.print") as mocked_print:
         app.print_blogs()
         mocked_print.assert_called_with(
             "-<Blog(title: Test, author: Test Author)>")
Пример #27
0
 def test_print_blogs(self):
     with patch('builtins.print') as mocked_print:
         app.print_blogs()
         mocked_print.assert_called_with(f"- {app.blogs['Test']}\n")
Пример #28
0
 def test_print_blogs(self):
     with patch("builtins.print") as mocked_print:
         app.print_blogs()
         mocked_print.assert_called_with("- Test by Test Author (0 posts)")
Пример #29
0
 def test_print_blogs(self):
     with patch(
             'builtins.print'
     ) as mocked_print:  #replace print function with a mock so we can do the test
         app.print_blogs()
         mocked_print.assert_called_with('- Test by Test Author (0 posts)')
Пример #30
0
 def test_print_blogs(self):
     ### CONTEXT with fake print call
     with patch('builtins.print') as mocked_print:
         app.print_blogs()
         mocked_print.assert_called_with('- Test by Test Author (0 posts)')
Пример #31
0
 def test_print_blogs(self):
     with patch(
             'builtins.print'
     ) as mocked_print:  # this mocked_print is going to replace the print in app.py
         app.print_blogs()
         mocked_print.assert_called_with('- Test by Test Author (0 post)')