def test_retrieve(conn):
    with closing(conn.cursor()) as cursor:
        time1 = pytz.utc.localize(datetime.utcnow())
        trend_names = ['CellID', 'CCR', 'Drops']
        data_rows = [
            (10023, time1, ('10023', '0.9919', '17')),
            (10047, time1, ('10047', '0.9963', '18'))
        ]
        datapackage = DataPackage(trend_names, data_rows)

        entitytype = name_to_entitytype(cursor, "UtranCell")
        datasource = name_to_datasource(cursor, "integration-test")

        data_types = ["text", "real", "smallint"]

        attributes = [Attribute(name, datatype) for name, datatype in
                      zip(trend_names, data_types)]

        attributestore = AttributeStore(datasource, entitytype, attributes)
        attributestore.create(cursor)

        attributestore.store_txn(datapackage).run(conn)
        time.sleep(5)

        time2 = pytz.utc.localize(datetime.utcnow())
        update_data_rows = [(10023, time2, ('10023', '0.9919', '18'))]
        update_datapackage = DataPackage(trend_names, update_data_rows)
        attributestore.store_txn(update_datapackage).run(conn)
        conn.commit()

        data = retrieve(conn, attributestore.table, trend_names, [10023])
        assert_not_equal(data, None)
Example #2
0
    def retrieve(self, datasource, entitytype, attribute_names, entities,
                 timestamp=None):
        attributestore = AttributeStore(datasource, entitytype)

        return retrieve(self.conn, attributestore.history_table, attribute_names,
                        entities, timestamp)