Skip to content

Commit

Permalink
Add unit test for keypair's api
Browse files Browse the repository at this point in the history
Add unit test for keypair's api in test_shell.py, just for v1.1,
not for v3, because of v3 inherits from v1.1.

Change-Id: Ibbad199449431b328091ef4b5e4b955ffcddc303
Closes-Bug: #1309986
  • Loading branch information
ugvddm committed Apr 18, 2014
1 parent 2598714 commit 02ee4fc
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions novaclient/tests/v1_1/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import fixtures
import mock
import six
from six.moves import builtins

import novaclient.client
from novaclient import exceptions
Expand Down Expand Up @@ -1939,6 +1940,33 @@ class FakeResources(object):
mock_system.assert_called_with("ssh -6 -p22 "
"root@2607:f0d0:1002::4 -1")

def test_keypair_add(self):
self.run_command('keypair-add test')
self.assert_called('POST', '/os-keypairs',
{'keypair':
{'name': 'test'}})

@mock.patch.object(builtins, 'open',
mock.mock_open(read_data='FAKE_PUBLIC_KEY'))
def test_keypair_import(self):
self.run_command('keypair-add --pub-key test.pub test')
self.assert_called('POST', '/os-keypairs',
{'keypair':
{'public_key': 'FAKE_PUBLIC_KEY',
'name': 'test'}})

def test_keypair_list(self):
self.run_command('keypair-list')
self.assert_called('GET', '/os-keypairs')

def test_keypair_show(self):
self.run_command('keypair-show test')
self.assert_called('GET', '/os-keypairs/test')

def test_keypair_delete(self):
self.run_command('keypair-delete test')
self.assert_called('DELETE', '/os-keypairs/test')


class GetSecgroupTest(utils.TestCase):
def test_with_integer(self):
Expand Down

0 comments on commit 02ee4fc

Please sign in to comment.