def test_print_posts(self):
     blog = Blog('Blog Title', "Blog Author")
     blog.create_post('Test Post', "Test Content")
     app.blogs = {'Blog Title': blog}
     with patch('app.print_post') as mocked_print_post:
         app.print_posts(blog)
         mocked_print_post.assert_called_with(blog.posts[0])
    def test_create_test_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")
        self.assertEqual(b.posts[0].content, "Test Content")
    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")
        self.assertEqual(b.posts[0].content, "Test Content")
Beispiel #4
0
    def test_create_post_in_blog(self):
        b = Blog('Test', 'Test Author')
        b.create_post('Test Post', 'Test Content')

        self.assertEqual(1, len(b.posts))
        self.assertEqual('Test Post', b.posts[0].title)
        self.assertEqual('Test Content', b.posts[0].content)
Beispiel #5
0
    def test_create_post_in_blog(self):
        b = Blog("Testbloggen", "Alexandra Wåhlander")
        b.create_post("Test post", "Test Content")

        self.assertEqual(len(b.posts), 1)
        self.assertEqual(b.posts[0].title, "Test post")
        self.assertEqual(b.posts[0].content, "Test Content")
Beispiel #6
0
    def test_create_post_in_blog(self):
        new_blog = Blog("Test Title", "Test Author")
        new_blog.create_post("Test Post", "Test Content")

        self.assertEqual(len(new_blog.posts), 1)
        self.assertEqual(new_blog.posts[0].title, "Test Post")
        self.assertEqual(new_blog.posts[0].content, "Test Content")
Beispiel #7
0
    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')
        self.assertEqual(b.posts[0].content, 'Test content')
Beispiel #8
0
 def test_print_posts(self):
     blog = Blog("Test", "Test author")
     blog.create_post("Title_post", "Content")
     app.blogs = {"Test": blog}
     with patch('app.print_post') as mocked_print_post:
         app.print_posts(blog)
         mocked_print_post.assert_called_with(blog.posts[0])
 def test_print_posts(self):
     b = Blog('Test', 'Test Author')
     b.create_post('Test Post', 'Test Post Content')
     app.blogs = {'Test': b}
     with patch('app.print_one_post') as mocked_print_post:
         app.print_posts(b)
         mocked_print_post.assert_called_with(b.posts[0])
 def test_print_posts(self):
     blog = Blog('Test', 'Test Author')
     blog.create_post('Test', 'Test Content')
     app.blogs = {'Test': blog}
     with patch('app.print_post') as mocked_print_post:
         app.print_posts(app.blogs['Test'])
         mocked_print_post.assert_called_with(blog.posts[0])
Beispiel #11
0
    def test_create_post(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')
        self.assertEqual(b.posts[0].content, 'Test Content')
Beispiel #12
0
    def test_create_post_in_blog(self):
        b = Blog('Test Title', 'Author')
        b.create_post("Kenya", "Amazing Kenya")

        self.assertEqual(len(b.posts), 1)
        self.assertEqual(b.posts[0].title, 'Kenya')
        self.assertEqual(b.posts[0].content, "Amazing Kenya")
Beispiel #13
0
    def test_blog_inter(self):
        b = Blog('Title', 'Name')
        b.create_post('Test post', 'Test content')

        self.assertEqual(len(b.posts), 1)
        self.assertEqual(b.posts[0].title, 'Test post')
        self.assertEqual(b.posts[0].content, 'Test content')
Beispiel #14
0
 def test_create_post(self):
     b = Blog("Test Title", "Neto")
     b.create_post("Testing New Post", "I am testing if a new post is created")
     self.assertEqual(1, len(b.posts), "The length of the list is 0, so no posts have been created")
     self.assertEqual("Testing New Post", b.posts[0].title, "The title of the post has not been created")
     self.assertEqual("I am testing if a new post is created", b.posts[0].content, "The content of the post has not"
                                                                                   "been created")
Beispiel #15
0
    def test_create_post(self):
        b = Blog('My blog', 'VV')
        b.create_post('Post 1', '1')

        self.assertEqual(1, len(b.posts))
        self.assertEqual('Post 1', b.posts[0].title)
        self.assertEqual('1', b.posts[0].content)
Beispiel #16
0
    def test_create_post_in_blog(self):
        b = Blog('The best book', 'John Doe')
        b.create_post('Test Post', 'Test content')

        self.assertEqual(len(b.posts), 1)
        self.assertEqual(b.posts[0].title, 'Test Post')
        self.assertEqual(b.posts[0].content, 'Test content')
Beispiel #17
0
    def test_create_post_in_blog(self):
        b = Blog("Název", "autor")
        b.create_post("Titulek", "Obsah")

        # v poli posts jsou uloženy objekty
        self.assertEqual(b.posts[0].title, "Titulek")
        self.assertEqual(b.posts[0].content, "Obsah")
Beispiel #18
0
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())
Beispiel #19
0
    def test_create_posts(self):
        b = Blog('Test Title', 'Test Author')
        b.create_post('Test Post Title', 'Test Post Content')
        expected = 'Title: Test Title by Author: Test Author (1 post)'

        self.assertEqual(expected, b.__repr__())
        self.assertEqual(b.posts[0].title, 'Test Post Title')
        self.assertEqual(b.posts[0].content, 'Test Post Content')
