def test_store_raw_fractured_small(conn):
    plugin = TrendPlugin(conn)

    with closing(conn.cursor()) as cursor:
        clear_database(cursor)

        datasource = name_to_datasource(cursor, "test_source002")

    conn.commit()

    granularity = 3600

    timestamp = "2012-04-19T11:00:00"

    trend_names_part_1 = ["PART1_COUNTER1", "PART1_COUNTER2", "PART1_COUNTER3"]

    raw_data_rows = [
        ("Network=dummy,Subnetwork=test,Element=1", ("1", "2", "3"))
    ]

    plugin.store_raw(datasource, granularity, timestamp,
            trend_names_part_1, raw_data_rows)

    trend_names_part_2 = ["PART2_COUNTER1", "PART2_COUNTER2", "PART2_COUNTER3"]

    raw_data_rows = [
        ("Network=dummy,Subnetwork=test,Element=1", ("4", "5", "6"))
    ]

    plugin.store_raw(datasource, granularity, timestamp,
            trend_names_part_2, raw_data_rows)
def test_store_raw_fractured_large(conn):
    plugin = TrendPlugin(conn)

    with closing(conn.cursor()) as cursor:
        clear_database(cursor)

        datasource = name_to_datasource(cursor, "test_source003")

    conn.commit()

    granularity = 3600

    timestamp = "2012-04-19T11:00:00"

    trend_names_part_1 = ["PART1_COUNTER1", "PART1_COUNTER2", "PART1_COUNTER3"]

    dn_template = "Network=dummy,Subnetwork=test,Element={}"

    raw_data_rows_part_1 = [(dn_template.format(i), ("1", "2", "3"))
            for i in range(100)]

    plugin.store_raw(datasource, granularity, timestamp,
            trend_names_part_1, raw_data_rows_part_1)

    trend_names_part_2 = ["PART2_COUNTER1", "PART2_COUNTER2", "PART2_COUNTER3"]

    raw_data_rows_part_2 = [(dn_template.format(i), ("4", "5", "6"))
            for i in range(100)]

    plugin.store_raw(datasource, granularity, timestamp,
            trend_names_part_2, raw_data_rows_part_2)
def test_store_raw1(conn):
    plugin = TrendPlugin(conn)

    with closing(conn.cursor()) as cursor:
        clear_database(cursor)

        datasource = name_to_datasource(cursor, "test_source001")

    conn.commit()

    granularity = 3600

    timestamp = "2012-04-19T11:00:00"

    trend_names = ["COUNTER1", "COUNTER2", "COUNTER3"]

    rows = [
        ("Network=dummy,Subnetwork=test,Element=1", ("1", "2", "3"))
    ]

    plugin.store_raw(datasource, granularity, timestamp, trend_names,
            rows)