@@ -161,26 +161,45 @@ def test_api_v3_scratch_build(client):
161161 assert r .json ["data" ]["type" ] == ["brew-build_scratch" ]
162162
163163
164- def test_api_v3_outcome_upper_case (client ):
165- """POST parameter "outcome" is converted to upper-case."""
166- data = brew_build_request_data (outcome = "failed" )
164+ @pytest .mark .parametrize ("outcome" , ["failed" , " failed " ])
165+ def test_api_v3_outcome_normalize (outcome , client ):
166+ """POST parameter "outcome" is converted to upper-case and stripped."""
167+ data = brew_build_request_data (outcome = outcome )
167168 r = client .post ("/api/v3/results/brew-builds" , json = data )
168169 assert r .status_code == 201 , r .text
169170 assert r .json ["outcome" ] == "FAILED"
170171
171172
172173def test_api_v3_outcome_bad_type (client ):
173- """POST parameter "outcome" is converted to upper-case ."""
174+ """POST parameter "outcome" must be a string ."""
174175 data = brew_build_request_data (outcome = 0 )
175176 r = client .post ("/api/v3/results/brew-builds" , json = data )
176177 assert r .status_code == 400 , r .text
178+ assert r .json == {
179+ "validation_error" : [
180+ {
181+ "loc" : ["outcome" ],
182+ "msg" : "Input should be a valid string" ,
183+ "type" : "string_type" ,
184+ "input" : 0 ,
185+ "url" : ANY ,
186+ }
187+ ]
188+ }
189+
190+
191+ def test_api_v3_outcome_bad_value (client ):
192+ """POST parameter "outcome" must be a supported value."""
193+ data = brew_build_request_data (outcome = "pass" )
194+ r = client .post ("/api/v3/results/brew-builds" , json = data )
195+ assert r .status_code == 400 , r .text
177196 assert r .json == {
178197 "validation_error" : [
179198 {
180199 "loc" : ["outcome" ],
181200 "msg" : "Value error, must be one of: AMAZING, ERROR, FAILED, INFO, NEEDS_INSPECTION, PASSED, QUEUED, RUNNING" ,
182201 "type" : "value_error" ,
183- "input" : ANY ,
202+ "input" : "pass" ,
184203 "url" : ANY ,
185204 }
186205 ]
0 commit comments