Example #1
0
    def test_migration_start(self):
        share = "fake_share"
        host = "fake_host"
        version = api_versions.APIVersion('2.29')
        manager = shares.ShareManager(
            api=fakes.FakeClient(api_version=version))

        with mock.patch.object(manager, "_action",
                               mock.Mock(return_value="fake")):
            result = manager.migration_start(
                share, host, force_host_assisted_migration=True,
                preserve_metadata=True, writable=True, nondisruptive=True,
                preserve_snapshots=True)
            manager._action.assert_called_once_with(
                'migration_start', share, {
                    "host": host,
                    "force_host_assisted_migration": True,
                    "preserve_metadata": True,
                    "writable": True,
                    "nondisruptive": True,
                    "preserve_snapshots": True,
                    "new_share_network_id": None,
                    "new_share_type_id": None,
                })

            self.assertEqual("fake", result)
Example #2
0
 def setUp(self):
     super(ShareGroupTypeAccessTest, self).setUp()
     self.manager = type_access.ShareGroupTypeAccessManager(
         fake.FakeClient())
     fake_group_type_access_info = {'id': fake.ShareGroupTypeAccess.id}
     self.share_group_type_access = type_access.ShareGroupTypeAccess(
         self.manager, fake_group_type_access_info, loaded=True)
Example #3
0
 def setUp(self):
     super(ShareNetworkTest, self).setUp()
     self.manager = share_networks.ShareNetworkManager(fakes.FakeClient())
     self.values = {
         'nova_net_id': 'fake_nova_net_id',
         'neutron_net_id': 'fake net id',
         'neutron_subnet_id': 'fake subnet id',
         'name': 'fake name',
         'description': 'new whatever',
     }
    def test_migration_cancel(self):
        share = "fake_share"
        manager = shares.ShareManager(api=fakes.FakeClient())

        with mock.patch.object(manager, "_action",
                               mock.Mock(return_value="fake")):
            result = manager.migration_cancel(share)

            manager._action.assert_called_once_with("migration_cancel", share)
            self.assertEqual("fake", result)
    def test_reset_task_state(self):
        share = "fake_share"
        state = "fake_state"
        manager = shares.ShareManager(api=fakes.FakeClient())

        with mock.patch.object(manager, "_action",
                               mock.Mock(return_value="fake")):
            result = manager.reset_task_state(share, state)

            manager._action.assert_called_once_with(
                "reset_task_state", share, {'task_state': state})
            self.assertEqual("fake", result)
Example #6
0
 def setUp(self):
     super(ShareGroupTypeTest, self).setUp()
     self.manager = types.ShareGroupTypeManager(fake.FakeClient())
     self.fake_group_specs = {'key1': 'value1', 'key2': 'value2'}
     self.fake_share_group_type_info = {
         'id': fake.ShareGroupType.id,
         'share_types': [fake.ShareType.id],
         'name': fake.ShareGroupType.name,
         'is_public': fake.ShareGroupType.is_public,
         'group_specs': self.fake_group_specs,
     }
     self.share_group_type = types.ShareGroupType(
         self.manager, self.fake_share_group_type_info, loaded=True)
Example #7
0
    def test_create(self, microversion):
        api_version = api_versions.APIVersion(microversion)
        values = self.values.copy()
        if (api_version >= api_versions.APIVersion("2.26")):
            del (values['nova_net_id'])
        body_expected = {share_networks.RESOURCE_NAME: values}

        manager = share_networks.ShareNetworkManager(
            fakes.FakeClient(api_version=api_version))
        with mock.patch.object(manager, '_create', fakes.fake_create):
            result = manager.create(**values)

            self.assertEqual(result['url'], share_networks.RESOURCES_PATH)
            self.assertEqual(result['resp_key'], share_networks.RESOURCE_NAME)
            self.assertEqual(body_expected, result['body'])
Example #8
0
    def test_update_share_network(self, microversion, share_nw):
        api_version = api_versions.APIVersion(microversion)
        values = self.values.copy()
        if (api_version >= api_versions.APIVersion("2.26")):
            del (values['nova_net_id'])
        body_expected = {share_networks.RESOURCE_NAME: values}

        manager = share_networks.ShareNetworkManager(
            fakes.FakeClient(api_version=api_version))
        with mock.patch.object(manager, '_update', fakes.fake_update):
            result = manager.update(share_nw, **values)
            id = share_nw.id if hasattr(share_nw, 'id') else share_nw
            self.assertEqual(result['url'], share_networks.RESOURCE_PATH % id)
            self.assertEqual(result['resp_key'], share_networks.RESOURCE_NAME)
            self.assertEqual(result['body'], body_expected)
