from django.test import TestCase
from django.shortcuts import resolve_url as r
from django.contrib.auth import get_user_model
from myideas.core.models import Ideas


class IdeasModelTest(TestCase):
    def setUp(self):
        user = get_user_model().objects.create(username='adminapp')
        self.idea = Ideas.objects.create(
                user=user,
                title='django app',
                description='test django web app',
                slug='django-app',
                tags='django'
        )

    def test_create(self):
        self.assertTrue(Ideas.objects.exists())

    def test_get_absolute_url(self):
        url = r('idea_details', slug=self.idea.slug)
        self.assertEqual(url, self.idea.get_absolute_url())

    def test_tags_can_be_blank(self):
        field = Ideas._meta.get_field('tags')
        self.assertTrue(field.blank)

    def test_str(self):
        self.assertEqual('django app', str(self.idea))
from django.test import TestCase
from django.shortcuts import resolve_url as r
from django.contrib.auth import get_user_model
from myideas.core.models import Ideas


class IdeasModelTest(TestCase):
    def setUp(self):
        user = get_user_model().objects.create(username='adminapp')
        self.idea = Ideas.objects.create(
                user=user,
                title='django app',
                description='test django web app',
                slug='django-app',
                tags='django'
        )

    def test_create(self):
        """Check models data create"""
        self.assertTrue(Ideas.objects.exists())

    def test_get_absolute_url(self):
        url = r('idea_details', slug=self.idea.slug)
        self.assertEqual(url, self.idea.get_absolute_url())

    def test_tags_can_be_blank(self):
        field = Ideas._meta.get_field('tags')
        self.assertTrue(field.blank)

    def test_str(self):
        self.assertEqual('django app', str(self.idea))
update tests