<s> from flexmock import flexmock , flexmock_teardown <EOL> from orator . schema import Blueprint <EOL> from orator . schema . grammars import SchemaGrammar <EOL> from orator . connections import Connection <EOL> from . . import OratorTestCase <EOL> class SchemaBuilderTestCase ( OratorTestCase ) : <EOL> def tearDown ( self ) : <EOL> flexmock_teardown ( ) <EOL> def test_to_sql_runs_commands_from_blueprint ( self ) : <EOL> conn = flexmock ( Connection ( None ) ) <EOL> conn . should_receive ( '<STR_LIT>' ) . once ( ) . with_args ( '<STR_LIT:foo>' ) <EOL> conn . should_receive ( '<STR_LIT>' ) . once ( ) . with_args ( '<STR_LIT:bar>' ) <EOL> grammar = flexmock ( SchemaGrammar ( conn ) ) <EOL> blueprint = flexmock ( Blueprint ( '<STR_LIT>' ) ) <EOL> blueprint . should_receive ( '<STR_LIT>' ) . once ( ) . with_args ( conn , grammar ) . and_return ( [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] ) <EOL> blueprint . build ( conn , grammar ) <EOL> def test_index_default_names ( self ) : <EOL> blueprint = Blueprint ( '<STR_LIT>' ) <EOL> blueprint . unique ( [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] ) <EOL> commands = blueprint . get_commands ( ) <EOL> self . assertEqual ( '<STR_LIT>' , commands [ <NUM_LIT:0> ] . index ) <EOL> blueprint = Blueprint ( '<STR_LIT>' ) <EOL> blueprint . index ( '<STR_LIT:foo>' ) <EOL> commands = blueprint . get_commands ( ) <EOL> self . assertEqual ( '<STR_LIT>' , commands [ <NUM_LIT:0> ] . index ) <EOL> def test_drop_index_default_names ( self ) : <EOL> blueprint = Blueprint ( '<STR_LIT>' ) <EOL> blueprint . drop_unique ( [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] ) <EOL> commands = blueprint . get_commands ( ) <EOL> self . assertEqual ( '<STR_LIT>' , commands [ <NUM_LIT:0> ] . index ) <EOL> blueprint = Blueprint ( '<STR_LIT>' ) <EOL> blueprint . drop_index ( [ '<STR_LIT:foo>' ] ) <EOL> commands = blueprint . get_commands ( ) <EOL> self . assertEqual ( '<STR_LIT>' , commands [ <NUM_LIT:0> ] . index ) </s>
