@@ -116,6 +116,69 @@ def test_create_sowing(self):
116116 }
117117 self .assertEqual (response .json (), expected )
118118
119+ def test_create_sowing_guest_with_name_email (self ):
120+ # ensure we are logged out for a guest submission
121+ self .client .logout ()
122+
123+ with open ('public/default_user_avatar.jpg' , 'rb' ) as image1 :
124+ response = self .graphql ({
125+ 'query' : """
126+ mutation M($input_0: SowingCreateInput!) {
127+ sowingCreate(input: $input_0) {
128+ clientMutationId,
129+ sowing {
130+ node {
131+ id
132+ where
133+ notes
134+ author { username }
135+ authorName
136+ authorEmail
137+ images { edges { node { id } } }
138+ }
139+ }
140+ errors { code location message }
141+ }
142+ }
143+ """ ,
144+ 'variables' : {
145+ 'input_0' : {
146+ 'clientMutationId' : '1' ,
147+ 'where' : 'bairro central' ,
148+ 'notes' : 'semeadura comunitária' ,
149+ 'species' : [self .species ['id' ]],
150+ 'name' : 'Convidado' ,
151+ 'email' : 'convidado@example.com' ,
152+ }
153+ },
154+ 'images' : [image1 ],
155+ }, content_type = MULTIPART_CONTENT )
156+
157+ sowing = response .json ()['data' ]['sowingCreate' ]['sowing' ]['node' ]
158+
159+ expected = {
160+ 'data' : {
161+ 'sowingCreate' : {
162+ 'sowing' : {
163+ 'node' : {
164+ 'id' : sowing ['id' ],
165+ 'where' : 'bairro central' ,
166+ 'notes' : 'semeadura comunitária' ,
167+ 'author' : None ,
168+ 'authorName' : 'Convidado' ,
169+ 'authorEmail' : 'convidado@example.com' ,
170+ 'images' : {
171+ 'edges' : [sowing ['images' ]['edges' ][0 ]],
172+ },
173+ }
174+ },
175+ 'clientMutationId' : '1' ,
176+ 'errors' : None ,
177+ }
178+ }
179+ }
180+ self .assertEqual (response .json (), expected )
181+
119182 def _do_create_life_node (self , client , node ):
120183 return self .graphql ({
121184 'query' : """
0 commit comments