<s> import unittest <EOL> import transaction <EOL> from pyramid import testing <EOL> from . models import DBSession <EOL> class TestMyViewSuccessCondition ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . config = testing . setUp ( ) <EOL> from sqlalchemy import create_engine <EOL> engine = create_engine ( '<STR_LIT>' ) <EOL> from . models import ( <EOL> Base , <EOL> MyModel , <EOL> ) <EOL> DBSession . configure ( bind = engine ) <EOL> Base . metadata . create_all ( engine ) <EOL> with transaction . manager : <EOL> model = MyModel ( name = '<STR_LIT>' , value = <NUM_LIT> ) <EOL> DBSession . add ( model ) <EOL> def tearDown ( self ) : <EOL> DBSession . remove ( ) <EOL> testing . tearDown ( ) <EOL> def test_passing_view ( self ) : <EOL> from . views import my_view <EOL> request = testing . DummyRequest ( ) <EOL> info = my_view ( request ) <EOL> self . assertEqual ( info [ '<STR_LIT>' ] . name , '<STR_LIT>' ) <EOL> self . assertEqual ( info [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> class TestMyViewFailureCondition ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . config = testing . setUp ( ) <EOL> from sqlalchemy import create_engine <EOL> engine = create_engine ( '<STR_LIT>' ) <EOL> from . models import ( <EOL> Base , <EOL> MyModel , <EOL> ) <EOL> DBSession . configure ( bind = engine ) <EOL> def tearDown ( self ) : <EOL> DBSession . remove ( ) <EOL> testing . tearDown ( ) <EOL> def test_failing_view ( self ) : <EOL> from . views import my_view <EOL> request = testing . DummyRequest ( ) <EOL> info = my_view ( request ) <EOL> self . assertEqual ( info . status_int , <NUM_LIT> ) </s>
