def test_series_string_input(): # one value parameter = TimeParameter("2085-01-01T12:00:00Z") assert parameter.value == ["2085-01-01T12:00:00"] assert parameter.get_bounds() == ("2085-01-01T12:00:00", "2085-01-01T12:00:00") # two values separated by "," parameter = TimeParameter("2085-01-01T12:00:00Z, 2120-12-30T12:00:00Z") assert parameter.value == ["2085-01-01T12:00:00", "2120-12-30T12:00:00"] assert parameter.get_bounds() == ("2085-01-01T12:00:00", "2120-12-30T12:00:00") # more then two values ... parameter = TimeParameter( "2085-01-01T12:00:00Z, 2090-01-01T12:00:00Z, 2120-12-30T12:00:00Z") assert parameter.value == [ "2085-01-01T12:00:00", "2090-01-01T12:00:00", "2120-12-30T12:00:00", ] assert parameter.get_bounds() == ("2085-01-01T12:00:00", "2120-12-30T12:00:00") # with year only parameter = TimeParameter("2085, 2120") assert parameter.value == ["2085-01-01T00:00:00", "2120-01-01T00:00:00"] assert parameter.get_bounds() == ("2085-01-01T00:00:00", "2120-01-01T00:00:00")
def test_time_parameter_get_bounds(): # Tests that the get_bounds() method of TimeParameter is working for # types "series", "interval" and "none" t_values = "2085-01-01T12:00:00", "2095-03-03T03:03:03", "2120-12-30T12:00:00" t_bounds = t_values[0], t_values[-1] def are_equal(b0, b1): return b0[0][:19] == b1[0][:19] and b0[1][:19] == b1[1][:19] parameter = TimeParameter(time_series(t_values)) assert parameter.type == "series" assert are_equal(parameter.get_bounds(), t_bounds) parameter = TimeParameter(time_series(t_bounds)) assert parameter.type == "series" assert are_equal(parameter.get_bounds(), t_bounds) parameter = TimeParameter(None) assert parameter.type == "none" assert parameter.get_bounds() == (None, None)
def test_interval_string_input(): # start/ parameter = TimeParameter("2085-01-01T12:00:00Z/") assert parameter.value == ("2085-01-01T12:00:00", None) assert parameter.get_bounds() == ("2085-01-01T12:00:00", None) # /end parameter = TimeParameter("/2120-12-30T12:00:00Z") assert parameter.value == (None, "2120-12-30T12:00:00") assert parameter.get_bounds() == (None, "2120-12-30T12:00:00") # start/end parameter = TimeParameter("2085-01-01T12:00:00Z/2120-12-30T12:00:00Z") assert parameter.value == ("2085-01-01T12:00:00", "2120-12-30T12:00:00") assert parameter.get_bounds() == ("2085-01-01T12:00:00", "2120-12-30T12:00:00") # start/end with non 360-day calendar parameter = TimeParameter("2085-01-01T00:00:00Z/2120-12-31T23:59:59Z") assert parameter.value == ("2085-01-01T00:00:00", "2120-12-31T23:59:59") assert parameter.get_bounds() == ("2085-01-01T00:00:00", "2120-12-31T23:59:59") # start/end with year parameter = TimeParameter("2085/2120") assert parameter.value == ("2085-01-01T00:00:00", "2120-12-31T23:59:59") assert parameter.get_bounds() == ("2085-01-01T00:00:00", "2120-12-31T23:59:59") # start/end with year-month-day parameter = TimeParameter("2085-01-16/2120-12-16") assert parameter.value == ("2085-01-16T00:00:00", "2120-12-16T23:59:59") assert parameter.get_bounds() == ("2085-01-16T00:00:00", "2120-12-16T23:59:59")