def test_uninstall(self): vdisk = Vdisk(name='vdisk', data=self.valid_data) vdisk.data['nsName'] = 'ns_name' vdisk.state.set('actions', 'install', 'ok') vdisk.api = MagicMock() vdisk.uninstall() vdisk._zerodb.schedule_action.assert_called_once_with( 'namespace_delete', args={'name': 'ns_name'})
def test_private_url(self): vdisk = Vdisk(name='vdisk', data=self.valid_data) vdisk.data['nsName'] = 'ns_name' vdisk.state.set('actions', 'install', 'ok') vdisk.api = MagicMock() vdisk._zerodb.schedule_action = MagicMock( return_value=task_mock('url')) assert vdisk.private_url() == 'url' vdisk._zerodb.schedule_action.assert_called_once_with( 'namespace_private_url', args={'name': 'ns_name'})
def test_info(self): vdisk = Vdisk(name='vdisk', data=self.valid_data) vdisk.data['nsName'] = 'ns_name' vdisk.state.set('actions', 'install', 'ok') vdisk.api = MagicMock() task = task_mock('info') vdisk._zerodb.schedule_action = MagicMock(return_value=task) assert vdisk.info() == 'info' vdisk._zerodb.schedule_action.assert_called_once_with( 'namespace_info', args={'name': vdisk.data['nsName']})
def test_install(self): vdisk = Vdisk(name='vdisk', data=self.valid_data) node = MagicMock() node.schedule_action = MagicMock(return_value=task_mock(('instance', 'ns_name'))) vdisk.api = MagicMock() vdisk.api.services.get = MagicMock(return_value=node) vdisk.install() args = { 'disktype': vdisk.data['diskType'].upper(), 'mode': 'user', 'password': vdisk.data['password'], 'public': False, 'size': int(vdisk.data['size']), } node.schedule_action.assert_called_once_with('create_zdb_namespace', args) vdisk.state.check('actions', 'install', 'ok') assert vdisk.data['nsName'] == 'ns_name' assert vdisk.data['zerodb'] == 'instance'