Пример #1
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 patronclient import extension
from patronclient.tests.unit import utils
from patronclient.tests.unit.v2.contrib import fakes
from patronclient.v2.contrib import baremetal


extensions = [
    extension.Extension(baremetal.__name__.split(".")[-1], baremetal),
]
cs = fakes.FakeClient(extensions=extensions)


class BaremetalExtensionTest(utils.TestCase):

    def test_list_nodes(self):
        nl = cs.baremetal.list()
        cs.assert_called('GET', '/os-baremetal-nodes')
        for n in nl:
            self.assertIsInstance(n, baremetal.BareMetalNode)

    def test_get_node(self):
        n = cs.baremetal.get(1)
        cs.assert_called('GET', '/os-baremetal-nodes/1')
#    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.
"""
External event triggering for servers, not to be used by users.
"""

from patronclient import extension
from patronclient.tests.unit import utils
from patronclient.tests.unit.v2.contrib import fakes
from patronclient.v2.contrib import server_external_events as ext_events

extensions = [
    extension.Extension(ext_events.__name__.split(".")[-1], ext_events),
]
cs = fakes.FakeClient(extensions=extensions)


class ServerExternalEventsTestCase(utils.TestCase):
    def test_external_event(self):
        events = [{
            'server_uuid': 'fake-uuid1',
            'name': 'test-event',
            'status': 'completed',
            'tag': 'tag'
        }, {
            'server_uuid': 'fake-uuid2',
            'name': 'test-event',
            'status': 'completed',
#    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.
"""
Assisted volume snapshots - to be used by Cinder and not end users.
"""

from patronclient import extension
from patronclient.tests.unit import utils
from patronclient.tests.unit.v2.contrib import fakes
from patronclient.v2.contrib import assisted_volume_snapshots as assisted_snaps

extensions = [
    extension.Extension(
        assisted_snaps.__name__.split(".")[-1], assisted_snaps),
]
cs = fakes.FakeClient(extensions=extensions)


class AssistedVolumeSnapshotsTestCase(utils.TestCase):
    def test_create_snap(self):
        cs.assisted_volume_snapshots.create('1', {})
        cs.assert_called('POST', '/os-assisted-volume-snapshots')

    def test_delete_snap(self):
        cs.assisted_volume_snapshots.delete('x', {})
        cs.assert_called('DELETE',
                         '/os-assisted-volume-snapshots/x?delete_info={}')
Пример #4
0
#
#         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 patronclient import extension
from patronclient.tests.unit import utils
from patronclient.tests.unit.v2 import fakes
from patronclient.v2.contrib import migrations

extensions = [
    extension.Extension(migrations.__name__.split(".")[-1], migrations),
]
cs = fakes.FakeClient(extensions=extensions)


class MigrationsTest(utils.TestCase):
    def test_list_migrations(self):
        ml = cs.migrations.list()
        cs.assert_called('GET', '/os-migrations')
        for m in ml:
            self.assertIsInstance(m, migrations.Migration)

    def test_list_migrations_with_filters(self):
        ml = cs.migrations.list('host1', 'finished', 'child1')

        cs.assert_called(
Пример #5
0
#
#         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 patronclient import extension
from patronclient.tests.unit import utils
from patronclient.tests.unit.v2.contrib import fakes
from patronclient.v2.contrib import tenant_networks

extensions = [
    extension.Extension(
        tenant_networks.__name__.split(".")[-1], tenant_networks),
]
cs = fakes.FakeClient(extensions=extensions)


class TenantNetworkExtensionTests(utils.TestCase):
    def test_list_tenant_networks(self):
        nets = cs.tenant_networks.list()
        cs.assert_called('GET', '/os-tenant-networks')
        self.assertTrue(len(nets) > 0)

    def test_get_tenant_network(self):
        cs.tenant_networks.get(1)
        cs.assert_called('GET', '/os-tenant-networks/1')

    def test_create_tenant_networks(self):
Пример #6
0
#    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 patronclient import extension
from patronclient.tests.unit import utils
from patronclient.tests.unit.v2 import fakes
from patronclient.v2.contrib import list_extensions

extensions = [
    extension.Extension(
        list_extensions.__name__.split(".")[-1], list_extensions),
]
cs = fakes.FakeClient(extensions=extensions)


class ListExtensionsTests(utils.TestCase):
    def test_list_extensions(self):
        all_exts = cs.list_extensions.show_all()
        cs.assert_called('GET', '/extensions')
        self.assertTrue(len(all_exts) > 0)
        for r in all_exts:
            self.assertTrue(len(r.summary) > 0)
Пример #7
0
#
#         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 patronclient import extension
from patronclient.tests.unit import utils
from patronclient.tests.unit.v2.contrib import fakes
from patronclient.v2.contrib import instance_action

extensions = [
    extension.Extension(
        instance_action.__name__.split(".")[-1], instance_action),
]
cs = fakes.FakeClient(extensions=extensions)


class InstanceActionExtensionTests(utils.TestCase):
    def test_list_instance_actions(self):
        server_uuid = '1234'
        cs.instance_action.list(server_uuid)
        cs.assert_called('GET',
                         '/servers/%s/os-instance-actions' % server_uuid)

    def test_get_instance_action(self):
        server_uuid = '1234'
        request_id = 'req-abcde12345'
        cs.instance_action.get(server_uuid, request_id)