Skip to content

Commit

Permalink
adding test to assert that svg can be uploaded
Browse files Browse the repository at this point in the history
  • Loading branch information
jessiebelle committed Dec 24, 2023
1 parent 8857a78 commit 8b1c844
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions sponsors/tests/test_forms.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from pathlib import Path

from django.core.files.uploadedfile import SimpleUploadedFile
from model_bakery import baker

from django.conf import settings
Expand Down Expand Up @@ -438,6 +441,21 @@ def test_create_sponsor_with_valid_data_for_non_required_inputs(
self.assertEqual(sponsor.landing_page_url, "https://companyx.com")
self.assertEqual(sponsor.twitter_handle, "@companyx")

def test_create_sponsor_with_svg_for_print_logo(
self,
):
tick_svg = Path(settings.STATICFILES_DIRS[0]) / "img"/"sponsors"/"tick.svg"
with tick_svg.open("rb") as fd:
uploaded_svg = SimpleUploadedFile("tick.svg", fd.read())
self.files["print_logo"] = uploaded_svg

form = SponsorshipApplicationForm(self.data, self.files)
self.assertTrue(form.is_valid(), form.errors)

sponsor = form.save()

self.assertTrue(sponsor.print_logo)

def test_use_previous_user_sponsor(self):
contact = baker.make(SponsorContact, user__email="foo@foo.com")
self.data = {"sponsor": contact.sponsor.id}
Expand Down

0 comments on commit 8b1c844

Please sign in to comment.