def get(self, uuid): self.set_status(200) try: last_result = LoadTest.get_last_result_for(uuid) if last_result: self.write(dumps(last_result.to_dict())) else: self.set_status(404) except DoesNotExist: self.set_status(404) finally: self.finish()
def test_get_last_result_for_diff(self): config = TestConfigurationFactory.build() self.load_test.results.append(TestResultFactory.build(config=config)) self.load_test.results.append(TestResultFactory.build()) self.load_test.save() load_test2 = LoadTestFactory.add_to_project(1, user=self.user, team=self.team, project=self.project, status="Finished") load_test2.results.append(TestResultFactory.build()) load_test2.results.append(TestResultFactory.build(config=config)) load_test2.save() result1 = self.load_test.results[0] result2 = load_test2.results[1] test_result = LoadTest.get_last_result_for(str(result2.uuid)) expect(str(test_result.uuid)).to_equal(str(result1.uuid))