Skip to content

Commit 42b1698

Browse files
gtemastephenfin
authored andcommitted
Adopt sdk_fakes for compute.test_keypair
Change-Id: Ifb5df852a9ae6eea3fabce13d450b16cb8348315
1 parent d175dea commit 42b1698

2 files changed

Lines changed: 57 additions & 125 deletions

File tree

openstackclient/tests/unit/compute/v2/fakes.py

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from openstack.compute.v2 import extension as _extension
2626
from openstack.compute.v2 import flavor as _flavor
2727
from openstack.compute.v2 import hypervisor as _hypervisor
28-
from openstack.compute.v2 import keypair as _keypair
2928
from openstack.compute.v2 import limits as _limits
3029
from openstack.compute.v2 import migration as _migration
3130
from openstack.compute.v2 import server as _server
@@ -620,61 +619,6 @@ def create_one_flavor_access(attrs=None):
620619
return flavor_access
621620

622621

623-
def create_one_keypair(attrs=None):
624-
"""Create a fake keypair
625-
626-
:param dict attrs: A dictionary with all attributes
627-
:return: A fake openstack.compute.v2.keypair.Keypair object
628-
"""
629-
attrs = attrs or {}
630-
631-
# Set default attributes.
632-
keypair_info = {
633-
'name': 'keypair-name-' + uuid.uuid4().hex,
634-
'type': 'ssh',
635-
'fingerprint': 'dummy',
636-
'public_key': 'dummy',
637-
'user_id': 'user',
638-
}
639-
640-
# Overwrite default attributes.
641-
keypair_info.update(attrs)
642-
643-
return _keypair.Keypair(**keypair_info)
644-
645-
646-
def create_keypairs(attrs=None, count=2):
647-
"""Create multiple fake keypairs.
648-
649-
:param dict attrs: A dictionary with all attributes
650-
:param int count: The number of keypairs to fake
651-
:return: A list of fake openstack.compute.v2.keypair.Keypair objects
652-
"""
653-
654-
keypairs = []
655-
for i in range(0, count):
656-
keypairs.append(create_one_keypair(attrs))
657-
658-
return keypairs
659-
660-
661-
def get_keypairs(keypairs=None, count=2):
662-
"""Get an iterable MagicMock object with a list of faked keypairs.
663-
664-
If keypairs list is provided, then initialize the Mock object with the
665-
list. Otherwise create one.
666-
667-
:param list keypairs: A list of fake openstack.compute.v2.keypair.Keypair
668-
objects
669-
:param int count: The number of keypairs to fake
670-
:return: An iterable Mock object with side_effect set to a list of faked
671-
keypairs
672-
"""
673-
if keypairs is None:
674-
keypairs = create_keypairs(count)
675-
return mock.Mock(side_effect=keypairs)
676-
677-
678622
def create_one_availability_zone(attrs=None):
679623
"""Create a fake AZ.
680624

0 commit comments

Comments
 (0)