@@ -30,7 +30,7 @@ def setUp(self):
3030 'benchmark' : 'float' ,
3131 'environment' : 'Dual Core' ,
3232 'result_value' : 456 ,
33- 'source' : 'legacy ' ,
33+ 'source' : '2010-suite ' ,
3434 }
3535
3636 def test_add_correct_result (self ):
@@ -44,7 +44,7 @@ def test_add_correct_result(self):
4444 # Check that the data was correctly saved
4545 e = Environment .objects .get (name = 'Dual Core' )
4646 b = Benchmark .objects .get (name = 'float' )
47- self .assertEqual (b .source , "legacy " )
47+ self .assertEqual (b .source , "2010-suite " )
4848 self .assertEqual (b .units , "seconds" )
4949 self .assertEqual (b .lessisbetter , True )
5050 p = Project .objects .get (name = 'MyProject' )
@@ -106,7 +106,7 @@ def test_bad_environment(self):
106106 def test_empty_argument (self ):
107107 """Should respond 400 when a POST request has an empty argument"""
108108 for key in self .data :
109- if key == 'source' : # optional, defaults to 'legacy '
109+ if key == 'source' : # optional, defaults to '2010-suite '
110110 continue
111111 backup = self .data [key ]
112112 self .data [key ] = ""
@@ -120,7 +120,7 @@ def test_empty_argument(self):
120120 def test_missing_argument (self ):
121121 """Should respond 400 when a POST request is missing an argument"""
122122 for key in list (self .data ):
123- if key == 'source' : # optional, defaults to 'legacy '
123+ if key == 'source' : # optional, defaults to '2010-suite '
124124 continue
125125 backup = self .data [key ]
126126 del self .data [key ]
@@ -196,14 +196,23 @@ def test_source_set_on_new_benchmark(self):
196196 b = Benchmark .objects .get (name = 'newbench' )
197197 self .assertEqual (b .source , 'pyperformance' )
198198
199- def test_source_defaults_to_legacy (self ):
200- """A payload without a source creates a 'legacy ' Benchmark"""
199+ def test_source_defaults_to_2010_suite (self ):
200+ """A payload without a source creates a '2010-suite ' Benchmark"""
201201 modified_data = copy .deepcopy (self .data )
202202 del modified_data ['source' ]
203203 response = self .client .post (self .path , modified_data )
204204 self .assertEqual (response .status_code , 202 )
205205 b = Benchmark .objects .get (name = 'float' )
206- self .assertEqual (b .source , 'legacy' )
206+ self .assertEqual (b .source , '2010-suite' )
207+
208+ def test_former_source_name_is_accepted (self ):
209+ """Uploaders still sending the pre-rename source name are mapped"""
210+ modified_data = copy .deepcopy (self .data )
211+ modified_data ['source' ] = 'legacy'
212+ response = self .client .post (self .path , modified_data )
213+ self .assertEqual (response .status_code , 202 )
214+ b = Benchmark .objects .get (name = 'float' )
215+ self .assertEqual (b .source , '2010-suite' )
207216
208217 def test_same_name_different_source_are_distinct (self ):
209218 """The same name in a different suite is a separate Benchmark"""
@@ -212,10 +221,10 @@ def test_same_name_different_source_are_distinct(self):
212221 modified_data ['source' ] = 'pyperformance'
213222 self .client .post (self .path , modified_data )
214223
215- legacy = Benchmark .objects .get (name = 'float' , source = 'legacy ' )
224+ suite2010 = Benchmark .objects .get (name = 'float' , source = '2010-suite ' )
216225 pyperf = Benchmark .objects .get (name = 'float' , source = 'pyperformance' )
217- self .assertNotEqual (legacy .pk , pyperf .pk )
218- self .assertEqual (legacy .results .count (), 1 )
226+ self .assertNotEqual (suite2010 .pk , pyperf .pk )
227+ self .assertEqual (suite2010 .results .count (), 1 )
219228 self .assertEqual (pyperf .results .count (), 1 )
220229
221230 def test_invalid_source_rejected (self ):
@@ -255,31 +264,31 @@ def setUp(self):
255264 'benchmark' : 'Richards' ,
256265 'environment' : 'bigdog' ,
257266 'result_value' : 456 ,
258- 'source' : 'legacy ' },
267+ 'source' : '2010-suite ' },
259268 {'commitid' : '456' ,
260269 'project' : 'pypy' ,
261270 'branch' : 'default' ,
262271 'executable' : 'pypy-c' ,
263272 'benchmark' : 'Richards' ,
264273 'environment' : 'bigdog' ,
265274 'result_value' : 457 ,
266- 'source' : 'legacy ' },
275+ 'source' : '2010-suite ' },
267276 {'commitid' : '456' ,
268277 'project' : 'pypy' ,
269278 'branch' : 'default' ,
270279 'executable' : 'pypy-c' ,
271280 'benchmark' : 'Richards2' ,
272281 'environment' : 'bigdog' ,
273282 'result_value' : 34 ,
274- 'source' : 'legacy ' },
283+ 'source' : '2010-suite ' },
275284 {'commitid' : '789' ,
276285 'project' : 'pypy' ,
277286 'branch' : 'default' ,
278287 'executable' : 'pypy-c' ,
279288 'benchmark' : 'Richards' ,
280289 'environment' : 'bigdog' ,
281290 'result_value' : 458 ,
282- 'source' : 'legacy ' },
291+ 'source' : '2010-suite ' },
283292 ]
284293
285294 def test_get_returns_405 (self ):
@@ -301,7 +310,7 @@ def test_add_correct_results(self):
301310 # Check that the data was correctly saved
302311 e = Environment .objects .get (name = 'bigdog' )
303312 b = Benchmark .objects .get (name = 'Richards' )
304- self .assertEqual (b .source , "legacy " )
313+ self .assertEqual (b .source , "2010-suite " )
305314 self .assertEqual (b .units , "seconds" )
306315 self .assertEqual (b .lessisbetter , True )
307316 p = Project .objects .get (name = 'pypy' )
@@ -356,7 +365,7 @@ def test_empty_argument(self):
356365 '''Should return 400 when making a request with an empty argument'''
357366 data = self .data [1 ]
358367 for key in data :
359- if key == 'source' : # optional, defaults to 'legacy '
368+ if key == 'source' : # optional, defaults to '2010-suite '
360369 continue
361370 backup = data [key ]
362371 data [key ] = ""
@@ -372,7 +381,7 @@ def test_missing_argument(self):
372381 '''Should return 400 when making a request with a missing argument'''
373382 data = self .data [2 ]
374383 for key in list (data ):
375- if key == 'source' : # optional, defaults to 'legacy '
384+ if key == 'source' : # optional, defaults to '2010-suite '
376385 continue
377386 backup = data [key ]
378387 del data [key ]
@@ -523,19 +532,19 @@ def test_no_source_fold_with_one_source(self):
523532 response = self .client .get (reverse ('timeline' ))
524533 self .assertEqual (response .status_code , 200 )
525534 self .assertIsNone (response .context ['grid_revisions' ])
526- self .assertNotContains (response , 'class="togglefold">Legacy </a>' )
535+ self .assertNotContains (response , 'class="togglefold">2010-suite </a>' )
527536 self .assertContains (response , 'grid_revisions: null' )
528537
529538 def test_source_fold_with_several_sources (self ):
530539 Benchmark .objects .create (name = 'float' , source = 'pyperformance' )
531540 # Suites are rendered folded, except the one of the selected benchmark
532541 response = self .client .get (reverse ('timeline' ))
533- self .assertContains (response , 'class="togglefold folded">Legacy </a>' )
542+ self .assertContains (response , 'class="togglefold folded">2010-suite </a>' )
534543 self .assertContains (
535544 response , 'class="togglefold folded">PyPerformance</a>' )
536545 response = self .client .get (
537546 reverse ('timeline' ), {'ben' : 'float.pyperformance' })
538- self .assertContains (response , 'class="togglefold folded">Legacy </a>' )
547+ self .assertContains (response , 'class="togglefold folded">2010-suite </a>' )
539548 self .assertContains (response , 'class="togglefold">PyPerformance</a>' )
540549
541550 @override_settings (TIMELINE_GRID_REVISIONS = 25 )
@@ -614,11 +623,18 @@ def test_groups_with_nothing_checked_are_rendered_folded(self):
614623 self .assertContains (
615624 response , 'class="togglefold folded">PyPerformance</a>' )
616625
626+ def test_former_source_name_in_ben_param (self ):
627+ """Permalinks from before the rename still say ben=legacy"""
628+ from codespeed .views import _parse_ben_param
629+ Benchmark .objects .create (name = 'float' , source = 'pyperformance' )
630+ self .assertEqual (
631+ {b .source for b in _parse_ben_param ('legacy' )}, {'2010-suite' })
632+
617633 def test_benchmarks_grouped_by_source_with_several_sources (self ):
618634 Benchmark .objects .create (name = 'float' , source = 'pyperformance' )
619635 response = self .client .get (self .path )
620636 self .assertEqual (list (response .context ['benchmarks' ]),
621- ['Legacy ' , 'PyPerformance' ])
637+ ['2010-suite ' , 'PyPerformance' ])
622638
623639
624640@override_settings (ALLOW_ANONYMOUS_POST = True )
@@ -634,7 +650,7 @@ def setUp(self):
634650 'benchmark' : 'float' ,
635651 'environment' : 'Dual Core' ,
636652 'result_value' : 200 ,
637- 'source' : 'legacy ' ,
653+ 'source' : '2010-suite ' ,
638654 }
639655 resp = self .client .post (reverse ('add-result' ),
640656 self .data )
0 commit comments