from unittest import TestCase
from drum.links.forms import LinkForm
from django.contrib.auth.models import User
from drum.links.models import Link, Profile


class LinkFormsTests(TestCase):

    def test_valid_data(self):
        form = LinkForm({
            "title": "Test title",
            "link": "http://test.com/",
            "description": "Test Desc",
        })
        self.assertTrue(form.is_valid())

    def test_title_may_not_be_empty(self):
        form = LinkForm({
            "title": "",
            "link": "http://test.com/",
            "description": "Test Desc",
        })
        self.assertFalse(form.is_valid())

    def test_link_may_be_empty(self):
        form = LinkForm({
            "title": "Test title",
            "link": "",
            "description": "Test Desc",
        })
        self.assertTrue(form.is_valid())

    def test_description_may_be_empty(self):
        form = LinkForm({
            "title": "Test title",
            "link": "http://test.com/",
            "description": "",
        })
        self.assertTrue(form.is_valid())


class LinkModelsTests(TestCase):

    def test_has_link_field(self):
        l = Link()
        self.assertTrue(hasattr(l, 'link'))

    def test_has_rating_field(self):
        l = Link()
        self.assertTrue(hasattr(l, 'rating'))

    def test_has_comments_field(self):
        l = Link()
        self.assertTrue(hasattr(l, 'comments'))


class ProfileModelsTests(TestCase):

    def setUp(self):
        self.user = User.objects.create(username='user', password="notsosecure")
        self.user.profile.website = "http://test.com/"
        self.user.profile.bio = "I have a dream"
        self.user.profile.karma = 777
        self.user.profile.save()

    def test_has_website_field(self):
        p = Profile.objects.get(user__username="user")
        self.assertEqual("http://test.com/", p.website)

    def test_has_bio_field(self):
        p = Profile.objects.get(user__username="user")
        self.assertEqual("I have a dream", p.bio)

    def test_has_bio_field(self):
        p = Profile.objects.get(user__username="user")
        self.assertEqual(777, p.karma)

    def tearDown(self):
        self.user.delete()

@@ -2,16 +2,29 @@
 rom 
-unit
+mezzanine.utils.
 test
+s
  imp
@@ -1491,32 +1491,80 @@
 ef setUp(self):%0A
+        super(ProfileModelsTests, self).setUp()%0A
         self.use
@@ -1584,14 +1584,11 @@
 cts.
-create
+get
 (use
@@ -1598,37 +1598,13 @@
 me='
-user', password=%22notsosecure%22
+test'
 )%0A  
@@ -1780,101 +1780,112 @@
 e()%0A
-%0A
     
-def test_has_website_field(self):%0A        p = Profile.objects.get(user__username=%22user%22)
+    self.profile = Profile.objects.get(user__username=%22test%22)%0A%0A    def test_has_website_field(self):
 %0A   
@@ -1926,17 +1926,28 @@
 .com/%22, 
-p
+self.profile
 .website
@@ -2023,36 +2023,36 @@
 user__username=%22
-user
+test
 %22)%0A        self.
@@ -2081,17 +2081,28 @@
 dream%22, 
-p
+self.profile
 .bio)%0A%0A 
@@ -2182,20 +2182,20 @@
 ername=%22
-user
+test
 %22)%0A     
@@ -2223,65 +2223,24 @@
 77, 
-p.karma)%0A%0A    def tearDown(self):%0A        self.user.delete(
+self.profile.karma
 )%0A

Change use mezzanine.utils.tests.TestCase instead of unitest.TestCase #discussion_r86263806 PR #48