def test_prefill_data_from_db(self): # setup # act form = PreferencesUpdateForm(instance=self.profile) # test self.assertEqual(form.initial["subscribed_newsletter"], False) self.assertEqual(form.initial["subscribed_gmm_invite"], False) self.assertEqual(form.initial["newsletter_recipient"], "TUE")
def test_success_newsletter_unchanged(self): # setup recipient = "*****@*****.**" # act form = PreferencesUpdateForm(instance=self.profile, data=get_preferences_form_data()) form.full_clean() form.save() # runs update_newsletter_preferences # test self.assertEqual(form.instance.subscribed_newsletter, False) self.assertEqual(form.instance.subscribed_gmm_invite, False) profile = Profile.objects.get(pk=self.profile.pk) self.assertEqual(profile.subscribed_newsletter, False) self.assertEqual(profile.subscribed_gmm_invite, False) self.assert_newsletter_subscription(recipient, False) self.assert_gmm_invite_subscription(recipient, False)