# -*- coding: utf8 -*-
from __future__ import unicode_literals

from django.test import TestCase
from blog.models import Post, Category

import datetime


class PostTestCase(TestCase):

    def setUp(self):

        # Category
        category = Category.objects.create(name='category', created=datetime.date.today())

        # Draft post
        Post.objects.create(title='Draft post',
                            category=category,
                            status=Post.STATUS_DRAFT,
                            excerpt='draft post',
                            slug='draft-post',
                            permalink='http://darkelda.net/draft-post',
                            description='',
                            content='#Draft post',
                            created=datetime.date.today())

    def test_title(self):
        post = Post.objects.get(slug='draft-post')
        self.assertEqual(post.__unicode__(), post.title)

    def test_creation(self):
        category = Category.objects.get(name='category')

        post = Post.objects.create(title='Hello world',
                                   category=category,
                                   status=Post.STATUS_DRAFT,
                                   excerpt='Hello world, I\'m a software engineer',
                                   slug='hello-world',
                                   permalink='http://darkelda.net/hello-world',
                                   description='',
                                   content='#hello world',
                                   created=datetime.date.today())
        self.assertTrue(isinstance(post, Post))