<s> import unittest <EOL> import trac . tests . compat <EOL> from trac . db . mysql_backend import MySQLConnector <EOL> from trac . db . schema import Table , Column , Index <EOL> from trac . test import EnvironmentStub , Mock <EOL> class MySQLTableAlterationSQLTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . env = EnvironmentStub ( ) <EOL> def test_alter_column_types ( self ) : <EOL> connector = MySQLConnector ( self . env ) <EOL> sql = connector . alter_column_types ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : ( '<STR_LIT:int>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( '<STR_LIT:int>' , '<STR_LIT>' ) } ) <EOL> sql = list ( sql ) <EOL> self . assertEqual ( [ <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> ] , sql ) <EOL> def test_alter_column_types_same ( self ) : <EOL> connector = MySQLConnector ( self . env ) <EOL> sql = connector . alter_column_types ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : ( '<STR_LIT:int>' , '<STR_LIT:int>' ) , <EOL> '<STR_LIT>' : ( '<STR_LIT:int>' , '<STR_LIT>' ) } ) <EOL> sql = list ( sql ) <EOL> self . assertEqual ( [ <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> ] , sql ) <EOL> def test_alter_column_types_none ( self ) : <EOL> connector = MySQLConnector ( self . env ) <EOL> sql = connector . alter_column_types ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : ( '<STR_LIT:int>' , '<STR_LIT:int>' ) } ) <EOL> self . assertEqual ( [ ] , list ( sql ) ) <EOL> def test_utf8_size ( self ) : <EOL> connector = MySQLConnector ( self . env ) <EOL> self . assertEqual ( <NUM_LIT:3> , connector . _utf8_size ( Mock ( charset = '<STR_LIT:utf8>' ) ) ) <EOL> self . assertEqual ( <NUM_LIT:4> , connector . _utf8_size ( Mock ( charset = '<STR_LIT>' ) ) ) <EOL> def test_to_sql ( self ) : <EOL> connector = MySQLConnector ( self . env ) <EOL> tab = Table ( '<STR_LIT>' , key = ( '<STR_LIT>' , '<STR_LIT>' ) ) [ Column ( '<STR_LIT>' ) , <EOL> Column ( '<STR_LIT>' ) , <EOL> Index ( [ '<STR_LIT>' ] ) ] <EOL> sql = list ( connector . to_sql ( tab , utf8_size = <NUM_LIT:3> ) ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( sql ) ) <EOL> self . assertIn ( '<STR_LIT>' , sql [ <NUM_LIT:0> ] ) <EOL> self . assertIn ( '<STR_LIT>' , sql [ <NUM_LIT:1> ] ) <EOL> sql = list ( connector . to_sql ( tab , utf8_size = <NUM_LIT:4> ) ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( sql ) ) <EOL> self . assertIn ( '<STR_LIT>' , sql [ <NUM_LIT:0> ] ) <EOL> self . assertIn ( '<STR_LIT>' , sql [ <NUM_LIT:1> ] ) <EOL> def suite ( ) : <EOL> suite = unittest . TestSuite ( ) <EOL> suite . addTest ( unittest . makeSuite ( MySQLTableAlterationSQLTest ) ) <EOL> return suite <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( defaultTest = '<STR_LIT>' ) </s>
