diff options
| author | Anindita Das <anindita.das@intel.com> | 2016-10-05 15:57:53 +0000 |
|---|---|---|
| committer | Anindita Das <anindita.das@intel.com> | 2017-02-22 02:45:51 +0000 |
| commit | edaeece7f144545bff9a7b00fccd2ec598ee2144 (patch) | |
| tree | fd8dc3f06a6652b8712fa6756100460be08ea358 /openstackclient/tests/unit/network/v2/fakes.py | |
| parent | 62938c02e077049e3e4ebb393045ba0fa783c72d (diff) | |
| download | python-openstackclient-edaeece7f144545bff9a7b00fccd2ec598ee2144.tar.gz | |
OSC Network Flavor
Implements Neutron feature of Network Flavor into OpenstackClient
This patch implements the following commands:
network flavor create
network flavor delete
network flavor list
network flavor show
network flavor set
Works with openstacksdk version 0.9.8
Change-Id: I29d7a62341010a1d067a8ca93bccb7d9b8d4c425
Partially-Implements: blueprint neutron-client-flavors
Partially-Implements: blueprint network-commands-options
Diffstat (limited to 'openstackclient/tests/unit/network/v2/fakes.py')
| -rw-r--r-- | openstackclient/tests/unit/network/v2/fakes.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/network/v2/fakes.py b/openstackclient/tests/unit/network/v2/fakes.py index dcecbeee..6a73b7e9 100644 --- a/openstackclient/tests/unit/network/v2/fakes.py +++ b/openstackclient/tests/unit/network/v2/fakes.py @@ -390,6 +390,69 @@ class FakeNetwork(object): return mock.Mock(side_effect=networks) +class FakeNetworkFlavor(object): + """Fake Network Flavor.""" + + @staticmethod + def create_one_network_flavor(attrs=None): + """Create a fake network flavor. + + :param Dictionary attrs: + A dictionary with all attributes + :return: + A FakeResource object faking the network flavor + """ + attrs = attrs or {} + + fake_uuid = uuid.uuid4().hex + network_flavor_attrs = { + 'description': 'network-flavor-description-' + fake_uuid, + 'enabled': True, + 'id': 'network-flavor-id-' + fake_uuid, + 'name': 'network-flavor-name-' + fake_uuid, + 'service_type': 'vpn', + 'tenant_id': 'project-id-' + uuid.uuid4().hex, + } + + # Overwrite default attributes. + network_flavor_attrs.update(attrs) + + network_flavor = fakes.FakeResource( + info=copy.deepcopy(network_flavor_attrs), + loaded=True + ) + + network_flavor.project_id = network_flavor_attrs['tenant_id'] + network_flavor.is_enabled = network_flavor_attrs['enabled'] + + return network_flavor + + @staticmethod + def create_flavor(attrs=None, count=2): + """Create multiple fake network flavors. + + :param Dictionary attrs: + A dictionary with all attributes + :param int count: + The number of network flavors to fake + :return: + A list of FakeResource objects faking the network falvors + """ + network_flavors = [] + for i in range(0, count): + network_flavors.append( + FakeNetworkFlavor.create_one_network_flavor(attrs) + ) + return network_flavors + + @staticmethod + def get_flavor(network_flavors=None, count=2): + """Get a list of flavors.""" + if network_flavors is None: + network_flavors = (FakeNetworkFlavor.create_flavor(count)) + return mock.Mock(side_effect=network_flavors) + + class FakeNetworkSegment(object): """Fake one or more network segments.""" |
