diff options
| author | Ken Pepple <ken.pepple@gmail.com> | 2011-08-21 18:01:34 -0700 |
|---|---|---|
| committer | Ken Pepple <ken.pepple@gmail.com> | 2011-08-21 18:01:34 -0700 |
| commit | b5bf5fbb77e95b44f3254a111374ddba73016c4d (patch) | |
| tree | 85a997dc02a46109ae1a473dcb98342cd7aa987b /nova | |
| parent | 326cfda8cc50f5db083e9df381d3109e0302605d (diff) | |
added exception catch and test for bad project_id
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/ipv6/account_identifier.py | 2 | ||||
| -rw-r--r-- | nova/tests/test_ipv6.py | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/nova/ipv6/account_identifier.py b/nova/ipv6/account_identifier.py index 4ca7b5983..27bb01988 100644 --- a/nova/ipv6/account_identifier.py +++ b/nova/ipv6/account_identifier.py @@ -38,6 +38,8 @@ def to_global(prefix, mac, project_id): raise TypeError(_('Bad mac for to_global_ipv6: %s') % mac) except TypeError: raise TypeError(_('Bad prefix for to_global_ipv6: %s') % prefix) + except NameError: + raise TypeError(_('Bad project_id for to_global_ipv6: %s') % project_id) def to_mac(ipv6_address): diff --git a/nova/tests/test_ipv6.py b/nova/tests/test_ipv6.py index f9c2517a7..5c333b17e 100644 --- a/nova/tests/test_ipv6.py +++ b/nova/tests/test_ipv6.py @@ -67,3 +67,10 @@ class IPv6AccountIdentiferTestCase(test.TestCase): bad_prefix, '2001:db8::a94a:8fe5:ff33:4455', 'test') + + def test_to_global_with_bad_project(self): + bad_project = 'non-existent-project-name' + self.assertRaises(TypeError, ipv6.to_global, + '2001:db8::', + '2001:db8::a94a:8fe5:ff33:4455', + bad_project) |
