#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.test import TestCase
from django.contrib.sites.models import Site
from django.contrib.auth import get_user_model
from django.core.files import File

from opps.articles.models import Post
from opps.channels.models import Channel
from opps.images.models import Image


class PostModelTest(TestCase):

    def setUp(self):
        User = get_user_model()
        self.user = User.objects.create(username=u'test', password='test')
        self.site = Site.objects.filter(name=u'example.com').get()
        self.channel = Channel.objects.create(name=u'Home', slug=u'home',
                                              description=u'home page',
                                              site=self.site, user=self.user)

        image = File(open("opps/__init__.py"), "test_file.png")
        self.image = Image.objects.create(site=self.site, title='test',
                                          image=image, user=self.user)

        self.post = Post.objects.create(
            title=u'Basic test',
            slug=u'basic-test',
            short_title=u'Write basict test for Article type Post',
            content=u'This field is context',
            main_image=self.image,
            channel=self.channel,
            user=self.user
        )

    def test_basic_post_exist(self):
        post = Post.objects.all()

        self.assertTrue(post)
        self.assertEqual(post[0], self.post)

@@ -76,481 +76,197 @@
 ase%0A
-from django.contrib.sites.models import Site%0Afrom django.contrib.auth import get_user_model%0Afrom django.core.files import File%0A%0Afrom opps.articles.models import Post%0Afrom opps.channels.models import Channel%0Afrom opps.images.models import Image%0A%0A%0Aclass PostModelTest(TestCase):%0A%0A    def setUp(self):%0A        User = get_user_model()%0A        self.user = User.objects.create(username=u'test', password='test')%0A        self.site = Site.objects.filter(name=u'example.com').get
+%0Afrom opps.articles.models import Post%0A%0A%0Aclass PostModelTest(TestCase):%0A%0A    fixtures = %5B'tests/initial_data.json'%5D%0A%0A    def test_basic_post_exist(self):%0A        post = Post.objects.all
 ()%0A
+%0A
     
@@ -278,898 +278,234 @@
 elf.
-channel = Channel.objects.create(name=u'Home', slug=u'home',%0A                                              description=u'home page',%0A                                              site=self.site, user=self.user)%0A%0A        image = File(open(%22opps/__init__.py%22), %22test_file.png%22)%0A        self.image = Image.objects.create(site=self.site, title='test',%0A                                          image=image, user=self.user)%0A%0A        self.post = Post.objects.create(%0A            title=u'Basic test',%0A            slug=u'basic-test',%0A            short_title=u'Write basict test for Article type Post',%0A            content=u'This field is context',%0A            main_image=self.image,%0A            channel=self.channel,%0A            user=self.user%0A        )%0A%0A    def test_basic_post_exist(self):%0A        post = Post.objects.all()%0A%0A        self.assertTrue(post)%0A        self.assertEqual(post%5B0%5D, self.post
+assertTrue(post)%0A        self.assertEqual(len(post), 1)%0A        self.assertEqual(post%5B0%5D.slug, u'test-post-application')%0A        self.assertEqual(post%5B0%5D.title, u'test post application')%0A        self.assertTrue(post%5B0%5D.short_url
 )%0A

Fix articles test, used test initial_data