Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tried to fix views and wrote tests, which aren't working
- Loading branch information
Tobias Lorenz
committed
Feb 19, 2013
1 parent
1a5d8e2
commit 58b7d2a
Showing
9 changed files
with
144 additions
and
12 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
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
2 changes: 1 addition & 1 deletion
2
cmsplugin_blog_categories/templatetags/cmsplugin_blog_categories_tags.py
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
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,50 @@ | ||
""" | ||
Utilities for creating test objects related to the | ||
``cmsplugin_blog_categories`` app. | ||
""" | ||
from cmsplugin_blog.models import Entry, EntryTitle | ||
import factory | ||
|
||
from cmsplugin_blog_categories import models | ||
|
||
|
||
class CategoryFactory(factory.Factory): | ||
"""Factory for the ``Category`` model.""" | ||
FACTORY_FOR = models.Category | ||
|
||
slug = factory.LazyAttribute(lambda a: 'category-{0}'.format(a)) | ||
|
||
|
||
class CategoryTitleFactoryBase(factory.Factory): | ||
"""Base factory for factories for ``CategoryTitle`` models.""" | ||
FACTORY_FOR = models.CategoryTitle | ||
|
||
category = factory.SubFactory(CategoryFactory) | ||
|
||
|
||
class CategoryTitleENFactory(CategoryTitleFactoryBase): | ||
"""Factory for english ``CategoryTitle`` objects.""" | ||
title = factory.LazyAttribute(lambda a: 'title-{0}'.format(a)) | ||
|
||
|
||
class EntryFactory(factory.Factory): | ||
"""Base factory for factories for ``Entry`` models.""" | ||
FACTORY_FOR = Entry | ||
|
||
is_published = True | ||
|
||
|
||
class EntryTitleFactory(factory.Factory): | ||
"""Base factory for factories for ``EntryTitle`` models.""" | ||
FACTORY_FOR = EntryTitle | ||
|
||
entry = factory.SubFactory(EntryFactory) | ||
|
||
|
||
class EntryCategoryFactory(factory.Factory): | ||
"""Base factory for factories for ``EntryCategory`` models.""" | ||
FACTORY_FOR = models.EntryCategory | ||
|
||
category = factory.SubFactory(CategoryTitleENFactory) | ||
entry = factory.SubFactory(EntryFactory) |
22 changes: 22 additions & 0 deletions
22
cmsplugin_blog_categories/tests/integration_tests/views_tests.py
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,22 @@ | ||
"""Tests for the views of the ``cmsplugin_blog_categories`` app.""" | ||
from django.test import TestCase | ||
|
||
from django_libs.tests.mixins import ViewTestMixin | ||
|
||
from cmsplugin_blog_categories.tests.factories import CategoryTitleENFactory | ||
|
||
|
||
class CategoryListViewTestCase(ViewTestMixin, TestCase): | ||
"""Tests for the ``CategoryListView`` generic view class.""" | ||
def setUp(self): | ||
self.category_title = CategoryTitleENFactory() | ||
self.category = self.category_title.category | ||
|
||
def get_view_name(self): | ||
return 'blog_archive_category' | ||
|
||
def get_view_kwargs(self): | ||
return {'category': self.category.slug} | ||
|
||
def test_view(self): | ||
pass |
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,47 @@ | ||
"""Tests for models of the ``cmsplugin_blog_categories``` application.""" | ||
from django.test import TestCase | ||
|
||
from cmsplugin_blog_categories.tests.factories import ( | ||
CategoryFactory, | ||
CategoryTitleENFactory, | ||
EntryCategoryFactory, | ||
EntryFactory, | ||
) | ||
|
||
|
||
class CategoryTestCase(TestCase): | ||
"""Tests for the ``Category`` model class.""" | ||
longMessage = True | ||
|
||
def setUp(self): | ||
self.obj = CategoryFactory() | ||
|
||
def test_model(self): | ||
self.assertTrue(self.obj.pk) | ||
|
||
def test_translation(self): | ||
self.assertFalse(self.obj.get_translation()) | ||
CategoryTitleENFactory(enquiry=self.obj) | ||
self.assertEqual(self.obj.get_translation().title, 'A question?') | ||
|
||
|
||
class EntryTestCase(TestCase): | ||
"""Tests for the ``Entry`` model class.""" | ||
longMessage = True | ||
|
||
def setUp(self): | ||
self.obj = EntryFactory() | ||
|
||
def test_model(self): | ||
self.assertTrue(self.obj.pk) | ||
|
||
|
||
class EntryCategoryTestCase(TestCase): | ||
"""Tests for the ``EntryCategory`` model class.""" | ||
longMessage = True | ||
|
||
def setUp(self): | ||
self.obj = EntryCategoryFactory() | ||
|
||
def test_model(self): | ||
self.assertTrue(self.obj.pk) |
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
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
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