예제 #1
0
    def init_commands(self):
        self.cli = Application(orator_application.get_name(),
                               orator_application.get_version())

        self.cli.add(InstallCommand(self))
        self.cli.add(MigrateCommand(self))
        self.cli.add(MigrateMakeCommand(self))
        self.cli.add(RollbackCommand(self))
        self.cli.add(StatusCommand(self))
        self.cli.add(ResetCommand(self))
예제 #2
0
    def test_basic_migrations_call_migrator_with_proper_arguments(self):
        resolver = flexmock(DatabaseManager)
        resolver.should_receive('connection').and_return(None)

        migrator_mock = flexmock(Migrator)
        migrator_mock.should_receive('set_connection').once().with_args(None)
        migrator_mock.should_receive('run').once().with_args(
            os.path.join(os.getcwd(), 'migrations'), False)
        migrator_mock.should_receive('get_notes').and_return([])
        migrator_mock.should_receive('repository_exists').once().and_return(
            True)

        command = flexmock(MigrateCommand())
        command.should_receive('_get_config').and_return({})

        self.run_command(command, input_stream=self.get_input_stream('y\n'))
예제 #3
0
    def test_migration_can_be_forced(self):
        resolver = flexmock(DatabaseManager)
        resolver.should_receive("connection").and_return(None)

        migrator_mock = flexmock(Migrator)
        migrator_mock.should_receive("set_connection").once().with_args(None)
        migrator_mock.should_receive("run").once().with_args(
            os.path.join(os.getcwd(), "migrations"), False)
        migrator_mock.should_receive("get_notes").and_return([])
        migrator_mock.should_receive("repository_exists").once().and_return(
            True)

        command = flexmock(MigrateCommand())
        command.should_receive("_get_config").and_return({})

        self.run_command(command, [("--force", True)])
예제 #4
0
    def test_migration_can_be_forced(self):
        resolver = flexmock(DatabaseManager)
        resolver.should_receive('connection').and_return(None)

        migrator_mock = flexmock(Migrator)
        migrator_mock.should_receive('set_connection').once().with_args(None)
        migrator_mock.should_receive('run').once().with_args(
            os.path.join(os.getcwd(), 'migrations'), False)
        migrator_mock.should_receive('get_notes').and_return([])
        migrator_mock.should_receive('repository_exists').once().and_return(
            True)

        command = flexmock(MigrateCommand())
        command.should_receive('_get_config').and_return({})

        self.run_command(command, [('--force', True)])
예제 #5
0
    def test_basic_migrations_call_migrator_with_proper_arguments(self):
        resolver = flexmock(DatabaseManager)
        resolver.should_receive("connection").and_return(None)

        migrator_mock = flexmock(Migrator)
        migrator_mock.should_receive("set_connection").once().with_args(None)
        migrator_mock.should_receive("run").once().with_args(
            os.path.join(os.getcwd(), "migrations"), False)
        migrator_mock.should_receive("get_notes").and_return([])
        migrator_mock.should_receive("repository_exists").once().and_return(
            True)

        command = flexmock(MigrateCommand())
        command.should_receive("_get_config").and_return({})
        command.should_receive("confirm").and_return(True)

        self.run_command(command)
예제 #6
0
    def test_migration_repository_create_when_necessary(self):
        resolver = flexmock(DatabaseManager)
        resolver.should_receive('connection').and_return(None)

        migrator_mock = flexmock(Migrator)
        migrator_mock.should_receive('set_connection').once().with_args(None)
        migrator_mock.should_receive('run').once().with_args(
            os.path.join(os.getcwd(), 'migrations'), False)
        migrator_mock.should_receive('get_notes').and_return([])
        migrator_mock.should_receive('repository_exists').once().and_return(
            False)

        command = flexmock(MigrateCommand())
        command.should_receive('_get_config').and_return({})
        command.should_receive('call').once()\
            .with_args('migrate:install', [('--config', None)])

        self.run_command(command, input_stream=self.get_input_stream('y\n'))
예제 #7
0
    def test_migration_database_can_be_set(self):
        resolver = flexmock(DatabaseManager)
        resolver.should_receive("connection").and_return(None)

        migrator_mock = flexmock(Migrator)
        migrator_mock.should_receive("set_connection").once().with_args("foo")
        migrator_mock.should_receive("run").once().with_args(
            os.path.join(os.getcwd(), "migrations"), False)
        migrator_mock.should_receive("get_notes").and_return([])
        migrator_mock.should_receive("repository_exists").once().and_return(
            False)

        command = flexmock(MigrateCommand())
        command.should_receive("_get_config").and_return({})
        command.should_receive("confirm").and_return(True)
        command.should_receive("call").once().with_args(
            "migrate:install", [("--database", "foo"), ("--config", None)])

        self.run_command(command, [("--database", "foo")])
예제 #8
0
    def test_migration_database_can_be_set(self):
        resolver = flexmock(DatabaseManager)
        resolver.should_receive('connection').and_return(None)

        migrator_mock = flexmock(Migrator)
        migrator_mock.should_receive('set_connection').once().with_args('foo')
        migrator_mock.should_receive('run').once().with_args(
            os.path.join(os.getcwd(), 'migrations'), False)
        migrator_mock.should_receive('get_notes').and_return([])
        migrator_mock.should_receive('repository_exists').once().and_return(
            False)

        command = flexmock(MigrateCommand())
        command.should_receive('_get_config').and_return({})
        command.should_receive('confirm').and_return(True)
        command.should_receive('call').once()\
            .with_args('migrate:install', [('--database', 'foo'), ('--config', None)])

        self.run_command(command, [('--database', 'foo')])