<s> """<STR_LIT>""" <EOL> import pytest <EOL> from sqlalchemy import Column , Integer , String , create_engine <EOL> from sqlalchemy . ext . declarative import declarative_base <EOL> from sqlalchemy . orm import sessionmaker <EOL> from nameko . rpc import rpc <EOL> from nameko . testing . services import worker_factory <EOL> from nameko_sqlalchemy import Session <EOL> Base = declarative_base ( ) <EOL> class Result ( Base ) : <EOL> __tablename__ = '<STR_LIT>' <EOL> id = Column ( Integer , primary_key = True ) <EOL> value = Column ( String ( <NUM_LIT:64> ) ) <EOL> class Service ( object ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> db = Session ( Base ) <EOL> @ rpc <EOL> def save ( self , value ) : <EOL> result = Result ( value = value ) <EOL> self . db . add ( result ) <EOL> self . db . commit ( ) <EOL> @ pytest . fixture <EOL> def session ( ) : <EOL> """<STR_LIT>""" <EOL> engine = create_engine ( '<STR_LIT>' ) <EOL> Base . metadata . create_all ( engine ) <EOL> session_cls = sessionmaker ( bind = engine ) <EOL> return session_cls ( ) <EOL> def test_service ( session ) : <EOL> service = worker_factory ( Service , db = session ) <EOL> service . save ( "<STR_LIT>" ) <EOL> assert session . query ( Result . value ) . all ( ) == [ ( "<STR_LIT>" , ) ] </s>
