def test_thread_delete(db, gmail_account):
 generic_thread = add_fake_thread(db.session, gmail_account.namespace.id)
 generic_message = add_fake_message(db.session, gmail_account.namespace.id, generic_thread)
 assert (db.session.query(Thread).filter((Thread.id == generic_thread.id)).all() == [generic_thread])
 assert (db.session.query(Message).filter((Message.id == generic_message.id)).all() == [generic_message])
 db.session.delete(generic_thread)
 db.session.commit()
 assert (db.session.query(Thread).filter((Thread.id == generic_thread.id)).all() == [])
 assert (db.session.query(Message).filter((Message.id == generic_message.id)).all() == [])

def test_thread_delete ( db , gmail_account ) : generic_thread = add_fake_thread ( db . session , gmail_account . namespace . id ) generic_message = add_fake_message ( db . session , gmail_account . namespace . id , generic_thread ) assert ( db . session . query ( Thread ) . filter ( ( Thread . id == generic_thread . id ) ) . all ( ) == [ generic_thread ] ) assert ( db . session . query ( Message ) . filter ( ( Message . id == generic_message . id ) ) . all ( ) == [ generic_message ] ) db . session . delete ( generic_thread ) db . session . commit ( ) assert ( db . session . query ( Thread ) . filter ( ( Thread . id == generic_thread . id ) ) . all ( ) == [ ] ) assert ( db . session . query ( Message ) . filter ( ( Message . id == generic_message . id ) ) . all ( ) == [ ] )
ensure that all associated messages are deleted when a thread is deleted .