Frédéric Guillot 02406a337a Add new volume commands: create, attach and detach
Change-Id: I2854e7f071108aa92e20bec9ca30ef9468aa383d
2017-05-29 13:52:41 -04:00

51 lines
2.0 KiB
Python

# Copyright 2017 INAP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from argparse import Namespace
import datetime
from unittest import mock
from almanachclient.commands.create_volume import CreateVolumeCommand
from almanachclient.tests import base
class TestCreateVolumeCommand(base.TestCase):
def setUp(self):
super().setUp()
self.app = mock.Mock()
self.app_args = mock.Mock()
self.args = Namespace(tenant_id='tenant uuid',
volume_id='volume uuid',
volume_type_id='volume type uuid',
volume_name='volume',
volume_size=2,
start='2017-01-01',
attachment=None)
self.client = mock.Mock()
self.app.get_client.return_value = self.client
self.command = CreateVolumeCommand(self.app, self.app_args)
def test_execute_command(self):
self.assertEqual('Success', self.command.take_action(self.args))
self.client.create_volume.assert_called_once_with('tenant uuid',
'volume uuid',
'volume type uuid',
'volume',
2,
start=datetime.datetime(2017, 1, 1, 0, 0),
attachments=None)