def get(self, team, project_name): quantity = self.get_argument("quantity").strip() quantity = int(quantity) if quantity else 20 load_tests = LoadTest.get_sliced_by_team_and_project_name(team, project_name, quantity) self.set_status(200) response = dumps([load_test.to_dict() for load_test in load_tests]) self.write(response) self.finish()
def test_list_load_tests_by_user_only(self): team1 = TeamFactory.create(owner=self.user) team2 = TeamFactory.create(owner=self.user) TeamFactory.add_projects(team1, 2) TeamFactory.add_projects(team2, 3) project1 = team1.projects[0] project2 = team1.projects[1] project3 = team2.projects[0] project4 = team2.projects[1] project5 = team2.projects[2] LoadTestFactory.add_to_project(4, user=self.user, team=team1, project=project1) LoadTestFactory.add_to_project(4, user=self.user, team=team1, project=project2) LoadTestFactory.add_to_project(4, user=self.user, team=team2, project=project3) LoadTestFactory.add_to_project(4, user=self.user, team=team2, project=project4) LoadTestFactory.add_to_project(4, user=self.user, team=team2, project=project5) load_tests1 = LoadTest.get_sliced_by_team_and_project_name(team1, project1.name, 3) load_tests2 = LoadTest.get_sliced_by_team_and_project_name(team1, project2.name, 3) load_tests3 = LoadTest.get_sliced_by_team_and_project_name(team2, project3.name, 3) load_tests4 = LoadTest.get_sliced_by_team_and_project_name(team2, project4.name, 3) load_tests5 = LoadTest.get_sliced_by_team_and_project_name(team2, project5.name, 3) uuids1 = _get_print_lines_for_load_tests(load_tests1) uuids2 = _get_print_lines_for_load_tests(load_tests2) uuids3 = _get_print_lines_for_load_tests(load_tests3) uuids4 = _get_print_lines_for_load_tests(load_tests4) uuids5 = _get_print_lines_for_load_tests(load_tests5) result = self.execute("list") expect(result).to_be_like((BASE_LOAD_TESTS_TABLE_PRINT * 5) % ( team1.name, project1.name, "".join(uuids1), team1.name, project2.name, "".join(uuids2), team2.name, project3.name, "".join(uuids3), team2.name, project4.name, "".join(uuids4), team2.name, project5.name, "".join(uuids5) ))
def test_list_load_tests_by_team_only(self): team = TeamFactory.create(owner=self.user) TeamFactory.add_projects(team, 2) project1 = team.projects[0] project2 = team.projects[1] LoadTestFactory.add_to_project(7, user=self.user, team=team, project=project1) LoadTestFactory.add_to_project(7, user=self.user, team=team, project=project2) load_tests1 = LoadTest.get_sliced_by_team_and_project_name(team, project1.name, 5) load_tests2 = LoadTest.get_sliced_by_team_and_project_name(team, project2.name, 5) uuids1 = _get_print_lines_for_load_tests(load_tests1) uuids2 = _get_print_lines_for_load_tests(load_tests2) result = self.execute("list", team=team.name) expect(result).to_be_like((BASE_LOAD_TESTS_TABLE_PRINT * 2) % ( team.name, project1.name, "".join(uuids1), team.name, project2.name, "".join(uuids2) ))
def test_list_load_tests_by_team_and_project(self): team = TeamFactory.create(owner=self.user) TeamFactory.add_projects(team, 1) project = team.projects[0] LoadTestFactory.add_to_project(25, user=self.user, team=team, project=project) load_tests = LoadTest.get_sliced_by_team_and_project_name(team, project.name, 20) uuids = _get_print_lines_for_load_tests(load_tests) result = self.execute("list", team=team.name, project=project.name) expect(result).to_be_like(BASE_LOAD_TESTS_TABLE_PRINT % (team.name, project.name, "".join(uuids)))
def get(self, team, project_name, test_uuid, result_uuid=None): project = [project for project in team.projects if project.name == project_name] if not project: self.set_status(404) self.finish() return load_test = [ load_test for load_test in LoadTest.get_sliced_by_team_and_project_name(team, project_name, 1) if str(load_test.uuid) == test_uuid ] if not load_test: self.set_status(404) self.finish() return try: load_test, test_result = LoadTest.get_test_result(result_uuid) self.write(dumps(test_result.to_dict())) self.set_status(200) except DoesNotExist: self.set_status(404) self.finish()