def remaining_time(self): try: remaining = max(j.time_tracker.remaining for j in self.jobs if j.time_tracker.remaining is not None) return seconds_to_time(milliseconds_to_seconds(remaining)) except ValueError: return None
def test_remaining_with_multiple_jobs_should_return_longest_time(self): test_buildset = fixtures.buildset() test_jobs = [fixtures.job() for x in range(3)] max_time = max(job.time_tracker.remaining for job in test_jobs) test_buildset.jobs = test_jobs result = test_buildset.remaining_time expected = seconds_to_time(milliseconds_to_seconds(max_time)) self.assertEqual(result, expected)
def __init__(self, name, buildset_id, jobs, enqueue_time, owner, ref, review_url): self.name = name self.buildset_id = buildset_id self.jobs = jobs self.enqueue_time = milliseconds_to_seconds(enqueue_time) self.owner = owner self.ref = ref self.review_url = review_url
def test_int_ms_milliseconds_to_seconds_should_return_data(self): result = milliseconds_to_seconds(milliseconds=8000) expected = 8.0 self.assertEqual(result, expected)
def test_none_ms_milliseconds_to_seconds_should_raise_excpetion(self): with self.assertRaises(TypeError): milliseconds_to_seconds(milliseconds=None)
def test_hour_remaining_to_time_should_return_data(self): tt = fixtures.time_tracker() result = tt.remaining_to_time expected = seconds_to_time(milliseconds_to_seconds(tt.remaining)) self.assertEqual(result, expected)
def remaining_to_time(self): if self.remaining is not None: return seconds_to_time(milliseconds_to_seconds(self.remaining)) return None
def elapsed_to_time(self): if self.elapsed: return seconds_to_time(milliseconds_to_seconds(self.elapsed)) return None