11import pytest
22from files_upload .models import File
3- from submissions .tests .factories import SubmissionFactory
3+ from submissions .tests .factories import AcceptedSubmissionFactory , SubmissionFactory
44from conferences .tests .factories import ConferenceFactory
55from django .test import override_settings
66
@@ -64,7 +64,7 @@ def test_upload_participant_avatar_to_invalid_conf_fails(graphql_client, user):
6464
6565
6666def test_upload_proposal_material_file (graphql_client , user ):
67- proposal = SubmissionFactory (speaker = user )
67+ proposal = AcceptedSubmissionFactory (speaker = user )
6868 graphql_client .force_login (user )
6969
7070 response = _upload_file (
@@ -88,7 +88,26 @@ def test_upload_proposal_material_file(graphql_client, user):
8888
8989
9090def test_cannot_upload_proposal_material_file_if_not_speaker (graphql_client , user ):
91- proposal = SubmissionFactory ()
91+ proposal = AcceptedSubmissionFactory ()
92+ graphql_client .force_login (user )
93+
94+ response = _upload_file (
95+ graphql_client ,
96+ {
97+ "proposalMaterial" : {
98+ "filename" : "test.txt" ,
99+ "proposalId" : proposal .hashid ,
100+ "conferenceCode" : proposal .conference .code ,
101+ }
102+ },
103+ )
104+
105+ assert not response ["data" ]
106+ assert response ["errors" ][0 ]["message" ] == "You cannot upload files of this type"
107+
108+
109+ def test_cannot_upload_proposal_material_file_if_not_accepted (graphql_client , user ):
110+ proposal = SubmissionFactory (status = "proposed" )
92111 graphql_client .force_login (user )
93112
94113 response = _upload_file (
@@ -129,7 +148,7 @@ def test_cannot_upload_proposal_material_file_with_invalid_proposal_id(
129148def test_cannot_upload_proposal_material_file_with_invalid_proposal_id_for_conference (
130149 graphql_client , user
131150):
132- proposal = SubmissionFactory ()
151+ proposal = AcceptedSubmissionFactory ()
133152 graphql_client .force_login (user )
134153
135154 response = _upload_file (
@@ -151,7 +170,7 @@ def test_cannot_upload_proposal_material_file_with_invalid_proposal_id_for_confe
151170 "file_type" , [File .Type .PARTICIPANT_AVATAR , File .Type .PROPOSAL_MATERIAL ]
152171)
153172def test_superusers_can_upload_anything (graphql_client , admin_superuser , file_type ):
154- proposal = SubmissionFactory ()
173+ proposal = AcceptedSubmissionFactory ()
155174 graphql_client .force_login (admin_superuser )
156175
157176 req_input = {}
0 commit comments