#    under the License.

from unittest import mock

import ddt

from manilaclient import api_versions
from manilaclient import extension
from manilaclient.tests.unit import utils
from manilaclient.tests.unit.v2 import fakes
from manilaclient.v2 import share_export_locations

extensions = [
    extension.Extension('share_export_locations', share_export_locations),
]
cs = fakes.FakeClient(extensions=extensions)


@ddt.ddt
class ShareExportLocationsTest(utils.TestCase):
    def _get_manager(self, microversion):
        version = api_versions.APIVersion(microversion)
        mock_microversion = mock.Mock(api_version=version)
        return (share_export_locations.ShareExportLocationManager(
            api=mock_microversion))

    def test_list_of_export_locations(self):
        share_id = '1234'
        cs.share_export_locations.list(share_id, search_opts=None)
        cs.assert_called('GET', '/shares/%s/export_locations' % share_id)
 def setUp(self):
     super(SecurityServiceTest, self).setUp()
     self.manager = security_services.SecurityServiceManager(
         fakes.FakeClient())
Example #11
0
 def setUp(self):
     super(ShareGroupSnapshotManagerTest, self).setUp()
     self.manager = snapshots.ShareGroupSnapshotManager(fake.FakeClient())
# 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 unittest import mock

from manilaclient.common.apiclient import base as common_base
from manilaclient import exceptions
from manilaclient.tests.unit import utils
from manilaclient.tests.unit.v2 import fakes
from manilaclient.v2 import shares


cs = fakes.FakeClient()


class BaseTest(utils.TestCase):

    def test_resource_repr(self):
        r = common_base.Resource(None, dict(foo="bar", baz="spam"))
        self.assertEqual(repr(r), "<Resource baz=spam, foo=bar>")

    def test_eq(self):
        # Two resources of the same type with the same id: equal
        # The truth of r1==r2 does not imply that r1!=r2 is false in PY2.
        # Test that inequality operator is defined and that comparing equal
        # items returns False.
        r1 = common_base.Resource(None, {'id': 1, 'name': 'hi'})
        r2 = common_base.Resource(None, {'id': 1, 'name': 'hello'})
 def setUp(self):
     super(ShareGroupTypeAccessManagerTest, self).setUp()
     self.manager = type_access.ShareGroupTypeAccessManager(
         fake.FakeClient())
Example #14
0
 def setUp(self):
     super(ShareReplicasTest, self).setUp()
     microversion = api_versions.APIVersion("2.11")
     self.manager = share_replicas.ShareReplicaManager(
         fakes.FakeClient(api_version=microversion))
 def setUp(self):
     super(MessageTest, self).setUp()
     self.manager = messages.MessageManager(fake.FakeClient())
     self.message = messages.Message(self.manager, {'id': 'fake_id'})
     self.fake_kwargs = {'key': 'value'}
Example #16
0
 def setUp(self):
     super(ShareGroupManagerTest, self).setUp()
     self.manager = share_groups.ShareGroupManager(fake.FakeClient())
 def setUp(self):
     super(PoolManagerTest, self).setUp()
     self.manager = scheduler_stats.PoolManager(fakes.FakeClient())
 def setUp(self):
     super(MessageManagerTest, self).setUp()
     self.manager = messages.MessageManager(fake.FakeClient())
Example #19
0
 def setUp(self):
     super(ShareNetworkSubnetTest, self).setUp()
     self.manager = share_network_subnets.ShareNetworkSubnetManager(
         fakes.FakeClient())
Example #20
0
 def setUp(self):
     super(ShareGroupTypeManagerTest, self).setUp()
     self.manager = types.ShareGroupTypeManager(fake.FakeClient())
     self.fake_group_specs = {'key1': 'value1', 'key2': 'value2'}
Example #21
0
 def setUp(self):
     super(ShareGroupSnapshotTest, self).setUp()
     self.manager = snapshots.ShareGroupSnapshotManager(fake.FakeClient())
     self.share_group_snapshot = snapshots.ShareGroupSnapshot(
         self.manager, {'id': 'fake_id'})
     self.fake_kwargs = {'key': 'value'}
Example #22
0
 def setUp(self):
     super(ShareGroupTest, self).setUp()
     self.manager = share_groups.ShareGroupManager(fake.FakeClient())
     self.share_group = share_groups.ShareGroup(self.manager,
                                                {'id': 'fake_id'})
     self.fake_kwargs = {'key': 'value'}
 def setUp(self):
     super(ShareServerManagerTest, self).setUp()
     self.manager = share_servers.ShareServerManager(api=fakes.FakeClient())