From 091f7bfe7d58608baa8bef6000300b64250c89ad Mon Sep 17 00:00:00 2001 From: jessiebelle Date: Sat, 30 Dec 2023 15:02:24 +0200 Subject: [PATCH] modifying existing tests to assert new fields are correctly saved --- sponsors/forms.py | 2 ++ sponsors/tests/test_forms.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sponsors/forms.py b/sponsors/forms.py index 04cacd876..6033a0b18 100644 --- a/sponsors/forms.py +++ b/sponsors/forms.py @@ -378,6 +378,8 @@ def save(self): landing_page_url=self.cleaned_data.get("landing_page_url", ""), twitter_handle=self.cleaned_data["twitter_handle"], print_logo=self.cleaned_data.get("print_logo"), + country_of_incorporation=self.cleaned_data.get("country_of_incorporation", ""), + state_of_incorporation=self.cleaned_data.get("state_of_incorporation", ""), ) contacts = [f.save(commit=False) for f in self.contacts_formset.forms] for contact in contacts: diff --git a/sponsors/tests/test_forms.py b/sponsors/tests/test_forms.py index 058e21625..3d9342927 100644 --- a/sponsors/tests/test_forms.py +++ b/sponsors/tests/test_forms.py @@ -420,14 +420,18 @@ def test_create_sponsor_with_valid_data(self): def test_create_sponsor_with_valid_data_for_non_required_inputs( self, ): + user = baker.make(settings.AUTH_USER_MODEL) + self.data["description"] = "Important company" self.data["landing_page_url"] = "https://companyx.com" self.data["twitter_handle"] = "@companyx" + self.data["country_of_incorporation"] = "US" + self.data["state_of_incorporation"] = "NY" self.files["print_logo"] = get_static_image_file_as_upload( "psf-logo_print.png", "logo_print.png" ) - form = SponsorshipApplicationForm(self.data, self.files) + form = SponsorshipApplicationForm(self.data, self.files, user=user) self.assertTrue(form.is_valid(), form.errors) sponsor = form.save() @@ -437,6 +441,8 @@ def test_create_sponsor_with_valid_data_for_non_required_inputs( self.assertFalse(form.user_with_previous_sponsors) self.assertEqual(sponsor.landing_page_url, "https://companyx.com") self.assertEqual(sponsor.twitter_handle, "@companyx") + self.assertEqual(sponsor.country_of_incorporation, "US") + self.assertEqual(sponsor.state_of_incorporation, "NY") def test_use_previous_user_sponsor(self): contact = baker.make(SponsorContact, user__email="foo@foo.com")