示例#1
0
 def test_non_unique_form_save(self):
     dup = MenuItemForm({
         'label': 'test nav',
         'slug': 'primary-nav',
         'order': 0,
     })
     self.assertFalse(dup.is_valid(), 'Form says a duplicate slug is valid.')
示例#2
0
 def test_non_unique_form_save(self):
     dup = MenuItemForm({
         'label': 'test nav',
         'slug': 'primary-nav',
         'order': 0,
     })
     self.assertFalse(dup.is_valid(), 'Form says a duplicate slug is valid.')
示例#3
0
 def test_getabsoluteurl(self):
     team = Team.objects.create(slug='durham-bulls')
     ct = ContentType.objects.get(app_label='treenav', model='team')
     form = MenuItemForm({
         'label': 'Durham Bulls',
         'slug': 'durham-bulls',
         'order': 4,
         'content_type': ct.id,
         'object_id': team.pk,
     })
     if not form.is_valid():
         self.fail(form.errors)
     menu = form.save()
     self.assertEqual(menu.href, team.get_absolute_url())
示例#4
0
 def test_getabsoluteurl(self):
     team = Team.objects.create(slug='durham-bulls')
     ct = ContentType.objects.get(app_label='treenav', model='team')
     form = MenuItemForm({
         'label': 'Durham Bulls',
         'slug': 'durham-bulls',
         'order': 4,
         'content_type': ct.id,
         'object_id': team.pk,
     })
     if not form.is_valid():
         self.fail(form.errors)
     menu = form.save()
     self.assertEqual(menu.href, team.get_absolute_url())