From 7fc62c8ac1971224550f37674ec57325d7b50d08 Mon Sep 17 00:00:00 2001 From: spisarski Date: Tue, 18 Jul 2017 11:22:03 -0600 Subject: 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 --- snaps/openstack/tests/create_instance_tests.py | 34 ++++++++++++++------------ 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'snaps/openstack/tests/create_instance_tests.py') 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): -- cgit 1.2.3-korg