def test_private_url(self): ns = Namespace(name='namespace', data=self.valid_data) ns.data['nsName'] = 'nsName' ns.state.set('actions', 'install', 'ok') ns.api = MagicMock() ns._zerodb.schedule_action = MagicMock(return_value=task_mock('url')) assert ns.private_url() == 'url' ns._zerodb.schedule_action.assert_called_once_with( 'namespace_private_url', args={'name': 'nsName'})
def test_connection_info(self): ns = Namespace(name='namespace', data=self.valid_data) ns.state.set('actions', 'install', 'ok') ns.state.set('status', 'running', 'ok') ns.api = MagicMock() result = {'ip': '127.0.0.1', 'port': 9900} task = task_mock(result) ns._zerodb.schedule_action = MagicMock(return_value=task) assert ns.connection_info() == result ns._zerodb.schedule_action.assert_called_once_with('connection_info')
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_info(self): ns = Namespace(name='namespace', data=self.valid_data) ns.data['nsName'] = 'nsName' ns.state.set('actions', 'install', 'ok') ns.api = MagicMock() task = task_mock('info') ns._zerodb.schedule_action = MagicMock(return_value=task) assert ns.info() == 'info' ns._zerodb.schedule_action.assert_called_once_with( 'namespace_info', args={'name': ns.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, 'ns_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'
def test_install(self): ns = Namespace(name='namespace', data=self.valid_data) node = MagicMock() node.schedule_action = MagicMock(return_value=task_mock(('instance', 'nsName'))) ns.api = MagicMock() ns.api.services.get = MagicMock(return_value=node) args = { 'disktype': ns.data['diskType'].upper(), 'mode': ns.data['mode'], 'password': ns.data['password'], 'public': ns.data['public'], 'ns_size': ns.data['size'], 'name': ns.data['nsName'] } ns.install() node.schedule_action.assert_called_once_with('create_zdb_namespace', args) ns.state.check('actions', 'install', 'ok') assert ns.data['nsName'] == 'nsName' assert ns.data['zerodb'] == 'instance'