def test_reassign_extra_data(self): """Testing UserApplicationChangeForm cannot re-assign extra_data""" user = User.objects.get(username='******') application = self.create_oauth_application(user) form = UserApplicationChangeForm( user, data=dict( model_to_dict( instance=application, fields=UserApplicationChangeForm.base_fields, exclude=('client_id', 'client_secret'), ), extra_data=1, ), instance=application, ) self.assertTrue(form.is_valid()) application = form.save() self.assertEqual(application.extra_data, {})
def test_reassign_local_site(self): """Testing UserApplicationChangeForm cannot re-assign Local Site""" user = User.objects.get(username='******') local_site = LocalSite.objects.get(pk=1) application = self.create_oauth_application(user, local_site) form = UserApplicationChangeForm( user, data=dict( model_to_dict( instance=application, fields=UserApplicationChangeForm.base_fields, exclude=('client_id', 'client_secret'), ), local_site=2, ), instance=application, ) self.assertTrue(form.is_valid()) application = form.save() self.assertEqual(application.local_site, local_site)