Ticket #1721: turbogears-sqlalchemy-0.4-rollback-test.patch

File turbogears-sqlalchemy-0.4-rollback-test.patch, 1.2 kB (added by toshio, 5 months ago)

Test case for this issue

  • TurboGears-1.0.4.3/turbogears/tests/test_sqlalchemy.py

    old new  
    158158    doerr = errorhandling.exception_handler(handerr)(doerr) 
    159159    doerr = expose()(doerr) 
    160160 
     161    def handexc(self, id): 
     162        Person(id=id) 
     163        try: 
     164            Person(id=id) 
     165        except: 
     166            pass 
     167    handexc = expose()(handexc) 
     168 
    161169def test_exc_rollback(): 
    162170    cherrypy.root = RbRoot() 
    163171    create_request('/doerr?id=24') 
     
    172180    print cherrypy.response.body[0] 
    173181    assert cherrypy.response.body[0] == '{"tg_flash": null}' 
    174182 
     183# Check that if the controller method catches a db exception, we don't still 
     184# raise an exception 
     185def test_exc_caught_rollback(): 
     186    cherrypy.root = RbRoot() 
     187    create_request('/handexc?id=27') 
     188    output = cherrypy.response.body[0] 
     189    print output 
     190    assert '<title>500 Internal error</title>' not in output 
     191 
    175192#-- 
    176193# Check for session freshness, ticket #1419 
    177194# It checks that changes made to the data in thread B are reflected in thread A.