Skip to content

Commit 749091e

Browse files
committed
Add test coverage for update_grant functionality
1 parent d8f42bd commit 749091e

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

backend/api/grants/tests/test_update_grant.py

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def test_cannot_update_a_grant_as_unlogged_user(graphql_client):
193193
assert resp["errors"][0]["message"] == "User not logged in"
194194

195195

196-
def test_cannot_update_submission_with_lang_outside_allowed_values(
196+
def test_cannot_update_grant_outside_allowed_values(
197197
graphql_client,
198198
user,
199199
):
@@ -211,15 +211,24 @@ def test_cannot_update_submission_with_lang_outside_allowed_values(
211211
graphql_client,
212212
grant=grant,
213213
name="Marcotte" * 50,
214+
fullName="Marcotte" * 50,
214215
departureCountry="Very long location" * 50,
215216
nationality="Freedonia" * 50,
216217
departureCity="Emerald City " * 50,
218+
why="Very long why" * 100,
219+
pythonUsage="Very long python usage" * 100,
220+
beenToOtherEvents="Very long been to other events" * 100,
221+
communityContribution="Very long community contribution" * 100,
222+
notes="Very long notes" * 100,
217223
)
218224

219225
assert response["data"]["updateGrant"]["__typename"] == "GrantErrors"
220226
assert response["data"]["updateGrant"]["errors"]["validationName"] == [
221227
"name: Cannot be more than 300 chars"
222228
]
229+
assert response["data"]["updateGrant"]["errors"]["validationFullName"] == [
230+
"full_name: Cannot be more than 300 chars"
231+
]
223232
assert response["data"]["updateGrant"]["errors"]["validationDepartureCountry"] == [
224233
"departure_country: Cannot be more than 100 chars"
225234
]
@@ -229,3 +238,53 @@ def test_cannot_update_submission_with_lang_outside_allowed_values(
229238
assert response["data"]["updateGrant"]["errors"]["validationDepartureCity"] == [
230239
"departure_city: Cannot be more than 100 chars"
231240
]
241+
assert response["data"]["updateGrant"]["errors"]["validationWhy"] == [
242+
"why: Cannot be more than 1000 chars"
243+
]
244+
assert response["data"]["updateGrant"]["errors"]["validationPythonUsage"] == [
245+
"python_usage: Cannot be more than 700 chars"
246+
]
247+
assert response["data"]["updateGrant"]["errors"]["validationBeenToOtherEvents"] == [
248+
"been_to_other_events: Cannot be more than 500 chars"
249+
]
250+
assert response["data"]["updateGrant"]["errors"][
251+
"validationCommunityContribution"
252+
] == ["community_contribution: Cannot be more than 900 chars"]
253+
assert response["data"]["updateGrant"]["errors"]["validationNotes"] == [
254+
"notes: Cannot be more than 350 chars"
255+
]
256+
257+
258+
def test_cannot_update_grant_with_empty_values_if_needs_funds_for_travel(
259+
graphql_client,
260+
user,
261+
):
262+
graphql_client.force_login(user)
263+
conference = ConferenceFactory(
264+
active_grants=True,
265+
)
266+
267+
grant = GrantFactory(
268+
user_id=user.id,
269+
conference=conference,
270+
)
271+
272+
response = _update_grant(
273+
graphql_client,
274+
grant=grant,
275+
needsFundsForTravel=True,
276+
departureCountry="",
277+
departureCity="",
278+
nationality="",
279+
)
280+
281+
assert response["data"]["updateGrant"]["__typename"] == "GrantErrors"
282+
assert response["data"]["updateGrant"]["errors"]["validationDepartureCountry"] == [
283+
"departure_country: Cannot be empty"
284+
]
285+
assert response["data"]["updateGrant"]["errors"]["validationDepartureCity"] == [
286+
"departure_city: Cannot be empty"
287+
]
288+
assert response["data"]["updateGrant"]["errors"]["validationNationality"] == [
289+
"nationality: Cannot be empty"
290+
]

0 commit comments

Comments
 (0)