def test_get_unix_time_from_time_string_360(time_str, time_sec): mode = CALENDAR.mode CALENDAR.set_mode(CALENDAR.MODE_360) try: assert get_unix_time_from_time_string(time_str) == time_sec finally: CALENDAR.set_mode(mode)
def get_task_icon(status, is_held, start_time=None, mean_time=None): """Return a Unicode string to represent a task. Arguments: status (str): A Cylc task status string. is_held (bool): True if the task is in a held state. start_time (str): Start date time string. mean_time (int): Execution mean time. Returns: list - Text content for the urwid.Text widget, may be a string, tuple or list, see urwid docs. """ ret = [] if is_held: ret.append(TASK_MODIFIERS['held']) if (status == TASK_STATUS_RUNNING and start_time and mean_time): start_time = get_unix_time_from_time_string(start_time) progress = (time() - start_time) / mean_time if progress >= 0.75: status = f'{TASK_STATUS_RUNNING}:75' elif progress >= 0.5: status = f'{TASK_STATUS_RUNNING}:50' elif progress >= 0.25: status = f'{TASK_STATUS_RUNNING}:25' else: status = f'{TASK_STATUS_RUNNING}:0' ret.append(TASK_ICONS[status]) return ret
def test_get_unix_time_from_time_string_error(value, error): with pytest.raises(error): get_unix_time_from_time_string(value)
def test_get_unix_time_from_time_string(time_str, time_sec): assert get_unix_time_from_time_string(time_str) == time_sec