from unittest import TestCase
from blog.blog import Blog

class BlogTest(TestCase):
    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)

    def test_repr(self):
        b = Blog("Test", "Test Author")
        b2 = Blog("My Day", "Rolf")

        self.assertEqual(b.__repr__(), "Test by Test Author (0 post)")
        self.assertEqual(b2.__repr__(), "My Day by Rolf (0 post)")

    def test_repr_multiple(self):
        b = Blog("Test", "Test Author")
        b.posts = ["Test"]

        b2 = Blog("My Day", "Rolf")
        b2.posts = ["Test", "Another"]

        self.assertEqual(b.__repr__(), "Test by Test Author (1 post)")
        self.assertEqual(b2.__repr__(), "My Day by Rolf (2 posts)")

