def test_save_none_in_menu(self): form = ImportMenusForm(data={ 'klass': 'menuhin.tests.data.TestMenu1', 'site': 1, }, files=None) self.assertTrue(form.is_valid()) result = form.save() self.assertIsNone(result)
def test_save_some_in_menu(self): try: admin.site.unregister(User) except NotRegistered: pass admin.site.register(User, UserAdmin) try: admin.site.unregister(MenuItem) except NotRegistered: pass admin.site.register(MenuItem, MenuItemAdmin) form = ImportMenusForm(data={ 'klass': 'menuhin.tests.data.TestMenu2', 'site': 1, }, files=None) self.assertTrue(form.is_valid()) result = form.save() self.assertIsNotNone(result) self.assertEqual(len(result), 3)