#!/usr/bin/python3

#
# Development Order #4:
#
# Determine the duration of a specified test.
#

#
# TODO: This is a bare-bones, unreliable implementation that should be
# used only for testing.
#

import datetime
import pscheduler

from common import *

json = pscheduler.json_load(exit_on_error=True)['spec']

# Release wait time
timeout = datetime.timedelta(seconds=RELEASE_TIMEOUT)

# Lease wait time        
timeout_iso = json.get("timeout", "PT%dS" % DEFAULT_LEASE_TIMEOUT)
timeout += pscheduler.iso8601_as_timedelta(timeout_iso)

# Internal slop
timeout += datetime.timedelta(seconds=2)

pscheduler.succeed_json({
    "duration": pscheduler.timedelta_as_iso8601( timeout )
    })
