def test_changelist_url(self): widget = widgets.ItemList(request=None) widget.changelist_url = 'test' # Original admin_changelist_url = '/admin/auth/user/' # String test self.assertEqual(changelist_url(widget), 'test') # Model test widget.changelist_url = User self.assertEqual(changelist_url(widget), admin_changelist_url + '') # Tuple with params test widget.changelist_url = (User, {'username__exact': 'user0'}) self.assertEqual(changelist_url(widget), admin_changelist_url + '?username__exact=user0') # Same with string no question sign widget.changelist_url = (User, 'username__exact=user0') self.assertEqual(changelist_url(widget), admin_changelist_url + '?username__exact=user0') # Same with question sign widget.changelist_url = (User, '?username__exact=user0') self.assertEqual(changelist_url(widget), admin_changelist_url + '?username__exact=user0') # Asserts first item is a Model widget.changelist_url = (None, {'username__exact': 'user0'}) with self.assertRaises(AssertionError): self.assertEqual(changelist_url(widget), admin_changelist_url) # Asserts last items is either basestring or dict widget.changelist_url = (User, None) with self.assertRaises(AssertionError): self.assertEqual(changelist_url(widget), admin_changelist_url)
def setUp(self): self.widget = widgets.ItemList(request=None)
def setUp(self): self.widget0 = widgets.ItemList(request=None) self.widget1 = widgets.ItemList(request=None) self.widget1.width = widgets.LARGE self.widget1.height = 300