python-novaclient/tests/v1_1/test_keypairs.py
Brian Waldon a905e5fe07 Accept 1 and 2 as version choices
- removes all unused imports
- update .gitignore with new venv path

Change-Id: I3e8199b72dc83268115133d7c73335ffb6060f9a
2011-12-14 14:44:26 -05:00

34 lines
1.0 KiB
Python

from novaclient.v1_1 import keypairs
from tests import utils
from tests.v1_1 import fakes
cs = fakes.FakeClient()
class KeypairsTest(utils.TestCase):
def test_list_keypairs(self):
kps = cs.keypairs.list()
cs.assert_called('GET', '/os-keypairs')
[self.assertTrue(isinstance(kp, keypairs.Keypair)) for kp in kps]
def test_delete_keypair(self):
kp = cs.keypairs.list()[0]
kp.delete()
cs.assert_called('DELETE', '/os-keypairs/test')
cs.keypairs.delete('test')
cs.assert_called('DELETE', '/os-keypairs/test')
cs.keypairs.delete(kp)
cs.assert_called('DELETE', '/os-keypairs/test')
def test_create_keypair(self):
kp = cs.keypairs.create("foo")
cs.assert_called('POST', '/os-keypairs')
self.assertTrue(isinstance(kp, keypairs.Keypair))
def test_import_keypair(self):
kp = cs.keypairs.create("foo", "fake-public-key")
cs.assert_called('POST', '/os-keypairs')
self.assertTrue(isinstance(kp, keypairs.Keypair))