当前位置: 首页>>代码示例>>Python>>正文


Python Command._restore_backup方法代码示例

本文整理汇总了Python中dbbackup.management.commands.dbrestore.Command._restore_backup方法的典型用法代码示例。如果您正苦于以下问题:Python Command._restore_backup方法的具体用法?Python Command._restore_backup怎么用?Python Command._restore_backup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dbbackup.management.commands.dbrestore.Command的用法示例。


在下文中一共展示了Command._restore_backup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DbMongoRestoreCommandRestoreBackupTest

# 需要导入模块: from dbbackup.management.commands.dbrestore import Command [as 别名]
# 或者: from dbbackup.management.commands.dbrestore.Command import _restore_backup [as 别名]
class DbMongoRestoreCommandRestoreBackupTest(TestCase):
    def setUp(self):
        self.command = DbrestoreCommand()
        self.command.stdout = DEV_NULL
        self.command.uncompress = False
        self.command.decrypt = False
        self.command.backup_extension = 'bak'
        self.command.path = None
        self.command.filename = 'foofile'
        self.command.database = TEST_MONGODB
        self.command.passphrase = None
        self.command.interactive = True
        self.command.storage = get_storage()
        self.command.connector = MongoDumpConnector()
        self.command.database_name = 'mongo'
        self.command.servername = HOSTNAME
        HANDLED_FILES.clean()
        add_private_gpg()

    def test_mongo_settings_backup_command(self, mock_runcommands, *args):
        self.command.storage.file_read = TARED_FILE
        self.command.filename = TARED_FILE
        HANDLED_FILES['written_files'].append((TARED_FILE, open(TARED_FILE, 'rb')))
        self.command._restore_backup()
        self.assertTrue(mock_runcommands.called)
开发者ID:ZuluPro,项目名称:django-dbbackup,代码行数:27,代码来源:test_dbrestore.py

示例2: DbrestoreCommandRestoreBackupTest

# 需要导入模块: from dbbackup.management.commands.dbrestore import Command [as 别名]
# 或者: from dbbackup.management.commands.dbrestore.Command import _restore_backup [as 别名]
class DbrestoreCommandRestoreBackupTest(TestCase):
    def setUp(self):
        self.command = DbrestoreCommand()
        self.command.stdout = DEV_NULL
        self.command.uncompress = False
        self.command.decrypt = False
        self.command.backup_extension = 'bak'
        self.command.filename = 'foofile'
        self.command.database = TEST_DATABASE
        self.command.dbcommands = DBCommands(TEST_DATABASE)
        self.command.passphrase = None
        self.command.interactive = True
        self.command.storage = FakeStorage()
        HANDLED_FILES.clean()
        add_private_gpg()

    def tearDown(self):
        clean_gpg_keys()

    def test_no_filename(self, *args):
        # Prepare backup
        HANDLED_FILES['written_files'].append(
            (utils.filename_generate('foo'), BytesIO(b'bar')))
        # Check
        self.command.path = None
        self.command.filename = None
        self.command._restore_backup()

    def test_no_backup_found(self, *args):
        self.command.path = None
        self.command.filename = None
        with self.assertRaises(CommandError):
            self.command._restore_backup()

    def test_uncompress(self, *args):
        self.command.storage.file_read = COMPRESSED_FILE
        self.command.path = None
        self.command.filename = COMPRESSED_FILE
        HANDLED_FILES['written_files'].append((COMPRESSED_FILE, open(COMPRESSED_FILE, 'rb')))
        self.command.uncompress = True
        self.command._restore_backup()

    @patch('dbbackup.utils.getpass', return_value=None)
    def test_decrypt(self, *args):
        self.command.path = None
        self.command.decrypt = True
        self.command.filename = ENCRYPTED_FILE
        HANDLED_FILES['written_files'].append((ENCRYPTED_FILE, open(ENCRYPTED_FILE, 'rb')))
        self.command._restore_backup()

    def test_path(self, *args):
        self.command.path = COMPRESSED_FILE
        self.command._restore_backup()
开发者ID:CalPolyResDev,项目名称:django-dbbackup,代码行数:55,代码来源:test_dbrestore.py

示例3: DbrestoreCommandRestoreBackupTest

# 需要导入模块: from dbbackup.management.commands.dbrestore import Command [as 别名]
# 或者: from dbbackup.management.commands.dbrestore.Command import _restore_backup [as 别名]
class DbrestoreCommandRestoreBackupTest(TestCase):
    def setUp(self):
        self.command = DbrestoreCommand()
        self.command.stdout = DEV_NULL
        self.command.uncompress = False
        self.command.decrypt = False
        self.command.backup_extension = 'bak'
        self.command.filename = 'foofile'
        self.command.database = TEST_DATABASE
        self.command.passphrase = None
        self.command.interactive = True
        self.command.storage = FakeStorage()
        self.command.connector = get_connector()
        HANDLED_FILES.clean()

    def tearDown(self):
        clean_gpg_keys()

    def test_no_filename(self, *args):
        # Prepare backup
        HANDLED_FILES['written_files'].append(
            (utils.filename_generate('foo'), get_dump()))
        # Check
        self.command.path = None
        self.command.filename = None
        self.command._restore_backup()

    def test_no_backup_found(self, *args):
        self.command.path = None
        self.command.filename = None
        with self.assertRaises(CommandError):
            self.command._restore_backup()

    def test_uncompress(self, *args):
        self.command.path = None
        compressed_file, self.command.filename = utils.compress_file(get_dump(), get_dump_name())
        HANDLED_FILES['written_files'].append(
            (self.command.filename, compressed_file)
        )
        self.command.uncompress = True
        self.command._restore_backup()

    @patch('dbbackup.utils.getpass', return_value=None)
    def test_decrypt(self, *args):
        self.command.path = None
        self.command.decrypt = True
        encrypted_file, self.command.filename = utils.encrypt_file(get_dump(), get_dump_name())
        HANDLED_FILES['written_files'].append(
            (self.command.filename, encrypted_file)
        )
        self.command._restore_backup()

    def test_path(self, *args):
        temp_dump = get_dump()
        dump_path = mktemp()
        with open(dump_path, 'wb') as dump:
            copyfileobj(temp_dump, dump)
        self.command.path = dump.name
        self.command._restore_backup()
        self.command.decrypt = False
        self.command.filepath = get_dump_name()
        HANDLED_FILES['written_files'].append(
            (self.command.filepath, get_dump())
        )
        self.command._restore_backup()
开发者ID:Fisiu,项目名称:django-dbbackup,代码行数:67,代码来源:test_dbrestore.py


注:本文中的dbbackup.management.commands.dbrestore.Command._restore_backup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。