def test_invalid_cleaned_data_instance(self): form = ImportMenusForm(data={ 'klass': 'menuhin.tests.data.TestMenu999999', 'site': 1, }, files=None) self.assertFalse(form.is_valid()) # now fake some stuff, just to cover the branch. form.cleaned_data = { 'klass': 'menuhin.tests.data.TestMenu999999' } with self.assertRaises(ValueError): form._menu_class_instance_from_cleaned_data()
def test_menu_class_instance_from_cleaned_data(self): form = ImportMenusForm(data={ 'klass': 'menuhin.tests.data.TestMenu2', 'site': 1, }, files=None) self.assertTrue(form.is_valid()) klass = form._menu_class_instance_from_cleaned_data() self.assertIsInstance(klass, TestMenu2)