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.')
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())