1- from privacy_policy .models import PrivacyPolicyAcceptanceRecord
2- from conferences .tests .factories import ConferenceFactory
3- from grants .tests .factories import GrantFactory
41import pytest
5- from participants .models import Participant
2+
3+ from conferences .tests .factories import ConferenceFactory
64from grants .models import Grant
5+ from grants .tests .factories import GrantFactory
76from notifications .models import EmailTemplateIdentifier
87from notifications .tests .factories import EmailTemplateFactory
9-
8+ from participants .models import Participant
9+ from privacy_policy .models import PrivacyPolicyAcceptanceRecord
1010
1111pytestmark = pytest .mark .django_db
1212
@@ -91,7 +91,9 @@ def _send_grant(client, conference, conference_code=None, **kwargs):
9191 return response
9292
9393
94- def test_send_grant (graphql_client , user , mocker , django_capture_on_commit_callbacks , sent_emails ):
94+ def test_send_grant (
95+ graphql_client , user , mocker , django_capture_on_commit_callbacks , sent_emails
96+ ):
9597 graphql_client .force_login (user )
9698 conference = ConferenceFactory (active_grants = True )
9799 EmailTemplateFactory (
@@ -120,13 +122,16 @@ def test_send_grant(graphql_client, user, mocker, django_capture_on_commit_callb
120122 # Verify that the correct email template was used and email was sent
121123 emails_sent = sent_emails ()
122124 assert emails_sent .count () == 1
123-
125+
124126 sent_email = emails_sent .first ()
125- assert sent_email .email_template .identifier == EmailTemplateIdentifier .grant_application_confirmation
127+ assert (
128+ sent_email .email_template .identifier
129+ == EmailTemplateIdentifier .grant_application_confirmation
130+ )
126131 assert sent_email .email_template .conference == conference
127132 assert sent_email .recipient == user
128133 assert sent_email .recipient_email == user .email
129-
134+
130135 # Verify placeholders were processed correctly
131136 assert sent_email .placeholders ["user_name" ] == user .full_name
132137
@@ -238,6 +243,11 @@ def test_cannot_send_grant_outside_allowed_values(
238243 departureCountry = "Very long location" * 50 ,
239244 nationality = "Freedonia" * 50 ,
240245 departureCity = "Emerald City " * 50 ,
246+ why = "Very long why" * 100 ,
247+ pythonUsage = "Very long python usage" * 100 ,
248+ beenToOtherEvents = "Very long been to other events" * 100 ,
249+ communityContribution = "Very long community contribution" * 100 ,
250+ notes = "Very long notes" * 100 ,
241251 )
242252
243253 assert response ["data" ]["sendGrant" ]["__typename" ] == "GrantErrors"
@@ -253,6 +263,21 @@ def test_cannot_send_grant_outside_allowed_values(
253263 assert response ["data" ]["sendGrant" ]["errors" ]["validationDepartureCity" ] == [
254264 "departure_city: Cannot be more than 100 chars"
255265 ]
266+ assert response ["data" ]["sendGrant" ]["errors" ]["validationWhy" ] == [
267+ "why: Cannot be more than 1000 chars"
268+ ]
269+ assert response ["data" ]["sendGrant" ]["errors" ]["validationPythonUsage" ] == [
270+ "python_usage: Cannot be more than 700 chars"
271+ ]
272+ assert response ["data" ]["sendGrant" ]["errors" ]["validationBeenToOtherEvents" ] == [
273+ "been_to_other_events: Cannot be more than 500 chars"
274+ ]
275+ assert response ["data" ]["sendGrant" ]["errors" ][
276+ "validationCommunityContribution"
277+ ] == ["community_contribution: Cannot be more than 900 chars" ]
278+ assert response ["data" ]["sendGrant" ]["errors" ]["validationNotes" ] == [
279+ "notes: Cannot be more than 350 chars"
280+ ]
256281
257282
258283def test_cannot_send_grant_with_empty_values (
@@ -279,6 +304,36 @@ def test_cannot_send_grant_with_empty_values(
279304 ]
280305
281306
307+ def test_cannot_send_grant_with_empty_values_if_needs_funds_for_travel (
308+ graphql_client ,
309+ user ,
310+ ):
311+ graphql_client .force_login (user )
312+ conference = ConferenceFactory (
313+ active_grants = True ,
314+ )
315+
316+ response = _send_grant (
317+ graphql_client ,
318+ conference ,
319+ needsFundsForTravel = True ,
320+ departureCountry = "" ,
321+ departureCity = "" ,
322+ nationality = "" ,
323+ )
324+
325+ assert response ["data" ]["sendGrant" ]["__typename" ] == "GrantErrors"
326+ assert response ["data" ]["sendGrant" ]["errors" ]["validationDepartureCountry" ] == [
327+ "departure_country: Cannot be empty"
328+ ]
329+ assert response ["data" ]["sendGrant" ]["errors" ]["validationDepartureCity" ] == [
330+ "departure_city: Cannot be empty"
331+ ]
332+ assert response ["data" ]["sendGrant" ]["errors" ]["validationNationality" ] == [
333+ "nationality: Cannot be empty"
334+ ]
335+
336+
282337def test_submit_grant_with_existing_participant (graphql_client , user ):
283338 graphql_client .force_login (user )
284339 conference = ConferenceFactory (
0 commit comments