def test_populate_worker_passes(self): user1 = User.objects.create_user('*****@*****.**', '*****@*****.**', 'pass') user1.save() user2 = User.objects.create_user('*****@*****.**', '*****@*****.**', 'pass') user2.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) worker1 = WorkerEntry.objects.create(user=user1) worker2 = WorkerEntry.objects.create(user=user2) self.assertEqual( 0, BenchmarkDefinitionWorkerPassEntry.objects.all().count()) BenchmarkDefinitionController.populate_worker_passes_for_definition( benchmark_definition1) self.assertEqual( 2, BenchmarkDefinitionWorkerPassEntry.objects.all().count()) self.assertEqual( 1, BenchmarkDefinitionWorkerPassEntry.objects.filter( definition__id=benchmark_definition1.id, worker__id=worker1.id).count()) self.assertEqual( 1, BenchmarkDefinitionWorkerPassEntry.objects.filter( definition__id=benchmark_definition1.id, worker__id=worker2.id).count())
def create_new_benchmark_definition(request): """ Creates a new benchmark defintion """ if request.method != 'POST': return res.get_response(400, 'Only post allowed', {}) definition = BenchmarkDefinitionController.create_default_benchmark_definition( ) BenchmarkDefinitionController.populate_worker_passes_for_definition( definition) data = {} data['redirect'] = ViewUrlGenerator.get_benchmark_definitions_url(1) return res.get_response(200, 'Benchmark definition created', data)