self.private_filepath = kwargs.get('private_filepath')
if not self.name:
- raise Exception('Name is a required attribute')
+ raise KeypairSettingsError('Name is a required attribute')
+
+
+class KeypairSettingsError(Exception):
+ """
+ Exception to be thrown when keypair settings are incorrect
+ """
import uuid
import os
-from snaps.openstack.create_keypairs import KeypairSettings, OpenStackKeypair
+from snaps.openstack.create_keypairs import (
+ KeypairSettings, OpenStackKeypair, KeypairSettingsError)
from snaps.openstack.tests.os_source_file_test import OSIntegrationTestCase
from snaps.openstack.utils import nova_utils
"""
def test_no_params(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(KeypairSettingsError):
KeypairSettings()
def test_empty_config(self):
- with self.assertRaises(Exception):
+ with self.assertRaises(KeypairSettingsError):
KeypairSettings(**dict())
def test_name_only(self):
def test_config_all(self):
settings = KeypairSettings(
**{'name': 'foo', 'public_filepath': '/foo/bar.pub',
- 'private_filepath': '/foo/bar'})
+ 'private_filepath': '/foo/bar'})
self.assertEqual('foo', settings.name)
self.assertEqual('/foo/bar.pub', settings.public_filepath)
self.assertEqual('/foo/bar', settings.private_filepath)