本文整理汇总了Python中sync.Sync.show_regions方法的典型用法代码示例。如果您正苦于以下问题:Python Sync.show_regions方法的具体用法?Python Sync.show_regions怎么用?Python Sync.show_regions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sync.Sync
的用法示例。
在下文中一共展示了Sync.show_regions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestSync
# 需要导入模块: from sync import Sync [as 别名]
# 或者: from sync.Sync import show_regions [as 别名]
class TestSync(unittest.TestCase):
"""Class to test all methods but constructor and parallel sync"""
@patch('sync.GlanceSync', auto_spec=True)
def setUp(self, glancesync):
"""create constructor, mock with glancesync, Set a master region"""
self.regions = []
self.sync = Sync(self.regions)
self.glancesync = glancesync
config = {'return_value.master_region': 'MasterRegion'}
self.glancesync.configure_mock(**config)
def test_report_status(self):
"""check that calls to export_sync_region_status are done"""
self.sync.regions = ['region1', 'region2']
self.sync.report_status()
calls = [call('region1', ANY), call('region2', ANY)]
self.glancesync.return_value.export_sync_region_status.\
assert_has_calls(calls)
def test_sequential_sync(self):
"""check that calls to sync_region are done"""
self.sync.regions = ['region1', 'region2']
self.sync.sequential_sync(dry_run=True)
calls = [call('region1', dry_run=True), call('region2', dry_run=True)]
self.glancesync.return_value.sync_region.assert_has_calls(calls)
def test_show_regions(self):
"""check that calls to get_regions are done"""
targets = {'master': None, 'other_target': None}
config = {'return_value.targets': targets}
self.glancesync.configure_mock(**config)
self.sync.show_regions()
calls = [call(), call(target='other_target')]
self.glancesync.return_value.get_regions.assert_has_calls(calls)
@patch('sync.os')
@patch('sync.datetime')
def test_make_backup(self, datetime_mock, os_mock):
"""check make backup; calls are correct and mkdir is invoked with
right parameters"""
datetime_str = '2020-02-06T23:57:09.205378'
config = {'datetime.now.return_value.isoformat.return_value':
datetime_str}
datetime_mock.configure_mock(**config)
self.sync.make_backup()
dir_name = 'backup_glance_' + datetime_str
os_mock.mkdir.assert_called_with(dir_name)
self.glancesync.return_value.backup_glancemetadata_region.\
assert_called_with('MasterRegion', dir_name)