-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic form and model tests stephenmcd/drum#28
- Loading branch information
1 parent
e246155
commit 44ce3eb
Showing
6 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from unittest import TestCase | ||
|
||
from drum.links.forms import LinkForm | ||
|
||
|
||
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from unittest import TestCase | ||
|
||
from django.contrib.auth.models import User | ||
from drum.links.models import Link, Profile | ||
|
||
|
||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mezzanine >= 4.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from __future__ import unicode_literals | ||
from mezzanine.bin.runtests import main | ||
|
||
main('drum') |