Skip to content

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paltman committed Jul 19, 2014
1 parent 2c969bc commit 257c095
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
36 changes: 33 additions & 3 deletions agora/tests/tests.py
@@ -1,7 +1,37 @@
from django.test import TestCase

from agora.models import Forum, ForumCategory

class Tests(TestCase):

def setUp(self):
pass
class ForumCategoryTests(TestCase):

def test_unicode_method(self):
cat = ForumCategory(title="Software")
self.assertEquals(str(cat), cat.title)

def test_get_absolute_url(self):
cat = ForumCategory.objects.create(title="Software")
self.assertEquals(cat.get_absolute_url(), "/category/1/")

def test_forums_ordered_properly(self):
cat = ForumCategory.objects.create(title="Software")
Forum.objects.create(category=cat, title="Python", description="Python software")
Forum.objects.create(category=cat, title="Swift", description="Swift software")
Forum.objects.create(category=cat, title="Basic", description="Old software")
forums = cat.forums
self.assertEquals(forums[0].title, "Basic")
self.assertEquals(forums[1].title, "Python")
self.assertEquals(forums[2].title, "Swift")


class ForumTests(TestCase):

def test_forum_thread_count_is_zero(self):
f = Forum.objects.create(title="Python", description="Python software")
self.assertEquals(f.thread_count, 0)

def test_inc_views(self):
f = Forum.objects.create(title="Python", description="Python software")
self.assertEquals(f.view_count, 0)
f.inc_views()
self.assertEquals(f.view_count, 1)
2 changes: 1 addition & 1 deletion agora/tests/urls.py
@@ -1,4 +1,4 @@
from django.conf.urls.defaults import patterns, include
from django.conf.urls import patterns, include


urlpatterns = patterns(
Expand Down

0 comments on commit 257c095

Please sign in to comment.