@@ -29,6 +29,7 @@ def setUp(self):
2929 'benchmark' : 'float' ,
3030 'environment' : 'Dual Core' ,
3131 'result_value' : 456 ,
32+ 'source' : 'legacy' ,
3233 }
3334
3435 def test_add_correct_result (self ):
@@ -190,11 +191,13 @@ def test_source_set_on_new_benchmark(self):
190191 b = Benchmark .objects .get (name = 'newbench' )
191192 self .assertEqual (b .source , 'pyperformance' )
192193
193- def test_source_defaults_to_legacy (self ):
194- """A payload without a source creates a 'legacy' Benchmark"""
195- self .client .post (self .path , self .data )
196- b = Benchmark .objects .get (name = 'float' )
197- self .assertEqual (b .source , 'legacy' )
194+ def test_missing_source_rejected (self ):
195+ """A payload without a source is rejected instead of defaulting"""
196+ modified_data = copy .deepcopy (self .data )
197+ del modified_data ['source' ]
198+ response = self .client .post (self .path , modified_data )
199+ self .assertEqual (response .status_code , 400 )
200+ self .assertFalse (Benchmark .objects .filter (name = 'float' ).exists ())
198201
199202 def test_same_name_different_source_are_distinct (self ):
200203 """The same name in a different suite is a separate Benchmark"""
@@ -245,28 +248,32 @@ def setUp(self):
245248 'executable' : 'pypy-c' ,
246249 'benchmark' : 'Richards' ,
247250 'environment' : 'bigdog' ,
248- 'result_value' : 456 },
251+ 'result_value' : 456 ,
252+ 'source' : 'legacy' },
249253 {'commitid' : '456' ,
250254 'project' : 'pypy' ,
251255 'branch' : 'default' ,
252256 'executable' : 'pypy-c' ,
253257 'benchmark' : 'Richards' ,
254258 'environment' : 'bigdog' ,
255- 'result_value' : 457 },
259+ 'result_value' : 457 ,
260+ 'source' : 'legacy' },
256261 {'commitid' : '456' ,
257262 'project' : 'pypy' ,
258263 'branch' : 'default' ,
259264 'executable' : 'pypy-c' ,
260265 'benchmark' : 'Richards2' ,
261266 'environment' : 'bigdog' ,
262- 'result_value' : 34 },
267+ 'result_value' : 34 ,
268+ 'source' : 'legacy' },
263269 {'commitid' : '789' ,
264270 'project' : 'pypy' ,
265271 'branch' : 'default' ,
266272 'executable' : 'pypy-c' ,
267273 'benchmark' : 'Richards' ,
268274 'environment' : 'bigdog' ,
269- 'result_value' : 458 },
275+ 'result_value' : 458 ,
276+ 'source' : 'legacy' },
270277 ]
271278
272279 def test_get_returns_405 (self ):
@@ -452,6 +459,7 @@ def setUp(self):
452459 'benchmark' : 'float' ,
453460 'environment' : 'Dual Core' ,
454461 'result_value' : 200 ,
462+ 'source' : 'legacy' ,
455463 }
456464 resp = self .client .post (reverse ('add-result' ),
457465 self .data )
0 commit comments