Beispiel #20
0
 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())
     
Beispiel #21
0
 def test_print_posts(self):
     title = 'Test Blog'
     blog = Blog(title, 'Test Author')
     blog.create_post('Test Post', 'Test Content')
     app.blogs = {title: blog}
     with patch('app.print_post') as mocked_print_post:
         app.print_posts(blog)
         mocked_print_post.assert_called_with(blog.posts[0])
Beispiel #22
0
    def test_print_posts(self):
        blog = Blog("automation", "Clark")
        blog.create_post("selenium", "one of automation tools")
        app.blogs = dict({"automation": blog})

        with patch("application.print_post") as mocked_print_post:
            app.print_posts(blog)
            mocked_print_post.assert_called_with(blog.posts[0])
    def test_print_posts(self):
        blog = Blog("Test", "Sergiy Mushtyn")
        blog.create_post('Test Post', 'Test Content')
        app.blogs = {'Test': blog}

        with patch('app.print_post') as mocked_print_post:
            app.print_posts(blog)
            mocked_print_post.assert_called_with(blog.posts[0])
Beispiel #24
0
 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")
Beispiel #25
0
    def test_create_post(
            self
    ):  # this test is not unittest - because test more than one stuff
        b = Blog('Test title', 'Test author')
        b.create_post('My first week in new job', 'some content')

        self.assertEqual(len(b.posts), 1)
        self.assertEqual(b.posts[0].title, 'My first week in new job')
        self.assertEqual(b.posts[0].content, 'some content')
    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, "number of posts is not 1")
        self.assertEqual(b.posts[0].title, "Test post",
                         "title of the first post is not as expected")
        self.assertEqual(b.posts[0].content, "Test content",
                         "content of the first post is not as expected")
    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'}],
        })
Beispiel #28
0
    def test_create_post(self):
        blog = Blog('Title', 'Author')
        blog.create_post('PostTitle', 'PostContent')
        expected = [{'Title': 'PostTitle',
                     'Content': 'PostContent',
                     }]

        self.assertEqual(len(blog.posts), 1)
        self.assertEqual(blog.posts[0].title, 'PostTitle')
        self.assertEqual(blog.posts[0].content, 'PostContent')
    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_post(self):
        b = Blog('Test', 'Test Author')
        b.create_post('Test Post', 'Post Content')
        b.create_post('Test Post2', 'Post Content2')

        self.assertEqual(len(b.posts), 2)
        self.assertEqual(b.posts[0].title, 'Test Post')
        self.assertEqual(b.posts[0].content, 'Post Content')
        self.assertEqual(b.posts[1].title, 'Test Post2')
        self.assertEqual(b.posts[1].content, 'Post Content2')
Beispiel #31
0
    def test_post(self):
        b = Blog('Test', 'Test Author')
        b.create_post('Test Post Title', 'Test Post Content')

        b2 = Blog('Generic', 'Generic Author')

        self.assertEqual(b.__repr__(),
                         '<title: Test, author: Test Author, posts: 1>')
        self.assertEqual(b2.__repr__(),
                         '<title: Generic, author: Generic Author, posts: 0>')
Beispiel #32
0
    def test_create_post1(self):
        """
        Unit test for create post method
        """
        b_1 = Blog('Test title', 'Test author')
        b_1.create_post('Test Post', 'Test Content')

        self.assertEqual(len(b_1.posts), 1)
        self.assertEqual(b_1.posts[0].title, 'Test Post')
        self.assertEqual(b_1.posts[0].content, 'Test 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_create_post_in_blog(self):
        b = Blog('Test', 'Test author')
        b.create_post('Test Post', 'Test Content')

        self.assertEqual(b.posts[0].title, 'Test Post')
        self.assertEqual(b.posts[0].content, 'Test Content')