@@ -252,7 +252,7 @@ def test_update_submission_with_materials(graphql_client, user):
252252
253253 graphql_client .force_login (user )
254254
255- new_file = FileFactory ( )
255+ new_file = ProposalMaterialFileFactory ( uploaded_by = user )
256256 response = _update_submission (
257257 graphql_client ,
258258 submission = submission ,
@@ -307,14 +307,16 @@ def test_update_submission_with_existing_materials(graphql_client, user):
307307 speaker_level = Submission .SPEAKER_LEVELS .intermediate ,
308308 previous_talk_video = "https://www.youtube.com/watch?v=SlPhMPnQ58k" ,
309309 )
310- existing_material = ProposalMaterialFactory (proposal = submission , file = FileFactory ())
310+ existing_material = ProposalMaterialFactory (
311+ proposal = submission , file = ProposalMaterialFileFactory (uploaded_by = user )
312+ )
311313 to_delete_material = ProposalMaterialFactory (
312- proposal = submission , file = FileFactory ()
314+ proposal = submission , file = None , url = "https://www.google.com"
313315 )
314316
315317 graphql_client .force_login (user )
316318
317- new_file = FileFactory ( )
319+ new_file = ProposalMaterialFileFactory ( uploaded_by = user )
318320 response = _update_submission (
319321 graphql_client ,
320322 submission = submission ,
@@ -349,7 +351,7 @@ def test_update_submission_with_existing_materials(graphql_client, user):
349351 assert not ProposalMaterial .objects .filter (id = to_delete_material .id ).exists ()
350352
351353
352- def test_update_submission_with_invalid_materials (graphql_client , user ):
354+ def test_update_submission_with_invalid_url (graphql_client , user ):
353355 conference = ConferenceFactory (
354356 topics = ("life" , "diy" ),
355357 languages = ("it" , "en" ),
@@ -371,13 +373,6 @@ def test_update_submission_with_invalid_materials(graphql_client, user):
371373 speaker_level = Submission .SPEAKER_LEVELS .intermediate ,
372374 previous_talk_video = "https://www.youtube.com/watch?v=SlPhMPnQ58k" ,
373375 )
374- other_submission_material = ProposalMaterialFactory (
375- proposal = SubmissionFactory (conference = conference ),
376- file = ProposalMaterialFileFactory (uploaded_by = user ),
377- )
378- to_delete_material = ProposalMaterialFactory (
379- proposal = submission , file = ProposalMaterialFileFactory (uploaded_by = user )
380- )
381376
382377 graphql_client .force_login (user )
383378
@@ -390,28 +385,222 @@ def test_update_submission_with_invalid_materials(graphql_client, user):
390385 "url" : "invalid-url" ,
391386 "name" : "test.pdf" ,
392387 },
388+ ],
389+ )
390+
391+ assert response ["data" ]["updateSubmission" ]["__typename" ] == "SendSubmissionErrors"
392+ assert response ["data" ]["updateSubmission" ]["errors" ]["validationMaterials" ][0 ][
393+ "url"
394+ ] == ["Invalid URL" ]
395+
396+
397+ def test_update_submission_with_other_submission_material (graphql_client , user ):
398+ conference = ConferenceFactory (
399+ topics = ("life" , "diy" ),
400+ languages = ("it" , "en" ),
401+ durations = ("10" , "20" ),
402+ active_cfp = True ,
403+ audience_levels = ("adult" , "senior" ),
404+ submission_types = ("talk" , "workshop" ),
405+ )
406+
407+ submission = SubmissionFactory (
408+ speaker_id = user .id ,
409+ custom_topic = "life" ,
410+ custom_duration = "10m" ,
411+ custom_audience_level = "adult" ,
412+ custom_submission_type = "talk" ,
413+ languages = ["it" ],
414+ tags = ["python" , "ml" ],
415+ conference = conference ,
416+ speaker_level = Submission .SPEAKER_LEVELS .intermediate ,
417+ previous_talk_video = "https://www.youtube.com/watch?v=SlPhMPnQ58k" ,
418+ )
419+ other_submission_material = ProposalMaterialFactory (
420+ proposal = SubmissionFactory (conference = conference ),
421+ file = ProposalMaterialFileFactory (uploaded_by = user ),
422+ )
423+
424+ graphql_client .force_login (user )
425+
426+ response = _update_submission (
427+ graphql_client ,
428+ submission = submission ,
429+ new_materials = [
393430 {
394431 "id" : other_submission_material .id ,
395432 "fileId" : None ,
396433 "url" : "https://www.google.com" ,
397434 "name" : "https://www.google.com" ,
398435 },
436+ ],
437+ )
438+
439+ assert response ["data" ]["updateSubmission" ]["__typename" ] == "SendSubmissionErrors"
440+ assert response ["data" ]["updateSubmission" ]["errors" ]["validationMaterials" ][0 ][
441+ "id"
442+ ] == ["Material not found" ]
443+
444+
445+ def test_update_submission_with_invalid_material_id (graphql_client , user ):
446+ conference = ConferenceFactory (
447+ topics = ("life" , "diy" ),
448+ languages = ("it" , "en" ),
449+ durations = ("10" , "20" ),
450+ active_cfp = True ,
451+ audience_levels = ("adult" , "senior" ),
452+ submission_types = ("talk" , "workshop" ),
453+ )
454+
455+ submission = SubmissionFactory (
456+ speaker_id = user .id ,
457+ custom_topic = "life" ,
458+ custom_duration = "10m" ,
459+ custom_audience_level = "adult" ,
460+ custom_submission_type = "talk" ,
461+ languages = ["it" ],
462+ tags = ["python" , "ml" ],
463+ conference = conference ,
464+ speaker_level = Submission .SPEAKER_LEVELS .intermediate ,
465+ previous_talk_video = "https://www.youtube.com/watch?v=SlPhMPnQ58k" ,
466+ )
467+
468+ graphql_client .force_login (user )
469+
470+ response = _update_submission (
471+ graphql_client ,
472+ submission = submission ,
473+ new_materials = [
399474 {
400475 "id" : "invalid-id" ,
401476 "fileId" : None ,
402477 "url" : "https://www.google.com" ,
403478 "name" : "https://www.google.com" ,
404479 },
480+ ],
481+ )
482+
483+ assert response ["data" ]["updateSubmission" ]["__typename" ] == "SendSubmissionErrors"
484+ assert response ["data" ]["updateSubmission" ]["errors" ]["validationMaterials" ][0 ][
485+ "id"
486+ ] == ["Invalid material id" ]
487+
488+
489+ def test_update_submission_with_nonexistent_file_id (graphql_client , user ):
490+ conference = ConferenceFactory (
491+ topics = ("life" , "diy" ),
492+ languages = ("it" , "en" ),
493+ durations = ("10" , "20" ),
494+ active_cfp = True ,
495+ audience_levels = ("adult" , "senior" ),
496+ submission_types = ("talk" , "workshop" ),
497+ )
498+
499+ submission = SubmissionFactory (
500+ speaker_id = user .id ,
501+ custom_topic = "life" ,
502+ custom_duration = "10m" ,
503+ custom_audience_level = "adult" ,
504+ custom_submission_type = "talk" ,
505+ languages = ["it" ],
506+ tags = ["python" , "ml" ],
507+ conference = conference ,
508+ speaker_level = Submission .SPEAKER_LEVELS .intermediate ,
509+ previous_talk_video = "https://www.youtube.com/watch?v=SlPhMPnQ58k" ,
510+ )
511+
512+ graphql_client .force_login (user )
513+
514+ response = _update_submission (
515+ graphql_client ,
516+ submission = submission ,
517+ new_materials = [
405518 {
406519 "fileId" : uuid4 (),
407520 "url" : "" ,
408521 "name" : "name" ,
409522 },
523+ ],
524+ )
525+
526+ assert response ["data" ]["updateSubmission" ]["__typename" ] == "SendSubmissionErrors"
527+ assert response ["data" ]["updateSubmission" ]["errors" ]["validationMaterials" ][0 ][
528+ "fileId"
529+ ] == ["File not found" ]
530+
531+
532+ def test_update_submission_with_file_from_different_user (graphql_client , user ):
533+ conference = ConferenceFactory (
534+ topics = ("life" , "diy" ),
535+ languages = ("it" , "en" ),
536+ durations = ("10" , "20" ),
537+ active_cfp = True ,
538+ audience_levels = ("adult" , "senior" ),
539+ submission_types = ("talk" , "workshop" ),
540+ )
541+
542+ submission = SubmissionFactory (
543+ speaker_id = user .id ,
544+ custom_topic = "life" ,
545+ custom_duration = "10m" ,
546+ custom_audience_level = "adult" ,
547+ custom_submission_type = "talk" ,
548+ languages = ["it" ],
549+ tags = ["python" , "ml" ],
550+ conference = conference ,
551+ speaker_level = Submission .SPEAKER_LEVELS .intermediate ,
552+ previous_talk_video = "https://www.youtube.com/watch?v=SlPhMPnQ58k" ,
553+ )
554+
555+ graphql_client .force_login (user )
556+
557+ response = _update_submission (
558+ graphql_client ,
559+ submission = submission ,
560+ new_materials = [
410561 {
411562 "fileId" : ProposalMaterialFileFactory (uploaded_by = UserFactory ()).id ,
412563 "url" : "" ,
413564 "name" : "name" ,
414565 },
566+ ],
567+ )
568+
569+ assert response ["data" ]["updateSubmission" ]["__typename" ] == "SendSubmissionErrors"
570+ assert response ["data" ]["updateSubmission" ]["errors" ]["validationMaterials" ][0 ][
571+ "fileId"
572+ ] == ["File not found" ]
573+
574+
575+ def test_update_submission_with_wrong_file_type (graphql_client , user ):
576+ conference = ConferenceFactory (
577+ topics = ("life" , "diy" ),
578+ languages = ("it" , "en" ),
579+ durations = ("10" , "20" ),
580+ active_cfp = True ,
581+ audience_levels = ("adult" , "senior" ),
582+ submission_types = ("talk" , "workshop" ),
583+ )
584+
585+ submission = SubmissionFactory (
586+ speaker_id = user .id ,
587+ custom_topic = "life" ,
588+ custom_duration = "10m" ,
589+ custom_audience_level = "adult" ,
590+ custom_submission_type = "talk" ,
591+ languages = ["it" ],
592+ tags = ["python" , "ml" ],
593+ conference = conference ,
594+ speaker_level = Submission .SPEAKER_LEVELS .intermediate ,
595+ previous_talk_video = "https://www.youtube.com/watch?v=SlPhMPnQ58k" ,
596+ )
597+
598+ graphql_client .force_login (user )
599+
600+ response = _update_submission (
601+ graphql_client ,
602+ submission = submission ,
603+ new_materials = [
415604 {
416605 "fileId" : ParticipantAvatarFileFactory (uploaded_by = user ).id ,
417606 "url" : "" ,
@@ -422,25 +611,52 @@ def test_update_submission_with_invalid_materials(graphql_client, user):
422611
423612 assert response ["data" ]["updateSubmission" ]["__typename" ] == "SendSubmissionErrors"
424613 assert response ["data" ]["updateSubmission" ]["errors" ]["validationMaterials" ][0 ][
425- "url"
426- ] == ["Invalid URL" ]
427- assert response ["data" ]["updateSubmission" ]["errors" ]["validationMaterials" ][1 ][
428- "id"
429- ] == ["Material not found" ]
430- assert response ["data" ]["updateSubmission" ]["errors" ]["validationMaterials" ][2 ][
431- "id"
432- ] == ["Invalid material id" ]
433- assert response ["data" ]["updateSubmission" ]["errors" ]["validationMaterials" ][3 ][
434- "fileId"
435- ] == ["File not found" ]
436- assert response ["data" ]["updateSubmission" ]["errors" ]["validationMaterials" ][4 ][
437- "fileId"
438- ] == ["File not found" ]
439- assert response ["data" ]["updateSubmission" ]["errors" ]["validationMaterials" ][5 ][
440614 "fileId"
441615 ] == ["File not found" ]
442616
443- assert ProposalMaterial .objects .filter (id = to_delete_material .id ).exists ()
617+
618+ def test_update_submission_with_too_many_materials (graphql_client , user ):
619+ conference = ConferenceFactory (
620+ topics = ("life" , "diy" ),
621+ languages = ("it" , "en" ),
622+ durations = ("10" , "20" ),
623+ active_cfp = True ,
624+ audience_levels = ("adult" , "senior" ),
625+ submission_types = ("talk" , "workshop" ),
626+ )
627+
628+ submission = SubmissionFactory (
629+ speaker_id = user .id ,
630+ custom_topic = "life" ,
631+ custom_duration = "10m" ,
632+ custom_audience_level = "adult" ,
633+ custom_submission_type = "talk" ,
634+ languages = ["it" ],
635+ tags = ["python" , "ml" ],
636+ conference = conference ,
637+ speaker_level = Submission .SPEAKER_LEVELS .intermediate ,
638+ previous_talk_video = "https://www.youtube.com/watch?v=SlPhMPnQ58k" ,
639+ )
640+
641+ graphql_client .force_login (user )
642+
643+ response = _update_submission (
644+ graphql_client ,
645+ submission = submission ,
646+ new_materials = [
647+ {
648+ "fileId" : None ,
649+ "url" : "https://www.google.com" ,
650+ "name" : "test.pdf" ,
651+ },
652+ ]
653+ * 4 ,
654+ )
655+
656+ assert response ["data" ]["updateSubmission" ]["__typename" ] == "SendSubmissionErrors"
657+ assert response ["data" ]["updateSubmission" ]["errors" ]["nonFieldErrors" ] == [
658+ "You can only add up to 3 materials"
659+ ]
444660
445661
446662def test_update_submission_speaker_availabilities (graphql_client , user ):
0 commit comments