Skip to content

Commit c9e93b1

Browse files
committed
tests
1 parent 41d5d87 commit c9e93b1

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

backend/api/submissions/mutations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ class SendSubmissionInput(BaseSubmissionInput):
210210
speaker_linkedin_url: str
211211
speaker_facebook_url: str
212212
speaker_mastodon_handle: str
213+
speaker_availabilities: JSON
213214

214215
topic: Optional[ID] = strawberry.field(default=None)
215216
tags: list[ID] = strawberry.field(default_factory=list)
@@ -372,6 +373,7 @@ def send_submission(
372373
"linkedin_url": input.speaker_linkedin_url,
373374
"facebook_url": input.speaker_facebook_url,
374375
"mastodon_handle": input.speaker_mastodon_handle,
376+
"speaker_availabilities": input.speaker_availabilities,
375377
},
376378
)
377379

backend/api/submissions/tests/test_edit_submission.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ def _update_submission(
3333
new_speaker_linkedin_url="",
3434
new_speaker_facebook_url="",
3535
new_speaker_mastodon_handle="",
36+
new_speaker_availabilities=None,
3637
):
3738
new_title = new_title or {"en": "new title to use"}
3839
new_elevator_pitch = new_elevator_pitch or {"en": "This is an elevator pitch"}
3940
new_abstract = new_abstract or {"en": "abstract here"}
4041
short_social_summary = new_short_social_summary or ""
4142
new_speaker_photo = new_speaker_photo or FileFactory().id
43+
new_speaker_availabilities = new_speaker_availabilities or {}
4244

4345
return graphql_client.query(
4446
"""
@@ -141,6 +143,7 @@ def _update_submission(
141143
"speakerLinkedinUrl": new_speaker_linkedin_url,
142144
"speakerFacebookUrl": new_speaker_facebook_url,
143145
"speakerMastodonHandle": new_speaker_mastodon_handle,
146+
"speakerAvailabilities": new_speaker_availabilities,
144147
}
145148
},
146149
)
@@ -201,6 +204,67 @@ def test_update_submission(graphql_client, user):
201204
assert participant.linkedin_url == "http://linkedin.com/company/pythonpizza"
202205

203206

207+
def test_update_submission_speaker_availabilities(graphql_client, user):
208+
conference = ConferenceFactory(
209+
topics=("life", "diy"),
210+
languages=("it", "en"),
211+
durations=("10", "20"),
212+
active_cfp=True,
213+
audience_levels=("adult", "senior"),
214+
submission_types=("talk", "workshop"),
215+
)
216+
217+
submission = SubmissionFactory(
218+
speaker_id=user.id,
219+
custom_topic="life",
220+
custom_duration="10m",
221+
custom_audience_level="adult",
222+
custom_submission_type="talk",
223+
languages=["it"],
224+
tags=["python", "ml"],
225+
conference=conference,
226+
speaker_level=Submission.SPEAKER_LEVELS.intermediate,
227+
previous_talk_video="https://www.youtube.com/watch?v=SlPhMPnQ58k",
228+
)
229+
230+
graphql_client.force_login(user)
231+
232+
new_topic = conference.topics.filter(name="diy").first()
233+
new_audience = conference.audience_levels.filter(name="senior").first()
234+
new_tag = SubmissionTagFactory(name="yello")
235+
new_duration = conference.durations.filter(name="20m").first()
236+
new_type = conference.submission_types.filter(name="workshop").first()
237+
238+
response = _update_submission(
239+
graphql_client,
240+
submission=submission,
241+
new_topic=new_topic,
242+
new_audience=new_audience,
243+
new_tag=new_tag,
244+
new_duration=new_duration,
245+
new_type=new_type,
246+
new_speaker_level=Submission.SPEAKER_LEVELS.experienced,
247+
new_speaker_availabilities={
248+
"2023-12-10@am": "unavailable",
249+
"2023-12-11@pm": "unavailable",
250+
"2023-12-12@am": "preferred",
251+
"2023-12-13@am": None,
252+
},
253+
)
254+
255+
submission.refresh_from_db()
256+
257+
assert response["data"]["updateSubmission"]["__typename"] == "Submission"
258+
259+
participant = Participant.objects.first()
260+
assert participant.speaker_availabilities == {
261+
"2023-12-10@am": "unavailable",
262+
"2023-12-11@pm": "unavailable",
263+
"2023-12-12@am": "preferred",
264+
"2023-12-13@am": None,
265+
}
266+
267+
204268
def test_update_submission_with_invalid_facebook_social_url(graphql_client, user):
205269
conference = ConferenceFactory(
206270
topics=("life", "diy"),

backend/api/submissions/tests/test_send_submission.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def _submit_proposal(client, conference, submission, **kwargs):
6767
"speakerFacebookUrl": "https://facebook.com/fake-link",
6868
"speakerMastodonHandle": "[email protected]",
6969
"tags": [tag.id],
70+
"speakerAvailabilities": {},
7071
}
7172

7273
override_conference = kwargs.pop("override_conference", None)
@@ -163,6 +164,11 @@ def test_submit_talk(graphql_client, user, django_capture_on_commit_callbacks, m
163164
shortSocialSummary="summary",
164165
speakerBio="my bio",
165166
speakerPhoto=speaker_photo,
167+
speakerAvailabilities={
168+
"2023-10-10@am": "preferred",
169+
"2023-10-11@pm": "unavailable",
170+
"2023-10-12@am": "available",
171+
},
166172
)
167173

168174
assert resp["data"]["sendSubmission"]["__typename"] == "Submission"
@@ -190,6 +196,11 @@ def test_submit_talk(graphql_client, user, django_capture_on_commit_callbacks, m
190196
participant = Participant.objects.get(conference=conference, user_id=user.id)
191197
assert participant.bio == "my bio"
192198
assert participant.photo_file_id == speaker_photo
199+
assert participant.speaker_availabilities == {
200+
"2023-10-10@am": "preferred",
201+
"2023-10-11@pm": "unavailable",
202+
"2023-10-12@am": "available",
203+
}
193204

194205
assert PrivacyPolicyAcceptanceRecord.objects.filter(
195206
user=user, conference=conference, privacy_policy="cfp"

0 commit comments

Comments
 (0)