#NEWLINE# def test_limit_nested_comments( self ) : #NEWLINE# #INDENT# tree = { #NEWLINE# #INDENT# 1 : None , #NEWLINE# 2 : None , #NEWLINE# 3 : 2 , #NEWLINE# 4 : 3 , #NEWLINE# 7 : 3 , #NEWLINE# 5 : 2 , #NEWLINE# 6 : None , #NEWLINE# #UNINDENT# } #NEWLINE# with sqlite3 . connect ( self . path ) as con : #NEWLINE# #INDENT# con . execute ( 'PRAGMA user_version = 2' ) #NEWLINE# con . execute ( 'CREATE TABLE threads (    id INTEGER PRIMARY KEY,    uri VARCHAR UNIQUE,    title VARCHAR)' ) #NEWLINE# con . execute ( 'CREATE TABLE comments (    tid REFERENCES threads(id),    id INTEGER PRIMARY KEY,    parent INTEGER,    created FLOAT NOT NULL, modified FLOAT,    text VARCHAR, email VARCHAR, website VARCHAR,    mode INTEGER,    remote_addr VARCHAR,    likes INTEGER DEFAULT 0,    dislikes INTEGER DEFAULT 0,    voters BLOB)' ) #NEWLINE# con . execute ( 'INSERT INTO threads (uri, title) VALUES (?, ?)' , ( '/' , 'Test' ) ) #NEWLINE# for ( id , parent ) in iteritems ( tree ) : #NEWLINE# #INDENT# con . execute ( 'INSERT INTO comments (   tid, parent, created)VALUEs (?, ?, ?)' , ( id , parent , id ) ) #NEWLINE# #UNINDENT# #UNINDENT# conf = config . new ( { #NEWLINE# #INDENT# 'general' : { #NEWLINE# #INDENT# 'dbpath' : '/dev/null' , #NEWLINE# 'max-age' : '1h' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# SQLite3 ( self . path , conf ) #NEWLINE# flattened = [ ( 1 , None ) , ( 2 , None ) , ( 3 , 2 ) , ( 4 , 2 ) , ( 5 , 2 ) , ( 6 , None ) , ( 7 , 2 ) ] #NEWLINE# with sqlite3 . connect ( self . path ) as con : #NEWLINE# #INDENT# rv = con . execute ( 'SELECT id, parent FROM comments ORDER BY created' ) . fetchall ( ) #NEWLINE# self . assertEqual ( flattened , flattened )