<s> import pytest <EOL> from webtest import TestApp <EOL> from pyramid . config import Configurator <EOL> from pyramid . testing import DummyRequest <EOL> from pyramid_sqlalchemy import Session <EOL> from resource_sql import BalloonModel <EOL> from resource_sql import BalloonResource <EOL> from rest_toolkit . ext . sql import _column_keys <EOL> def make_app ( config ) : <EOL> return TestApp ( config . make_wsgi_app ( ) ) <EOL> def test_column_keys ( ) : <EOL> keys = _column_keys ( BalloonResource . context_query ) <EOL> assert set ( keys ) == { ( True , '<STR_LIT:id>' ) , ( False , '<STR_LIT>' ) } <EOL> @ pytest . mark . usefixtures ( '<STR_LIT>' ) <EOL> def test_unknown_id ( ) : <EOL> config = Configurator ( ) <EOL> config . include ( '<STR_LIT>' ) <EOL> config . scan ( '<STR_LIT>' ) <EOL> app = make_app ( config ) <EOL> r = app . get ( '<STR_LIT>' , status = <NUM_LIT> ) <EOL> @ pytest . mark . usefixtures ( '<STR_LIT>' ) <EOL> def test_known_id ( ) : <EOL> balloon = BalloonModel ( figure = u'<STR_LIT>' ) <EOL> Session . add ( balloon ) <EOL> Session . flush ( ) <EOL> config = Configurator ( ) <EOL> config . include ( '<STR_LIT>' ) <EOL> config . scan ( '<STR_LIT>' ) <EOL> app = make_app ( config ) <EOL> r = app . get ( '<STR_LIT>' % balloon . id ) <EOL> assert r . json [ '<STR_LIT>' ] == u'<STR_LIT>' <EOL> @ pytest . mark . usefixtures ( '<STR_LIT>' ) <EOL> def test_update_instance ( ) : <EOL> balloon = BalloonModel ( figure = u'<STR_LIT>' ) <EOL> Session . add ( balloon ) <EOL> Session . flush ( ) <EOL> request = DummyRequest ( matchdict = { '<STR_LIT:id>' : balloon . id } ) <EOL> resource = BalloonResource ( request ) <EOL> resource . update_from_dict ( { '<STR_LIT>' : u'<STR_LIT>' } ) <EOL> assert balloon . figure == u'<STR_LIT>' </s>
