def get_benchmark_definition_all(request, page_index): """ Returns html for the benchmark definition page """ (definitions, page_indices) = BenchmarkDefinitionController.get_benchmark_definitions_with_pagination( DEFINITION_ITEMS_PER_PAGE, page_index, PAGINATION_HALF_RANGE ) for definition in definitions: definition['url'] = {} definition['url']['single'] = ViewUrlGenerator.get_benchmark_definition_url(definition['id']) data = {} data['definitions'] = definitions data['menu'] = ViewPrepareObjects.prepare_menu_for_html([]) data['pagination'] = ViewPrepareObjects.prepare_pagination_bench_definitions(page_indices) data['controls'] = get_definition_controls() return res.get_template_data(request, 'presenter/benchmark_definition_all.html', data)
def test_get_benchmark_definitions_paginated_fist_by_active_then_by_name( self): user1 = User.objects.create_user('*****@*****.**', '*****@*****.**', 'pass') user1.save() git_project1 = GitProjectEntry.objects.create(url='http://test/') command_group = CommandGroupEntry.objects.create() command_set = CommandSetEntry.objects.create(group=command_group) bluesteel_layout = BluesteelLayoutEntry.objects.create( name='Layout', active=True, project_index_path=0) bluesteel_project = BluesteelProjectEntry.objects.create( name='Project', order=0, layout=bluesteel_layout, command_group=command_group, git_project=git_project1) benchmark_definition1 = BenchmarkDefinitionEntry.objects.create( name='BenchmarkDefinition1', layout=bluesteel_layout, project=bluesteel_project, active=True, command_set=command_set, revision=28) benchmark_definition2 = BenchmarkDefinitionEntry.objects.create( name='BenchmarkDefinition9', layout=bluesteel_layout, project=bluesteel_project, active=False, command_set=command_set, revision=28) benchmark_definition3 = BenchmarkDefinitionEntry.objects.create( name='BenchmarkDefinition2', layout=bluesteel_layout, project=bluesteel_project, active=True, command_set=command_set, revision=28) benchmark_definition4 = BenchmarkDefinitionEntry.objects.create( name='BenchmarkDefinition8', layout=bluesteel_layout, project=bluesteel_project, active=False, command_set=command_set, revision=28) benchmark_definition5 = BenchmarkDefinitionEntry.objects.create( name='BenchmarkDefinition3', layout=bluesteel_layout, project=bluesteel_project, active=True, command_set=command_set, revision=28) benchmark_definition6 = BenchmarkDefinitionEntry.objects.create( name='BenchmarkDefinition7', layout=bluesteel_layout, project=bluesteel_project, active=False, command_set=command_set, revision=28) ( definitions1, paginations1 ) = BenchmarkDefinitionController.get_benchmark_definitions_with_pagination( 6, 1, 1) self.assertEqual(6, len(definitions1)) self.assertEqual('BenchmarkDefinition1', definitions1[0]['name']) self.assertEqual('BenchmarkDefinition2', definitions1[1]['name']) self.assertEqual('BenchmarkDefinition3', definitions1[2]['name']) self.assertEqual('BenchmarkDefinition7', definitions1[3]['name']) self.assertEqual('BenchmarkDefinition8', definitions1[4]['name']) self.assertEqual('BenchmarkDefinition9', definitions1[5]['name']) self.assertEqual(True, definitions1[0]['active']) self.assertEqual(True, definitions1[1]['active']) self.assertEqual(True, definitions1[2]['active']) self.assertEqual(False, definitions1[3]['active']) self.assertEqual(False, definitions1[4]['active']) self.assertEqual(False, definitions1[5]['active'])
def test_get_benchmark_definitions_paginated_with_fluctuations(self): user1 = User.objects.create_user('*****@*****.**', '*****@*****.**', 'pass') user1.save() git_project1 = GitProjectEntry.objects.create(url='http://test/') command_group = CommandGroupEntry.objects.create() command_set = CommandSetEntry.objects.create(group=command_group) bluesteel_layout = BluesteelLayoutEntry.objects.create( name='Layout', active=True, project_index_path=0) bluesteel_project = BluesteelProjectEntry.objects.create( name='Project', order=0, layout=bluesteel_layout, command_group=command_group, git_project=git_project1) benchmark_definition1 = BenchmarkDefinitionEntry.objects.create( name='BenchmarkDefinition1', layout=bluesteel_layout, project=bluesteel_project, command_set=command_set, revision=28) benchmark_definition2 = BenchmarkDefinitionEntry.objects.create( name='BenchmarkDefinition2', layout=bluesteel_layout, project=bluesteel_project, command_set=command_set, revision=28) benchmark_definition3 = BenchmarkDefinitionEntry.objects.create( name='BenchmarkDefinition3', layout=bluesteel_layout, project=bluesteel_project, command_set=command_set, revision=28) benchmark_definition4 = BenchmarkDefinitionEntry.objects.create( name='BenchmarkDefinition4', layout=bluesteel_layout, project=bluesteel_project, command_set=command_set, revision=28) benchmark_definition5 = BenchmarkDefinitionEntry.objects.create( name='BenchmarkDefinition5', layout=bluesteel_layout, project=bluesteel_project, command_set=command_set, revision=28) benchmark_definition6 = BenchmarkDefinitionEntry.objects.create( name='BenchmarkDefinition6', layout=bluesteel_layout, project=bluesteel_project, command_set=command_set, revision=28) fluc1 = BenchmarkFluctuationOverrideEntry.objects.create( definition=benchmark_definition1, result_id='id1', override_value=28) fluc2 = BenchmarkFluctuationOverrideEntry.objects.create( definition=benchmark_definition2, result_id='id2', override_value=29) fluc3 = BenchmarkFluctuationOverrideEntry.objects.create( definition=benchmark_definition2, result_id='id3', override_value=30) ( definitions1, paginations1 ) = BenchmarkDefinitionController.get_benchmark_definitions_with_pagination( 2, 1, 1) definitions1.sort(key=lambda x: x['name']) self.assertEqual(2, len(definitions1)) self.assertEqual('BenchmarkDefinition1', definitions1[0]['name']) self.assertEqual(1, len(definitions1[0]['fluctuation_overrides'])) self.assertEqual( 'id1', definitions1[0]['fluctuation_overrides'][0]['result_id']) self.assertEqual( 28, definitions1[0]['fluctuation_overrides'][0]['override_value']) self.assertEqual('BenchmarkDefinition2', definitions1[1]['name']) self.assertEqual(2, len(definitions1[1]['fluctuation_overrides'])) self.assertEqual( 'id2', definitions1[1]['fluctuation_overrides'][0]['result_id']) self.assertEqual( 29, definitions1[1]['fluctuation_overrides'][0]['override_value']) self.assertEqual( 'id3', definitions1[1]['fluctuation_overrides'][1]['result_id']) self.assertEqual( 30, definitions1[1]['fluctuation_overrides'][1]['override_value']) self.assertEqual(1, paginations1['current']) self.assertEqual(1, paginations1['prev']) self.assertEqual(2, paginations1['next']) self.assertEqual([1, 2, 3], paginations1['page_indices'])