def test_valid(): assert valid("2000-01-12T00:00:00Z") is False current_year = datetime.today().year assert valid("%d-01-12T00:00:00Z" % (current_year + 1)) is True this_instance = instant() assert valid(this_instance) is False # unless on a very fast machine :-) soon = in_a_while(seconds=10) assert valid(soon) is True
def _expiration(timeout, time_format=None): """ Return an expiration time :param timeout: When :param time_format: The format of the returned value :return: A timeout date """ if timeout == "now": return time_util.instant(time_format) else: # validity time should match lifetime of assertions return time_util.in_a_while(minutes=timeout, time_format=time_format)
def test_instant(): inst = str_to_time(instant()) now = time.gmtime() assert now >= inst