def test_store_record(conn): with closing(conn.cursor()) as cursor: datasource = name_to_datasource(cursor, "test-source-003") attributes = [Attribute("a", "integer", "a attribute"), Attribute("b", "integer", "b attribute")] notificationstore = NotificationStore(datasource, attributes) notificationstore.create(cursor) datarecord = Record( entity_id=100, timestamp=datetime(2013, 6, 5, 12, 0, 0), attribute_names=["a", "b"], values=[1, 42] ) notificationstore.store_record(datarecord)(cursor)
def test_create(conn): with closing(conn.cursor()) as cursor: datasource = name_to_datasource(cursor, "test-source-001") notificationstore = NotificationStore(datasource, []) notificationstore.create(cursor) assert notificationstore.id is not None query = ( "SELECT datasource_id " "FROM notification.notificationstore " "WHERE id = %s") args = (notificationstore.id,) cursor.execute(query, args) eq_(cursor.rowcount, 1) datasource_id, = cursor.fetchone() eq_(datasource_id, datasource.id)