<s> """<STR_LIT>""" <EOL> import pytest <EOL> from pyrseas . testutils import DatabaseToMapTestCase <EOL> from pyrseas . testutils import InputMapToSqlTestCase , fix_indent <EOL> CREATE_TABLE = "<STR_LIT>" <EOL> VIEW_STMT = "<STR_LIT>" <EOL> CREATE_STMT = "<STR_LIT>" + VIEW_STMT <EOL> COMMENT_STMT = "<STR_LIT>" <EOL> VIEW_DEFN = "<STR_LIT>" <EOL> class MatViewToMapTestCase ( DatabaseToMapTestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_map_view ( self ) : <EOL> "<STR_LIT>" <EOL> if self . db . version < <NUM_LIT> : <EOL> self . skipTest ( '<STR_LIT>' ) <EOL> stmts = [ CREATE_TABLE , CREATE_STMT ] <EOL> dbmap = self . to_map ( stmts ) <EOL> expmap = { '<STR_LIT>' : VIEW_DEFN , '<STR_LIT>' : True } <EOL> assert dbmap [ '<STR_LIT>' ] [ '<STR_LIT>' ] == expmap <EOL> def test_map_view_comment ( self ) : <EOL> "<STR_LIT>" <EOL> if self . db . version < <NUM_LIT> : <EOL> self . skipTest ( '<STR_LIT>' ) <EOL> dbmap = self . to_map ( [ CREATE_TABLE , CREATE_STMT , COMMENT_STMT ] ) <EOL> assert dbmap [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <EOL> '<STR_LIT:description>' ] == '<STR_LIT>' <EOL> def test_map_view_index ( self ) : <EOL> "<STR_LIT>" <EOL> if self . db . version < <NUM_LIT> : <EOL> self . skipTest ( '<STR_LIT>' ) <EOL> stmts = [ CREATE_TABLE , CREATE_STMT , <EOL> "<STR_LIT>" ] <EOL> dbmap = self . to_map ( stmts ) <EOL> expmap = { '<STR_LIT>' : VIEW_DEFN , '<STR_LIT>' : True , <EOL> '<STR_LIT>' : { '<STR_LIT>' : { '<STR_LIT>' : [ '<STR_LIT>' ] } } } <EOL> assert dbmap [ '<STR_LIT>' ] [ '<STR_LIT>' ] == expmap <EOL> class MatViewToSqlTestCase ( InputMapToSqlTestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_create_view ( self ) : <EOL> "<STR_LIT>" <EOL> if self . db . version < <NUM_LIT> : <EOL> self . skipTest ( '<STR_LIT>' ) <EOL> inmap = self . std_map ( ) <EOL> inmap [ '<STR_LIT>' ] . update ( { '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ { '<STR_LIT>' : { '<STR_LIT:type>' : '<STR_LIT>' } } , { '<STR_LIT>' : { '<STR_LIT:type>' : '<STR_LIT:text>' } } , <EOL> { '<STR_LIT>' : { '<STR_LIT:type>' : '<STR_LIT>' } } ] } } ) <EOL> inmap [ '<STR_LIT>' ] . update ( { '<STR_LIT>' : { <EOL> '<STR_LIT>' : "<STR_LIT>" } } ) <EOL> sql = self . to_sql ( inmap ) <EOL> assert fix_indent ( sql [ <NUM_LIT:0> ] ) == "<STR_LIT>" "<STR_LIT>" <EOL> assert fix_indent ( sql [ <NUM_LIT:1> ] ) == "<STR_LIT>" <EOL> def test_bad_view_map ( self ) : <EOL> "<STR_LIT>" <EOL> if self . db . version < <NUM_LIT> : <EOL> self . skipTest ( '<STR_LIT>' ) <EOL> inmap = self . std_map ( ) <EOL> inmap [ '<STR_LIT>' ] . update ( { '<STR_LIT>' : { '<STR_LIT>' : VIEW_DEFN } } ) <EOL> with pytest . raises ( KeyError ) : <EOL> self . to_sql ( inmap ) <EOL> def test_drop_view ( self ) : <EOL> "<STR_LIT>" <EOL> if self . db . version < <NUM_LIT> : <EOL> self . skipTest ( '<STR_LIT>' ) <EOL> stmts = [ "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ] <EOL> sql = self . to_sql ( self . std_map ( ) , stmts ) <EOL> assert sql [ <NUM_LIT:0> ] == "<STR_LIT>" <EOL> drt1 = <NUM_LIT:1> <EOL> drt2 = <NUM_LIT:2> <EOL> if '<STR_LIT>' in sql [ <NUM_LIT:2> ] : <EOL> drt1 = <NUM_LIT:2> <EOL> drt2 = <NUM_LIT:1> <EOL> assert sql [ drt1 ] == "<STR_LIT>" <EOL> assert sql [ drt2 ] == "<STR_LIT>" <EOL> def test_view_with_comment ( self ) : <EOL> "<STR_LIT>" <EOL> if self . db . version < <NUM_LIT> : <EOL> self . skipTest ( '<STR_LIT>' ) <EOL> inmap = self . std_map ( ) <EOL> inmap [ '<STR_LIT>' ] . update ( { '<STR_LIT>' : { <EOL> '<STR_LIT>' : VIEW_STMT , '<STR_LIT:description>' : "<STR_LIT>" } } ) <EOL> sql = self . to_sql ( inmap ) <EOL> assert fix_indent ( sql [ <NUM_LIT:0> ] ) == CREATE_STMT <EOL> assert sql [ <NUM_LIT:1> ] == COMMENT_STMT <EOL> def test_view_index ( self ) : <EOL> "<STR_LIT>" <EOL> if self . db . version < <NUM_LIT> : <EOL> self . skipTest ( '<STR_LIT>' ) <EOL> stmts = [ CREATE_TABLE , CREATE_STMT ] <EOL> inmap = self . std_map ( ) <EOL> inmap [ '<STR_LIT>' ] . update ( { '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ { '<STR_LIT>' : { '<STR_LIT:type>' : '<STR_LIT>' } } , { '<STR_LIT>' : { '<STR_LIT:type>' : '<STR_LIT:text>' } } , <EOL> { '<STR_LIT>' : { '<STR_LIT:type>' : '<STR_LIT>' } } ] } } ) <EOL> inmap [ '<STR_LIT>' ] . update ( { '<STR_LIT>' : { <EOL> '<STR_LIT>' : VIEW_DEFN , '<STR_LIT>' : { '<STR_LIT>' : { '<STR_LIT>' : [ '<STR_LIT>' ] } } } } ) <EOL> sql = self . to_sql ( inmap , stmts ) <EOL> print ( sql ) <EOL> assert sql == [ "<STR_LIT>" ] </s>
