#NEWLINE# @ patch ( 'simple_db_migrate.main.Main._get_migration_files_to_be_executed' , return_value = [ Migration ( file_name = '20090214115600_06_test_migration.migration' , version = '20090214115600' , sql_up = 'sql up 06' , sql_down = 'sql down 06' ) , Migration ( file_name = '20090214115500_05_test_migration.migration' , version = '20090214115500' , sql_up = 'sql up 05' , sql_down = 'sql down 05' ) ] ) #NEWLINE# @ patch ( 'simple_db_migrate.main.Main._execution_log' ) #NEWLINE# def test_it_should_execute_sql_commands_when_show_sql_only_is_not_set_and_is_down( self , _execution_log_mock , files_to_be_executed_mock ) : #NEWLINE# #INDENT# self . initial_config . update ( { #NEWLINE# #INDENT# 'schema_version' : '20090214115400' , #NEWLINE# 'label_version' : None , #NEWLINE# 'database_migrations_dir' : [ 'migrations' , '.' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# config = Config ( self . initial_config ) #NEWLINE# main = Main ( sgdb = Mock ( ** { #NEWLINE# #INDENT# 'change.return_value' : None , #NEWLINE# 'get_current_schema_version.return_value' : '20090214115600' , #NEWLINE# 'get_version_id_from_version_number.side_effect' : get_version_id_from_version_number_side_effect , #NEWLINE# #UNINDENT# } ) , config = config ) #NEWLINE# main . execute ( ) #NEWLINE# expected_calls = [ call ( '\nStarting DB migration on host/database "localhost/test" with user "user"...' , 'PINK' , log_level_limit = 1 ) , call ( '- Current version is: 20090214115600' , 'GREEN' , log_level_limit = 1 ) , call ( '- Destination version is: 20090214115400' , 'GREEN' , log_level_limit = 1 ) , call ( '\nStarting migration down!' , log_level_limit = 1 ) , call ( "*** versions: ['20090214115600', '20090214115500']\n" , 'CYAN' , log_level_limit = 1 ) , call ( '===== executing 20090214115600_06_test_migration.migration (down) =====' , log_level_limit = 1 ) , call ( '===== executing 20090214115500_05_test_migration.migration (down) =====' , log_level_limit = 1 ) , call ( '\nDone.\n' , 'PINK' , log_level_limit = 1 ) ] #NEWLINE# self . assertEqual ( expected_calls , _execution_log_mock . mock_calls ) #NEWLINE# files_to_be_executed_mock . assert_called_with ( '20090214115600' , '20090214115400' , False ) #NEWLINE# expected_calls = [ call ( 'sql down 06' , '20090214115600' , '20090214115600_06_test_migration.migration' , 'sql up 06' , 'sql down 06' , False , _execution_log_mock , None ) , call ( 'sql down 05' , '20090214115500' , '20090214115500_05_test_migration.migration' , 'sql up 05' , 'sql down 05' , False , _execution_log_mock , None ) ] #NEWLINE# self . assertEqual ( expected_calls , main . sgdb . change . mock_calls )