本文整理汇总了Python中mock.MagicMock.begin_install方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.begin_install方法的具体用法?Python MagicMock.begin_install怎么用?Python MagicMock.begin_install使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.MagicMock
的用法示例。
在下文中一共展示了MagicMock.begin_install方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _prepare_dynamic
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import begin_install [as 别名]
def _prepare_dynamic(self, device_path='/dev/vdb', is_db_installed=True,
backup_info=None):
mock_status = MagicMock()
self.manager.appStatus = mock_status
mock_status.begin_install = MagicMock(return_value=None)
volume.VolumeDevice.format = MagicMock(return_value=None)
volume.VolumeDevice.mount = MagicMock(return_value=None)
volume.VolumeDevice.mount_points = MagicMock(return_value=[])
couch_service.CouchbaseApp.install_if_needed = MagicMock(
return_value=None)
couch_service.CouchbaseApp.complete_install_or_restart = MagicMock(
return_value=None)
#invocation
self.manager.prepare(self.context, self.packages, None, 2048,
None, device_path=device_path,
mount_point='/var/lib/couchbase',
backup_info=backup_info)
#verification/assertion
mock_status.begin_install.assert_any_call()
couch_service.CouchbaseApp.install_if_needed.assert_any_call(
self.packages)
couch_service.CouchbaseApp.complete_install_or_restart.\
assert_any_call()
示例2: _prepare_dynamic
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import begin_install [as 别名]
def _prepare_dynamic(self, device_path='/dev/vdb', backup_id=None,
*mocks, **kwmocks):
# covering all outcomes is starting to cause trouble here
backup_info = {'id': backup_id,
'location': 'fake-location',
'type': 'CbBackup',
'checksum': 'fake-checksum'} if backup_id else None
mock_status = MagicMock()
mock_status.begin_install = MagicMock(return_value=None)
self.manager.appStatus = mock_status
instance_ram = 2048
mount_point = '/var/lib/couchbase'
self.manager.prepare(self.context, self.packages, None,
instance_ram, None, device_path=device_path,
mount_point=mount_point,
backup_info=backup_info,
overrides=None,
cluster_config=None)
# verification/assertion
mock_status.begin_install.assert_any_call()
kwmocks['install_if_needed'].assert_any_call(self.packages)
if backup_info:
backup.restore.assert_any_call(self.context,
backup_info,
mount_point)
示例3: _prepare_dynamic
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import begin_install [as 别名]
def _prepare_dynamic(self, device_path='/dev/vdb', is_redis_installed=True,
backup_info=None, is_root_enabled=False,
mount_point='var/lib/redis'):
# covering all outcomes is starting to cause trouble here
mock_status = MagicMock()
redis_service.RedisAppStatus.get = MagicMock(return_value=mock_status)
redis_service.RedisApp.start_redis = MagicMock(return_value=None)
redis_service.RedisApp.install_if_needed = MagicMock(return_value=None)
redis_service.RedisApp.write_config = MagicMock(return_value=None)
operating_system.update_owner = MagicMock(return_value=None)
redis_service.RedisApp.restart = MagicMock(return_value=None)
mock_status.begin_install = MagicMock(return_value=None)
VolumeDevice.format = MagicMock(return_value=None)
VolumeDevice.mount = MagicMock(return_value=None)
VolumeDevice.mount_points = MagicMock(return_value=[])
backup.restore = MagicMock(return_value=None)
self.manager.prepare(self.context, self.packages,
None, '2048',
None, device_path=device_path,
mount_point=mount_point,
backup_info=backup_info,
overrides=None,
cluster_config=None)
self.assertEqual(redis_service.RedisAppStatus.get.call_count, 2)
mock_status.begin_install.assert_any_call()
VolumeDevice.format.assert_any_call()
redis_service.RedisApp.install_if_needed.assert_any_call(self.packages)
redis_service.RedisApp.write_config.assert_any_call(None)
operating_system.update_owner.assert_any_call(
'redis', 'redis', mount_point)
redis_service.RedisApp.restart.assert_any_call()
示例4: _prepare_dynamic
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import begin_install [as 别名]
def _prepare_dynamic(self, packages,
config_content='MockContent', device_path='/dev/vdb',
backup_id=None,
overrides=None, is_mounted=False):
# covering all outcomes is starting to cause trouble here
expected_vol_count = 1 if device_path else 0
if not backup_id:
backup_info = {'id': backup_id,
'location': 'fake-location',
'type': 'InnoBackupEx',
'checksum': 'fake-checksum',
}
mock_status = MagicMock()
self.manager.appStatus = mock_status
mock_status.begin_install = MagicMock(return_value=None)
path_exists_function = MagicMock(return_value=True)
volume.VolumeDevice.format = MagicMock(return_value=None)
volume.VolumeDevice.migrate_data = MagicMock(return_value=None)
volume.VolumeDevice.mount = MagicMock(return_value=None)
mount_points = []
if is_mounted:
mount_points = ['/mnt']
VolumeDevice.mount_points = MagicMock(return_value=mount_points)
VolumeDevice.unmount = MagicMock(return_value=None)
VerticaApp.install_if_needed = MagicMock(return_value=None)
VerticaApp.install_vertica = MagicMock(return_value=None)
VerticaApp.create_db = MagicMock(return_value=None)
VerticaApp.prepare_for_install_vertica = MagicMock(return_value=None)
VerticaApp.complete_install_or_restart = MagicMock(return_value=None)
# invocation
self.manager.prepare(context=self.context, packages=packages,
config_contents=config_content,
databases=None,
memory_mb='2048', users=None,
device_path=device_path,
mount_point="/var/lib/vertica",
backup_info=backup_info,
overrides=None,
cluster_config=None,
path_exists_function=path_exists_function)
self.assertEqual(expected_vol_count, VolumeDevice.format.call_count)
self.assertEqual(expected_vol_count,
VolumeDevice.migrate_data.call_count)
self.assertEqual(expected_vol_count,
VolumeDevice.mount_points.call_count)
if is_mounted:
self.assertEqual(1, VolumeDevice.unmount.call_count)
else:
self.assertEqual(0, VolumeDevice.unmount.call_count)
VerticaApp.install_if_needed.assert_any_call(packages)
VerticaApp.prepare_for_install_vertica.assert_any_call()
VerticaApp.install_vertica.assert_any_call()
VerticaApp.create_db.assert_any_call()
VerticaApp.complete_install_or_restart.assert_any_call()
示例5: _prepare_dynamic
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import begin_install [as 别名]
def _prepare_dynamic(self, save_configuration_mock, chown_mock,
apply_initial_guestagent_configuration, restart,
install_if_needed,
device_path='/dev/vdb', is_redis_installed=True,
backup_info=None, is_root_enabled=False,
mount_point='var/lib/redis', backup_id=None,
snapshot=None):
backup_info = None
if backup_id is not None:
backup_info = {'id': backup_id,
'location': 'fake-location',
'type': 'RedisBackup',
'checksum': 'fake-checksum',
}
# covering all outcomes is starting to cause trouble here
mock_status = MagicMock()
self.manager._app.status = mock_status
self.manager._build_admin_client = MagicMock(return_value=MagicMock())
redis_service.RedisApp.stop_db = MagicMock(return_value=None)
redis_service.RedisApp.start_db = MagicMock(return_value=None)
mock_status.begin_install = MagicMock(return_value=None)
VolumeDevice.format = MagicMock(return_value=None)
VolumeDevice.mount = MagicMock(return_value=None)
VolumeDevice.mount_points = MagicMock(return_value=[])
backup.restore = MagicMock(return_value=None)
mock_replication = MagicMock()
mock_replication.enable_as_slave = MagicMock()
self.mock_repl.return_value = mock_replication
self.manager.prepare(self.context, self.packages,
None, '2048',
None, device_path=device_path,
mount_point=mount_point,
backup_info=backup_info,
overrides=None,
cluster_config=None,
snapshot=snapshot)
mock_status.begin_install.assert_any_call()
VolumeDevice.format.assert_any_call()
install_if_needed.assert_any_call(self.packages)
save_configuration_mock.assert_any_call(None)
apply_initial_guestagent_configuration.assert_called_once_with()
chown_mock.assert_any_call(mount_point, 'redis', 'redis', as_root=True)
if backup_info:
backup.restore.assert_called_once_with(self.context,
backup_info,
'/var/lib/redis')
else:
redis_service.RedisApp.restart.assert_any_call()
if snapshot:
self.assertEqual(1, mock_replication.enable_as_slave.call_count)
else:
self.assertEqual(0, mock_replication.enable_as_slave.call_count)
示例6: _prepare_dynamic
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import begin_install [as 别名]
def _prepare_dynamic(self, packages=None, databases=None, users=None,
config_content=None, device_path='/dev/vdb',
is_db_installed=True, backup_id=None, overrides=None):
backup_info = {'id': backup_id,
'location': 'fake-location',
'type': 'DB2Backup',
'checksum': 'fake-checksum'} if backup_id else None
mock_status = MagicMock()
mock_app = MagicMock()
self.manager.appStatus = mock_status
self.manager.app = mock_app
mock_status.begin_install = MagicMock(return_value=None)
mock_app.change_ownership = MagicMock(return_value=None)
mock_app.restart = MagicMock(return_value=None)
mock_app.start_db = MagicMock(return_value=None)
mock_app.stop_db = MagicMock(return_value=None)
volume.VolumeDevice.format = MagicMock(return_value=None)
volume.VolumeDevice.mount = MagicMock(return_value=None)
volume.VolumeDevice.mount_points = MagicMock(return_value=[])
db2_service.DB2Admin.create_user = MagicMock(return_value=None)
db2_service.DB2Admin.create_database = MagicMock(return_value=None)
backup.restore = MagicMock(return_value=None)
with patch.object(pkg.Package, 'pkg_is_installed',
return_value=MagicMock(
return_value=is_db_installed)):
self.manager.prepare(context=self.context, packages=packages,
config_contents=config_content,
databases=databases,
memory_mb='2048', users=users,
device_path=device_path,
mount_point="/home/db2inst1/db2inst1",
backup_info=backup_info,
overrides=None,
cluster_config=None)
mock_status.begin_install.assert_any_call()
self.assertEqual(1, mock_app.change_ownership.call_count)
if databases:
self.assertTrue(db2_service.DB2Admin.create_database.called)
else:
self.assertFalse(db2_service.DB2Admin.create_database.called)
if users:
self.assertTrue(db2_service.DB2Admin.create_user.called)
else:
self.assertFalse(db2_service.DB2Admin.create_user.called)
if backup_id:
backup.restore.assert_any_call(self.context,
backup_info,
'/home/db2inst1/db2inst1')
示例7: _prepare_dynamic
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import begin_install [as 别名]
def _prepare_dynamic(self, packages,
config_content='MockContent', device_path='/dev/vdb',
is_db_installed=True, backup_id=None,
is_root_enabled=False,
overrides=None):
# covering all outcomes is starting to cause trouble here
if not backup_id:
backup_info = {'id': backup_id,
'location': 'fake-location',
'type': 'InnoBackupEx',
'checksum': 'fake-checksum',
}
mock_status = MagicMock()
mock_app = MagicMock()
mock_app.status = mock_status
self.manager._app = mock_app
mock_status.begin_install = MagicMock(return_value=None)
mock_app.install_if_needed = MagicMock(return_value=None)
mock_app.init_storage_structure = MagicMock(return_value=None)
mock_app.write_config = MagicMock(return_value=None)
mock_app.apply_initial_guestagent_configuration = MagicMock(
return_value=None)
mock_app.restart = MagicMock(return_value=None)
mock_app.start_db = MagicMock(return_value=None)
mock_app.stop_db = MagicMock(return_value=None)
os.path.exists = MagicMock(return_value=True)
volume.VolumeDevice.format = MagicMock(return_value=None)
volume.VolumeDevice.migrate_data = MagicMock(return_value=None)
volume.VolumeDevice.mount = MagicMock(return_value=None)
volume.VolumeDevice.mount_points = MagicMock(return_value=[])
with patch.object(pkg.Package, 'pkg_is_installed',
return_value=is_db_installed):
# invocation
self.manager.prepare(context=self.context, packages=packages,
config_contents=config_content,
databases=None,
memory_mb='2048', users=None,
device_path=device_path,
mount_point="/var/lib/cassandra",
backup_info=backup_info,
overrides=None,
cluster_config=None)
# verification/assertion
mock_status.begin_install.assert_any_call()
mock_app.install_if_needed.assert_any_call(packages)
mock_app.init_storage_structure.assert_any_call('/var/lib/cassandra')
mock_app.apply_initial_guestagent_configuration.assert_any_call()
mock_app.start_db.assert_any_call(update_db=False)
mock_app.stop_db.assert_any_call()
示例8: _prepare_dynamic
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import begin_install [as 别名]
def _prepare_dynamic(
self,
packages=None,
databases=None,
users=None,
config_content=None,
device_path="/dev/vdb",
is_db_installed=True,
backup_id=None,
overrides=None,
):
mock_status = MagicMock()
mock_app = MagicMock()
self.manager.appStatus = mock_status
self.manager.app = mock_app
mock_status.begin_install = MagicMock(return_value=None)
mock_app.change_ownership = MagicMock(return_value=None)
mock_app.restart = MagicMock(return_value=None)
mock_app.start_db = MagicMock(return_value=None)
mock_app.stop_db = MagicMock(return_value=None)
volume.VolumeDevice.format = MagicMock(return_value=None)
volume.VolumeDevice.mount = MagicMock(return_value=None)
volume.VolumeDevice.mount_points = MagicMock(return_value=[])
db2_service.DB2Admin.create_user = MagicMock(return_value=None)
db2_service.DB2Admin.create_database = MagicMock(return_value=None)
with patch.object(pkg.Package, "pkg_is_installed", return_value=MagicMock(return_value=is_db_installed)):
self.manager.prepare(
context=self.context,
packages=packages,
config_contents=config_content,
databases=databases,
memory_mb="2048",
users=users,
device_path=device_path,
mount_point="/home/db2inst1/db2inst1",
backup_info=None,
overrides=None,
cluster_config=None,
)
mock_status.begin_install.assert_any_call()
self.assertEqual(1, mock_app.change_ownership.call_count)
if databases:
self.assertTrue(db2_service.DB2Admin.create_database.called)
else:
self.assertFalse(db2_service.DB2Admin.create_database.called)
if users:
self.assertTrue(db2_service.DB2Admin.create_user.called)
else:
self.assertFalse(db2_service.DB2Admin.create_user.called)
示例9: _prepare_dynamic
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import begin_install [as 别名]
def _prepare_dynamic(self, packages=None, databases=None,
config_content=None, device_path='/dev/vdb',
is_db_installed=True, backup_id=None,
overrides=None):
mock_status = MagicMock()
mock_app = MagicMock()
self.manager.appStatus = mock_status
self.manager.app = mock_app
mount_point = '/var/lib/couchdb'
mock_status.begin_install = MagicMock(return_value=None)
mock_app.install_if_needed = MagicMock(return_value=None)
mock_app.make_host_reachable = MagicMock(return_value=None)
mock_app.restart = MagicMock(return_value=None)
mock_app.start_db = MagicMock(return_value=None)
mock_app.stop_db = MagicMock(return_value=None)
os.path.exists = MagicMock(return_value=True)
volume.VolumeDevice.format = MagicMock(return_value=None)
volume.VolumeDevice.migrate_data = MagicMock(return_value=None)
volume.VolumeDevice.mount = MagicMock(return_value=None)
volume.VolumeDevice.mount_points = MagicMock(return_value=[])
backup.restore = MagicMock(return_value=None)
backup_info = {'id': backup_id,
'location': 'fake-location',
'type': 'CouchDBBackup',
'checksum': 'fake-checksum'} if backup_id else None
couchdb_service.CouchDBAdmin.create_database = MagicMock(
return_value=None)
couchdb_service.CouchDBAdmin.create_user = MagicMock(return_value=None)
with patch.object(pkg.Package, 'pkg_is_installed',
return_value=MagicMock(
return_value=is_db_installed)):
self.manager.prepare(context=self.context, packages=packages,
config_contents=config_content,
databases=databases,
memory_mb='2048', users=None,
device_path=device_path,
mount_point=mount_point,
backup_info=backup_info,
overrides=None,
cluster_config=None)
# verification/assertion
mock_status.begin_install.assert_any_call()
mock_app.install_if_needed.assert_any_call(packages)
mock_app.make_host_reachable.assert_any_call()
mock_app.change_permissions.assert_any_call()
if backup_id:
backup.restore.assert_any_call(self.context,
backup_info,
mount_point)
示例10: _prepare_dynamic
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import begin_install [as 别名]
def _prepare_dynamic(self, packages,
config_content='MockContent', device_path='/dev/vdb',
is_db_installed=True, backup_info=None,
is_root_enabled=False,
overrides=None):
mock_status = MagicMock()
mock_app = MagicMock()
mock_app.status = mock_status
self.manager._app = mock_app
mock_status.begin_install = MagicMock(return_value=None)
mock_app.install_if_needed = MagicMock(return_value=None)
mock_app.init_storage_structure = MagicMock(return_value=None)
mock_app.write_config = MagicMock(return_value=None)
mock_app.apply_initial_guestagent_configuration = MagicMock(
return_value=None)
mock_app.restart = MagicMock(return_value=None)
mock_app.start_db = MagicMock(return_value=None)
mock_app.stop_db = MagicMock(return_value=None)
mock_app._remove_system_tables = MagicMock(return_value=None)
os.path.exists = MagicMock(return_value=True)
volume.VolumeDevice.format = MagicMock(return_value=None)
volume.VolumeDevice.migrate_data = MagicMock(return_value=None)
volume.VolumeDevice.mount = MagicMock(return_value=None)
volume.VolumeDevice.mount_points = MagicMock(return_value=[])
with patch.object(pkg.Package, 'pkg_is_installed',
return_value=is_db_installed):
# invocation
self.manager.prepare(context=self.context, packages=packages,
config_contents=config_content,
databases=None,
memory_mb='2048', users=None,
device_path=device_path,
mount_point=self.__MOUNT_POINT,
backup_info=backup_info,
overrides=None,
cluster_config=None)
# verification/assertion
mock_status.begin_install.assert_any_call()
mock_app.install_if_needed.assert_any_call(packages)
mock_app._remove_system_tables.assert_any_call()
mock_app.init_storage_structure.assert_any_call('/var/lib/cassandra')
mock_app.apply_initial_guestagent_configuration.assert_any_call(
cluster_name=None)
mock_app.start_db.assert_any_call(update_db=False)
mock_app.stop_db.assert_any_call()
if backup_info:
mock_app._apply_post_restore_updates.assert_called_once_with(
backup_info)
示例11: _prepare_dynamic
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import begin_install [as 别名]
def _prepare_dynamic(self, device_path="/dev/vdb", is_db_installed=True, backup_id=None):
# covering all outcomes is starting to cause trouble here
backup_info = (
{"id": backup_id, "location": "fake-location", "type": "MongoDump", "checksum": "fake-checksum"}
if backup_id
else None
)
mock_status = MagicMock()
mock_app = MagicMock()
self.manager.status = mock_status
self.manager.app = mock_app
mock_status.begin_install = MagicMock(return_value=None)
volume.VolumeDevice.format = MagicMock(return_value=None)
volume.VolumeDevice.migrate_data = MagicMock(return_value=None)
volume.VolumeDevice.mount = MagicMock(return_value=None)
volume.VolumeDevice.mount_points = MagicMock(return_value=[])
backup.restore = MagicMock(return_value=None)
mock_app.stop_db = MagicMock(return_value=None)
mock_app.start_db = MagicMock(return_value=None)
mock_app.clear_storage = MagicMock(return_value=None)
os.path.exists = MagicMock(return_value=is_db_installed)
with patch.object(utils, "execute_with_timeout"):
# invocation
self.manager.prepare(
context=self.context,
databases=None,
packages=["package"],
memory_mb="2048",
users=None,
device_path=device_path,
mount_point="/var/lib/mongodb",
backup_info=backup_info,
overrides=None,
cluster_config=None,
)
# verification/assertion
mock_status.begin_install.assert_any_call()
mock_app.install_if_needed.assert_any_call(["package"])
mock_app.stop_db.assert_any_call()
VolumeDevice.format.assert_any_call()
VolumeDevice.migrate_data.assert_any_call("/var/lib/mongodb")
if backup_info:
backup.restore.assert_any_call(self.context, backup_info, "/var/lib/mongodb")
示例12: _prepare_dynamic
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import begin_install [as 别名]
def _prepare_dynamic(
self,
packages,
config_content=None,
device_path="/dev/vdb",
is_db_installed=True,
backup_id=None,
overrides=None,
):
mock_status = MagicMock()
mock_app = MagicMock()
self.manager.appStatus = mock_status
self.manager.app = mock_app
mock_status.begin_install = MagicMock(return_value=None)
mock_app.install_if_needed = MagicMock(return_value=None)
mock_app.make_host_reachable = MagicMock(return_value=None)
mock_app.restart = MagicMock(return_value=None)
mock_app.start_db = MagicMock(return_value=None)
mock_app.stop_db = MagicMock(return_value=None)
os.path.exists = MagicMock(return_value=True)
volume.VolumeDevice.format = MagicMock(return_value=None)
volume.VolumeDevice.migrate_data = MagicMock(return_value=None)
volume.VolumeDevice.mount = MagicMock(return_value=None)
volume.VolumeDevice.mount_points = MagicMock(return_value=[])
with patch.object(pkg.Package, "pkg_is_installed", return_value=MagicMock(return_value=is_db_installed)):
self.manager.prepare(
context=self.context,
packages=packages,
config_contents=config_content,
databases=None,
memory_mb="2048",
users=None,
device_path=device_path,
mount_point="/var/lib/couchdb",
backup_info=None,
overrides=None,
cluster_config=None,
)
# verification/assertion
mock_status.begin_install.assert_any_call()
mock_app.install_if_needed.assert_any_call(packages)
mock_app.make_host_reachable.assert_any_call()
mock_app.change_permissions.assert_any_call()
示例13: _prepare_dynamic
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import begin_install [as 别名]
def _prepare_dynamic(self, device_path='/dev/vdb', is_db_installed=True,
backup_id=None):
# covering all outcomes is starting to cause trouble here
backup_info = {'id': backup_id,
'location': 'fake-location',
'type': 'MongoDump',
'checksum': 'fake-checksum'} if backup_id else None
mock_status = MagicMock()
mock_app = MagicMock()
self.manager.status = mock_status
self.manager.app = mock_app
mock_status.begin_install = MagicMock(return_value=None)
volume.VolumeDevice.format = MagicMock(return_value=None)
volume.VolumeDevice.migrate_data = MagicMock(return_value=None)
volume.VolumeDevice.mount = MagicMock(return_value=None)
volume.VolumeDevice.mount_points = MagicMock(return_value=[])
backup.restore = MagicMock(return_value=None)
mock_app.stop_db = MagicMock(return_value=None)
mock_app.start_db = MagicMock(return_value=None)
mock_app.clear_storage = MagicMock(return_value=None)
os.path.exists = MagicMock(return_value=is_db_installed)
self.manager.prepare(context=self.context, databases=None,
packages=['package'],
memory_mb='2048', users=None,
device_path=device_path,
mount_point='/var/lib/mongodb',
backup_info=backup_info,
overrides=None,
cluster_config=None)
# verification/assertion
mock_status.begin_install.assert_any_call()
mock_app.install_if_needed.assert_any_call(['package'])
mock_app.stop_db.assert_any_call()
VolumeDevice.format.assert_any_call()
VolumeDevice.migrate_data.assert_any_call('/var/lib/mongodb')
if backup_info:
backup.restore.assert_any_call(self.context,
backup_info,
'/var/lib/mongodb')
示例14: _prepare_dynamic
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import begin_install [as 别名]
def _prepare_dynamic(self, device_path='/dev/vdb', backup_id=None,
*mocks, **kwmocks):
# covering all outcomes is starting to cause trouble here
backup_info = {'id': backup_id,
'location': 'fake-location',
'type': 'CbBackup',
'checksum': 'fake-checksum'} if backup_id else None
mock_status = MagicMock()
mock_status.begin_install = MagicMock(return_value=None)
self.manager.app.status = mock_status
instance_ram = 2048
mount_point = '/var/lib/couchbase'
with patch.object(couch_service.CouchbaseApp, 'available_ram_mb',
new_callable=PropertyMock) as available_ram_mock:
available_ram_mock.return_value = instance_ram
self.manager.prepare(self.context, self.packages, None,
instance_ram, None, device_path=device_path,
mount_point=mount_point,
backup_info=backup_info,
overrides=None,
cluster_config=None)
# verification/assertion
mock_status.begin_install.assert_any_call()
storage_mock = kwmocks['init_storage_structure']
init_mock = kwmocks['initialize_node']
init_mock.assert_called_once_with()
storage_mock.assert_called_once_with(mount_point)
kwmocks['install_if_needed'].assert_any_call(self.packages)
if backup_info:
backup.restore.assert_called_once_with(self.context,
backup_info,
mount_point)
kwmocks['apply_post_restore_updates'].assert_called_once_with(
backup_info)
kwmocks['secure'].assert_called_once_with(initialize=True,
password=None)
示例15: _prepare_dynamic
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import begin_install [as 别名]
def _prepare_dynamic(self, device_path='/dev/vdb', backup_id=None):
# covering all outcomes is starting to cause trouble here
backup_info = {'id': backup_id,
'location': 'fake-location',
'type': 'CbBackup',
'checksum': 'fake-checksum'} if backup_id else None
mock_status = MagicMock()
self.manager.appStatus = mock_status
mock_status.begin_install = MagicMock(return_value=None)
volume.VolumeDevice.format = MagicMock(return_value=None)
volume.VolumeDevice.mount = MagicMock(return_value=None)
volume.VolumeDevice.mount_points = MagicMock(return_value=[])
couch_service.CouchbaseApp.install_if_needed = MagicMock(
return_value=None)
couch_service.CouchbaseApp.start_db_with_conf_changes = MagicMock(
return_value=None)
couch_service.CouchbaseApp.initial_setup = MagicMock(
return_value=None)
couch_service.CouchbaseApp.complete_install_or_restart = MagicMock(
return_value=None)
backup.restore = MagicMock(return_value=None)
#invocation
self.manager.prepare(self.context, self.packages, None, 2048,
None, device_path=device_path,
mount_point='/var/lib/couchbase',
backup_info=backup_info,
overrides=None,
cluster_config=None)
#verification/assertion
mock_status.begin_install.assert_any_call()
couch_service.CouchbaseApp.install_if_needed.assert_any_call(
self.packages)
couch_service.CouchbaseApp.complete_install_or_restart.\
assert_any_call()
if backup_info:
backup.restore.assert_any_call(self.context,
backup_info,
'/var/lib/couchbase')