示例#1
0
def test_to_unix_timestamp_from_date_and_time():
    t = datetime.time(hour=12, minute=30, second=10, microsecond=6000)
    d = datetime.date(year=1991, month=10, day=17)

    unix_ms = support.to_unix_timestamp_from_date_and_time(d, t)

    run_tests.compare_answer(unix_ms, 687702610, "")
def retrieve_bandwidth_prediction_data(dbcc, link_id, date, end_time):
    end_time_unix = support.to_unix_timestamp_from_date_and_time(date, end_time)
    start_time_unix = end_time_unix - config.BP_USE_DATA_FROM_LAST_SECONDS

    conditions = [ ("link_id", "=", link_id)
                 , ("time", ">=", start_time_unix)
                 , ("time", "<=", end_time_unix)
                 ]

    bp_fetched = db_layout.BPFetched.retrieve_objects(dbcc, conditions)
    return bp_fetched
def check_integrity_bandwidth_prediction_data(bpfetched, date, end_time):
    end_time_unix = support.to_unix_timestamp_from_date_and_time(date, end_time)
    start_time_unix = end_time_unix - config.BP_USE_DATA_FROM_LAST_SECONDS

    list_time_throughput_bps = map(db_layout.BPFetched.to_tuple_without_link_id, bpfetched)

    missing_ranges = support.reduce_to_missing_ranges( list_time_throughput_bps
                                                     , lambda (time, throughput): time
                                                     , 1
                                                     , start_time_unix
                                                     , end_time_unix
                                                     )

    return missing_ranges