Skip to content

Commit

Permalink
modifying existing tests to assert new fields are correctly saved
Browse files Browse the repository at this point in the history
  • Loading branch information
jessiebelle committed Dec 30, 2023
1 parent 7f73df0 commit 091f7bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sponsors/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion sponsors/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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")
Expand Down

0 comments on commit 091f7bf

Please sign in to comment.