예제 #1
0
	def test_browser_items_empty_context(self):
		rf = RequestFactory()
		request = rf.get('/')
		request.user = self.user

		response = BrowserItemsView.as_view()(request)
		self.assertEqual(True, response.context_data['empty_items'])
예제 #2
0
	def test_browser_items_view_status(self):
		rf = RequestFactory()
		request = rf.get('/')
		request.user = self.user

		response = BrowserItemsView.as_view()(request)
		self.assertEqual(200, response.status_code)
예제 #3
0
	def test_browser_items_paginated(self):
		rf = RequestFactory()
		request = rf.get('/?ctype=contentbrowser.demomodel')
		request.user = self.user
		response = BrowserItemsView.as_view()(request)

		self.assertEqual('Page',
			response.context_data['page'].__class__.__name__)
예제 #4
0
	def test_browser_items_context(self):
		rf = RequestFactory()
		request = rf.get('/?ctype=contentbrowser.demomodel')
		request.user = self.user
		response = BrowserItemsView.as_view()(request)

		self.assertIn('page', response.context_data)
		self.assertIn('ctype', response.context_data)
예제 #5
0
	def test_only_permitted_groups_have_access(self):
		settings.CONTENT_BROWSER_RESTRICTED_TO = ('group1', 'group2')

		rf = RequestFactory()
		request = rf.get('/')
		request.user = self.user

		response = BrowserItemsView.as_view()(request)
		self.assertEqual(403, response.status_code)
예제 #6
0
	def test_permitted_groups_have_access(self):
		settings.CONTENT_BROWSER_RESTRICTED_TO = ('group1', 'group2')
		group = Group.objects.create(name='group1')
		self.user.groups.add(group)

		rf = RequestFactory()
		request = rf.get('/')
		request.user = self.user

		response = BrowserItemsView.as_view()(request)
		self.assertEqual(200, response.status_code)
예제 #7
0
	def test_browser_items_with_ctypes(self):
		rf = RequestFactory()
		request = rf.get('/?ctype=contentbrowser.demomodel')
		request.user = self.user
		response = BrowserItemsView.as_view()(request)

		expected_items = [1, 2, 3]
		items = response.context_data['page'].object_list\
			.values_list('id', flat=True)

		self.assertEqual('contentbrowser.demomodel',
			response.context_data['ctype'])

		self.assertEqual(expected_items, list(items))
예제 #8
0
from django.conf.urls.defaults import *

from views import BrowserItemsView


urlpatterns = patterns('',
	url(r'^browse/items/$', BrowserItemsView.as_view(),
		name="contentbrowser_browse_items"),
)