summaryrefslogtreecommitdiffstats
path: root/snaps/openstack/tests/create_instance_tests.py
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2017-07-18 11:22:03 -0600
committerspisarski <s.pisarski@cablelabs.com>2017-07-18 11:22:03 -0600
commit7fc62c8ac1971224550f37674ec57325d7b50d08 (patch)
tree88de84815e8af1a2ed27891a85d83db160729ae7 /snaps/openstack/tests/create_instance_tests.py
parentacda399def76b37345f298c7df14ae2594cdc147 (diff)
Created custom exceptions for VM instance creation.
Created VmInstanceSettingsError for errors creating VmInstanceSettings objects Created FloatingIpSettingsError for errors creating FloatingIpSettings objects Created VmInstanceCreationError for errors creating VM instances JIRA: SNAPS-132 Change-Id: I588ae34bf066c8440755a8bf4f3721b946533d99 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/tests/create_instance_tests.py')
-rw-r--r--snaps/openstack/tests/create_instance_tests.py34
1 files changed, 18 insertions, 16 deletions
diff --git a/snaps/openstack/tests/create_instance_tests.py b/snaps/openstack/tests/create_instance_tests.py
index ebdb76a..66b83cb 100644
--- a/snaps/openstack/tests/create_instance_tests.py
+++ b/snaps/openstack/tests/create_instance_tests.py
@@ -20,12 +20,14 @@ import unittest
import uuid
import os
+from neutronclient.common.exceptions import InvalidIpForSubnetClient
from snaps import file_utils
from snaps.openstack.create_flavor import OpenStackFlavor, FlavorSettings
from snaps.openstack.create_image import OpenStackImage, ImageSettings
from snaps.openstack.create_instance import (
- VmInstanceSettings, OpenStackVmInstance, FloatingIpSettings)
+ VmInstanceSettings, OpenStackVmInstance, FloatingIpSettings,
+ VmInstanceSettingsError, FloatingIpSettingsError)
from snaps.openstack.create_keypairs import OpenStackKeypair, KeypairSettings
from snaps.openstack.create_network import OpenStackNetwork, PortSettings
from snaps.openstack.create_router import OpenStackRouter
@@ -50,27 +52,27 @@ class VmInstanceSettingsUnitTests(unittest.TestCase):
"""
def test_no_params(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(VmInstanceSettingsError):
VmInstanceSettings()
def test_empty_config(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(VmInstanceSettingsError):
VmInstanceSettings(config=dict())
def test_name_only(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(VmInstanceSettingsError):
VmInstanceSettings(name='foo')
def test_config_with_name_only(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(VmInstanceSettingsError):
VmInstanceSettings(config={'name': 'foo'})
def test_name_flavor_only(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(VmInstanceSettingsError):
VmInstanceSettings(name='foo', flavor='bar')
def test_config_with_name_flavor_only(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(VmInstanceSettingsError):
VmInstanceSettings(config={'name': 'foo', 'flavor': 'bar'})
def test_name_flavor_port_only(self):
@@ -175,35 +177,35 @@ class FloatingIpSettingsUnitTests(unittest.TestCase):
"""
def test_no_params(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(FloatingIpSettingsError):
FloatingIpSettings()
def test_empty_config(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(FloatingIpSettingsError):
FloatingIpSettings(**dict())
def test_name_only(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(FloatingIpSettingsError):
FloatingIpSettings(name='foo')
def test_config_with_name_only(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(FloatingIpSettingsError):
FloatingIpSettings(**{'name': 'foo'})
def test_name_port_only(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(FloatingIpSettingsError):
FloatingIpSettings(name='foo', port_name='bar')
def test_config_with_name_port_only(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(FloatingIpSettingsError):
FloatingIpSettings(**{'name': 'foo', 'port_name': 'bar'})
def test_name_router_only(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(FloatingIpSettingsError):
FloatingIpSettings(name='foo', router_name='bar')
def test_config_with_name_router_only(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(FloatingIpSettingsError):
FloatingIpSettings(**{'name': 'foo', 'router_name': 'bar'})
def test_name_port_router_only(self):
@@ -882,7 +884,7 @@ class CreateInstancePortManipulationTests(OSIntegrationTestCase):
self.os_creds, instance_settings,
self.image_creator.image_settings)
- with self.assertRaises(Exception):
+ with self.assertRaises(InvalidIpForSubnetClient):
self.inst_creator.create()
def test_set_custom_valid_mac(self):