def test_filter_latest_jobs_higher_build_last(self): self.assertEqual( filter_latest_builds( [Build('foo', 3), Build('bar', 5), Build('foo', 5)]), [Build('bar', 5), Build('foo', 5)])
def latest_try_jobs(self, builder_names=None): """Returns a list of Builds for the latest jobs for the given builders.""" try_results = self.fetch_try_results() if builder_names: try_results = [ r for r in try_results if r['builder_name'] in builder_names ] return filter_latest_builds( self._try_result_to_build(r) for r in try_results)
def latest_try_jobs(self, builder_names=None): """Returns a dict of Builds to results for the latest try jobs. This includes jobs that are not yet finished and builds with infra failures, so if a build is in this list, that doesn't guarantee that there are results. Args: builder_names: Optional list of builders used to filter results. Returns: A dict mapping Build objects to TryJobSTatus objects, with only the latest jobs included. """ try_results = self.try_job_results() builds = try_results.keys() if builder_names: builds = [b for b in builds if b.builder_name in builder_names] latest_builds = filter_latest_builds(builds) return {b: s for b, s in try_results.items() if b in latest_builds}
def filter_latest(try_results): """Returns the latest entries from from a Build to TryJobStatus dict.""" if try_results is None: return None latest_builds = filter_latest_builds(try_results.keys()) return {b: s for b, s in try_results.items() if b in latest_builds}
def test_filter_latest_jobs_no_build_number(self): self.assertEqual( filter_latest_builds([Build('foo', 3), Build('bar'), Build('bar')]), [Build('bar'), Build('foo', 3)])
def test_filter_latest_jobs_empty(self): self.assertEqual(filter_latest_builds([]), [])