Example #1
0
    def test_get_model(self):
        view = FeaturedListView()
        user_content_type = ContentType.objects.get(app_label='auth', model='user').model_class()

        model_class = view.get_model('auth.user')

        self.assertEqual(user_content_type, model_class)
Example #2
0
    def test_get_category_template_names(self):
        view = FeaturedListView()
        view.get_context_data(self.category.slug, 'auth.user')
        expected = 'featured/%(slug)s_featured_list.html' % {'slug': self.category.slug}

        result = view.get_category_template_name()

        self.assertEqual(expected, result)
Example #3
0
    def test_get_model(self):
        view = FeaturedListView()
        user_content_type = ContentType.objects.get(
            app_label='auth', model='user').model_class()

        model_class = view.get_model('auth.user')

        self.assertEqual(user_content_type, model_class)
Example #4
0
    def test_get_category_template_names(self):
        view = FeaturedListView()
        view.get_context_data(self.category.slug, 'auth.user')
        expected = 'featured/%(slug)s_featured_list.html' % {
            'slug': self.category.slug
        }

        result = view.get_category_template_name()

        self.assertEqual(expected, result)
Example #5
0
    def test_get_context_data(self):
        view = FeaturedListView()
        queryset = get_featured_queryset_for(User, category=self.category)

        context = view.get_context_data(self.category.slug, 'auth.user')

        self.assertEqual(2, len(context))
        self.assertTrue('object_list' in context)
        self.assertEqual(list(queryset), list(context['object_list']))
        self.assertTrue('user_list' in context)
        self.assertEqual(list(queryset), list(context['user_list']))
Example #6
0
    def test_get_context_data(self):
        view = FeaturedListView()
        queryset = get_featured_queryset_for(User, category=self.category)

        context = view.get_context_data(self.category.slug, 'auth.user')

        self.assertEqual(2, len(context))
        self.assertTrue('object_list' in context)
        self.assertEqual(list(queryset), list(context['object_list']))
        self.assertTrue('user_list' in context)
        self.assertEqual(list(queryset), list(context['user_list']))
Example #7
0
    def test_get_context_data_when_inexistent_category_slug(self):
        view = FeaturedListView()

        self.assertRaises(Http404,
                          view.get_context_data,
                          slug='inexistent-cateogry-slug',
                          model='auth.user')
Example #8
0
    def test_get_context_data_when_inexistent_model(self):
        view = FeaturedListView()

        self.assertRaises(Http404,
                          view.get_context_data,
                          slug=self.category.slug,
                          model='auth.inexistentmodel')
Example #9
0
    def test_get_context_data_when_inactive_category(self):
        self.category.active = False
        self.category.save()
        view = FeaturedListView()

        self.assertRaises(Http404,
                          view.get_context_data,
                          slug=self.category.slug,
                          model='auth.user')
Example #10
0
from django.conf.urls.defaults import patterns, url

from featured.views import FeaturedListView


urlpatterns = patterns('',
    url(r'^(?P<slug>[-\w]+)/(?P<model>(\w+\.\w+))/$', FeaturedListView.as_view(), name='featured_category_list'),
)
Example #11
0
    def test_get_object_name(self):
        view = FeaturedListView()

        object_name = view.get_object_name('auth.user')

        self.assertEqual('user_list', object_name)
Example #12
0
    def test_get_category(self):
        view = FeaturedListView()

        category_result = view.get_category(self.category.slug)

        self.assertEqual(self.category, category_result)
Example #13
0
    def test_get_object_name(self):
        view = FeaturedListView()

        object_name = view.get_object_name('auth.user')

        self.assertEqual('user_list', object_name)
Example #14
0
    def test_get_category(self):
        view = FeaturedListView()

        category_result = view.get_category(self.category.slug)

        self.assertEqual(self.category, category_result)
Example #15
0
from django.conf.urls import url

from featured.views import FeaturedListView

urlpatterns = [
    url(r'^(?P<slug>[-\w]+)/(?P<model>(\w+\.\w+))/$',
        FeaturedListView.as_view(),
        name='featured_category_list'),
]