'Tests the get_keypair function.'

def test_get_keypair(self):

    my_pub_key = 'a    cool    public    key    string'
    my_key_name = 'mykey'
    my_key = mock.MagicMock()
    my_key.public_key = my_pub_key
    my_key.name = my_key_name
    self.nova_client.keypairs.get.side_effect = [my_key, nova_exceptions.NotFound(404)]
    self.assertEqual(my_key, self.nova_plugin.get_keypair(my_key_name))
    self.assertRaises(exception.EntityNotFound, self.nova_plugin.get_keypair, 'notakey')
    calls = [mock.call(my_key_name), mock.call('notakey')]
    self.nova_client.keypairs.get.assert_has_calls(calls)
