|
| 1 | +import pytest |
1 | 2 | from uuid import uuid4 |
2 | 3 | from users.tests.factories import UserFactory |
3 | 4 | from conferences.tests.factories import ConferenceFactory |
@@ -615,6 +616,101 @@ def test_update_submission_with_wrong_file_type(graphql_client, user): |
615 | 616 | ] == ["File not found"] |
616 | 617 |
|
617 | 618 |
|
| 619 | +def test_update_submission_with_too_long_url(graphql_client, user): |
| 620 | + conference = ConferenceFactory( |
| 621 | + topics=("life", "diy"), |
| 622 | + languages=("it", "en"), |
| 623 | + durations=("10", "20"), |
| 624 | + active_cfp=True, |
| 625 | + audience_levels=("adult", "senior"), |
| 626 | + submission_types=("talk", "workshop"), |
| 627 | + ) |
| 628 | + |
| 629 | + submission = SubmissionFactory( |
| 630 | + speaker_id=user.id, |
| 631 | + custom_topic="life", |
| 632 | + custom_duration="10m", |
| 633 | + custom_audience_level="adult", |
| 634 | + custom_submission_type="talk", |
| 635 | + languages=["it"], |
| 636 | + tags=["python", "ml"], |
| 637 | + conference=conference, |
| 638 | + speaker_level=Submission.SPEAKER_LEVELS.intermediate, |
| 639 | + previous_talk_video="https://www.youtube.com/watch?v=SlPhMPnQ58k", |
| 640 | + ) |
| 641 | + |
| 642 | + graphql_client.force_login(user) |
| 643 | + |
| 644 | + response = _update_submission( |
| 645 | + graphql_client, |
| 646 | + submission=submission, |
| 647 | + new_materials=[ |
| 648 | + { |
| 649 | + "fileId": None, |
| 650 | + "url": f"https://www.googl{'e' * 2049}.com", |
| 651 | + "name": "name", |
| 652 | + }, |
| 653 | + ], |
| 654 | + ) |
| 655 | + |
| 656 | + assert response["data"]["updateSubmission"]["__typename"] == "SendSubmissionErrors" |
| 657 | + assert response["data"]["updateSubmission"]["errors"]["validationMaterials"][0][ |
| 658 | + "url" |
| 659 | + ] == ["URL is too long"] |
| 660 | + |
| 661 | + |
| 662 | +@pytest.mark.parametrize( |
| 663 | + "url", |
| 664 | + [ |
| 665 | + "ftp://www.google.com", |
| 666 | + "//www.google.com", |
| 667 | + "google.com/test", |
| 668 | + "no/url", |
| 669 | + ], |
| 670 | +) |
| 671 | +def test_update_submission_with_invalid_urls(graphql_client, user, url): |
| 672 | + conference = ConferenceFactory( |
| 673 | + topics=("life", "diy"), |
| 674 | + languages=("it", "en"), |
| 675 | + durations=("10", "20"), |
| 676 | + active_cfp=True, |
| 677 | + audience_levels=("adult", "senior"), |
| 678 | + submission_types=("talk", "workshop"), |
| 679 | + ) |
| 680 | + |
| 681 | + submission = SubmissionFactory( |
| 682 | + speaker_id=user.id, |
| 683 | + custom_topic="life", |
| 684 | + custom_duration="10m", |
| 685 | + custom_audience_level="adult", |
| 686 | + custom_submission_type="talk", |
| 687 | + languages=["it"], |
| 688 | + tags=["python", "ml"], |
| 689 | + conference=conference, |
| 690 | + speaker_level=Submission.SPEAKER_LEVELS.intermediate, |
| 691 | + previous_talk_video="https://www.youtube.com/watch?v=SlPhMPnQ58k", |
| 692 | + ) |
| 693 | + |
| 694 | + graphql_client.force_login(user) |
| 695 | + |
| 696 | + response = _update_submission( |
| 697 | + graphql_client, |
| 698 | + submission=submission, |
| 699 | + new_materials=[ |
| 700 | + { |
| 701 | + "fileId": None, |
| 702 | + "url": url, |
| 703 | + "name": "name", |
| 704 | + }, |
| 705 | + ], |
| 706 | + ) |
| 707 | + |
| 708 | + assert response["data"]["updateSubmission"]["__typename"] == "SendSubmissionErrors" |
| 709 | + assert response["data"]["updateSubmission"]["errors"]["validationMaterials"][0][ |
| 710 | + "url" |
| 711 | + ] == ["Invalid URL"] |
| 712 | + |
| 713 | + |
618 | 714 | def test_update_submission_with_too_many_materials(graphql_client, user): |
619 | 715 | conference = ConferenceFactory( |
620 | 716 | topics=("life", "diy"), |
|
0 commit comments