Beispiel #1
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 #2
0
    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)
        self.assertEqual(0, len(b.posts))
Beispiel #3
0
 def setUp(self):
     blog = Blog('Test', 'Test Author')
     app.blogs = {'Test': blog}
Beispiel #4
0
    def test_repr_multiple_posts(self):
        b = Blog('Test', 'Test Author')
        b.posts = ['test']

        self.assertEqual(b.__repr__(), 'Test by Test Author (1 post)')
Beispiel #5
0
    def test_repr(self):
        b = Blog('Test', 'Test Author')

        self.assertEqual(b.__repr__(),
                         '{} by {} (0 posts)'.format(b.title, b.author))
Beispiel #6
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')
Beispiel #7
0
def ask_create_blog():
    title = input('Enter your blog title: ')
    author = input('Enter your name: ')

    blogs[title] = Blog(title, author)