Commit Graph

65 Commits

Author SHA1 Message Date
Rodolfo Alonso Hernandez 4df5f2f41b [UT] Fix ``APIv2TestBase`` derived test classes
The method test calling ``_post_request`` with create or update
operations, were not properly patching the ML2 plugin
``create_network`` and `update_network`` methods. With
Python3.12, the mock object passed (instead of a dictionary with a
reduced network definition) don't have a ``__json__`` method and
fails during the encoding.

NOTE: this has been manually tested with Python3.12. Currently this
patch cannot be tested in the CI.

Closes-Bug: #2051928
Change-Id: Ie30af0c655d2f27d9039ff7933e81603047da6f4
2024-02-07 08:25:29 +00:00
Brian Haley e522d04668 Remove the SubresourceTest class
None of the tests in this class actually run, they
just generate a warning:

  SKIPPED: this class will be deleted

It was basically deprected in db1058a4 so let's just
remove it.

TrivialFix

Change-Id: I57d4771cbc3091c934dd58f6bef44e95548392ed
2023-11-30 18:02:40 -05:00
Slawek Kaplonski 670cc383e0 [S-RBAC] Switch to new policies by default
As part of the Secure RBAC community goal, we should switch options
"enforce_new_defaults" and "enforce_scope" to be True by default.
It will be still possible to fallback to old policy rules by configuring
those config options to False in Neutron config.

Change-Id: I09c0026ccf87e6c0bb1fa59165c03dc508fba6fa
2023-04-21 16:22:42 +02:00
Rajesh Tailor 8ab5ee1d17 Fix remaining typos in comments and tests
Change-Id: I872422cffd1f9a2e59b5e18a86695e5cb6edc2cd
2022-07-06 21:20:27 +05:30
Jakub Libosvar 8ccbbb2292 [quota] Enable ``DbQuotaDriverNull`` as a production driver
Enabled ``DbQuotaDriverNull`` as a productio quota database
quota driver. This driver does not enforce any quota nor have access
to the database. When using this quota driver, the API will return
the default empty values expected from the ``QuotaDriverAPI`` class.

Closes-bug: #1960032

Change-Id: Iafa24753e657746a8b8165b5a63c17de9a9ba791
Signed-off-by: Jakub Libosvar <libosvar@redhat.com>
Co-Authored-By: Rodolfo Alonso Hernandez <ralonsoh@redhat.com>
2022-04-05 10:10:46 +00:00
Nurmatov Mamatisa d0c871df19 Rename notify to publish in unit tests
After [1] patch merging all neutron code will be
switched to payload style callback[2].
Neutron-lib registry.notify can be depricated

1) https://review.opendev.org/c/openstack/neutron/+/806607
2)https://codesearch.openstack.org/?q=registry.notify&i=nope&literal=nope&files=&excludeFiles=&repos=

Change-Id: I5a549c4d09822659f7e4cdd08b085d856f3b65ed
2021-09-02 14:41:18 +00:00
Rodolfo Alonso Hernandez ad31c58d60 Remove ``ConfDriver`` code
The quota driver ``ConfDriver`` was deprecated in Liberty release.

``NullQuotaDriver`` is created for testing although it could be used
in production if no quota enforcement is needed. However, because
the Quota engine is not plugable (is an extension always loaded), it
could be interesting to make it plugable as any other plugin.

This patch also creates a Quota engine driver API class that should be
used in any Quota engine driver. Currently it is used in the three
in-tree drivers implemented: ``NullQuotaDriver``, ``DbQuotaDriver``
and ``DbQuotaNoLockDriver``.

Change-Id: Ib4af80e18fac52b9f68f26c84a215415e63c2822
Closes-Bug: #1928211
2021-07-26 15:00:32 +00:00
Rodolfo Alonso Hernandez ddd5832323 Remove "six" library
Last step to remove "six" library usage in Neutron.

Change-Id: Idd42e0c51c8c3bd598c9cf91602596be238bccae
2020-07-28 16:55:52 +00:00
Brian Haley 4f10c3bd3f Remove usage of six.text_type and six.string_type
With python 3.x, six.text_type and six.string_type
are just str.

Also removed a six.integer_type since it was the only
one left in a file.

Another step in removing all of six usage from neutron.

Change-Id: I5208dc41bff1983ecd323286f427296b722da62a
2020-05-22 14:02:55 -04:00
Brian Haley 7594bb0627 Remove the dependency on the "mock" package
Now that we are python3 only, we should move to using the built
in version of mock that supports all of our testing needs and
remove the dependency on the "mock" package.

This patch moves all references to "import mock" to
"from unittest import mock". It also cleans up some new line
inconsistency.

Fixed an inconsistency in the OVSBridge.deferred() definition
as it needs to also have an *args argument.

Fixed an issue where an l3-agent test was mocking
functools.partial, causing a python3.8 failure.

Unit tests only, removing from tests/base.py affects
functional tests which need additional work.

Change-Id: I40e8a8410840c3774c72ae1a8054574445d66ece
2020-04-28 18:05:37 -04:00
pandatt 335ac4e2d9 Fix bug: AttributeError arises while sorting with standard attributes
Common neutron resource(e.g, Port) consists of:
1. Resource Attributes, e.g: Port.mac_address, etc.
2. Standard Attributes, e.g: created_at, and are shared among all
   neutron resources.
The `sort` opt only supports limited attributes. We need to filter
attributes that are defined with `is_sort_key=True` and it's preferred
to explicitly warn CLI & API users of illegal sort keys rather than
just accept without check, pass forward and then hit a internal error
which's quite confusing.

Depends-on: https://review.opendev.org/#/c/660097/
Change-Id: I8d206f909b09f1279dfcdc25c39989a67bff93d5
Closes-Bug: #1659175
2019-05-29 17:58:51 +08:00
Boden R ee77344ac1 use api def ALIAS in supported_extension_aliases
Today a number of classes define their supported_extension_aliases
using static strings rather than API definition ALIASes. This patch
switches them to use the ALIAS where applicable.

Change-Id: I716270c68a9fcd850c3c26de31bc13ea16def23d
2019-04-08 08:30:20 -06:00
Doug Hellmann 2530ccff8f Upgrade pylint to a version that works with python3
Also fixed some six.moves errors as well.

Change-Id: I9783ee588de1ec4b91a665b9dc89fdba3e2d90df
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2018-10-04 18:03:25 +00:00
Boden R 4bd2f0e8f7 shim neutron rpc with neutron-lib
The common rpc and exceptions were rehomed into
neutron-lib with [1]. This patch shims those rehomed
modules in neutron to switch over to neutron-lib's
versions under the covers.

To do so:
- The rpc and common exceptions are changed to
reference their counterpart in neutron-lib effectively
swapping the impl over to neutron-lib.
- The fake_notifier is removed from neutron and lib's
version is used instead.
- The rpc tests are removed; they live in lib now.
- A few unit test related changes are required
including changing mock.patch to mock.patch.object,
changing the mock checks for a few UTs as they don't
quite work the same with the shim in place.
- Using the RPC fixture from neutron-lib rather than
that setup in neutron's base test class.

With this shim in place, consumers are effectively using
neutron-lib's RPC plumbing and thus we can move consumers
over to neutron-lib's version at will. Once all
consumers are moved over we can come back and remove
the RPC logic from neutron and follow-up with a consumption
patch.

NeutronLibImpact

[1] https://review.openstack.org/#/c/319328/

Change-Id: I87685be8764a152ac24366f13e190de9d4f6f8d8
2018-08-22 11:20:53 -06:00
Hongbin Lu 2b1d8ea4a2 Implement filter validation
Enforce validation on filter parameters on list requests.
If an API request contains an unknown or unsupported parameter,
the server will return a 400 response instead of silently ignoring
the invalid input.

In resource attributes map, all filter parameters are annotated by
the ``is_filter`` keyword. Attributes with is_filter set to True
are candidates for validation.

Enabling filter validation requires support from core plugin and
all service plugins so each plugin need to indicate if it supports
the validation by setting ``__filter_validation_support`` to True.
If this field is not set, the default is False and validation is
turned off. Right now, the ML2 plugin and all the in-tree service
plugin support filter validation. Out-of-tree plugins will have
filter validation disabled by default.

An API extension is introduced to allow API users to discover this
new API behavior. This feature can be disabled by cloud operators
if they choose to do that. If it is disabled, the extension won't
be presented.

Depends-On: Ic3ab5b3ffdc378d570678b9c967cb42b0c7a8a9b
Depends-On: I4397df1c35463a8b532afdc9c5d28b37224a37b4
Depends-On: I3f2e6e861adaeef81a1a5819a57b28f5c6281d80
Depends-On: I1189bc9a50308df5c7e18c329f3a1262c90b9e12
Depends-On: I057cd917628c77dd20c0ff7747936c3fec7b4844
Depends-On: I0b24a304cc3466a2c05426cdbb6f9d99f1797edd

Change-Id: I21bf8a752813802822fd9966dda6ab3b6c4abfdc
Partial-Bug: #1749820
2018-07-19 04:13:43 +00:00
Hongbin Lu d950949b90 Ensure request's object type is dict
Handle an edge case that API users send a POST/PUT request with
invalid data in request body.

Closes-Bug: #1780327
Change-Id: I3877c18a18ac506dc8f4a9ded2a18b53b9f6cfae
2018-07-05 21:02:54 +00:00
Hongbin Lu f213ba487b Populate project info before using it
Sorting and filtering will rely on the attributes information. It is
necessary to populate project info before using it to sort/filter.

Closes-Bug: #1765452
Change-Id: Ife90268530b6e86a0b0d213e4742a2ef81cb2395
2018-05-10 21:28:17 +00:00
Hongbin Lu a732bbf19e Support filter attribute with empty string
This will enable users to filter list of results with attributes
with empty value. For example, the request below will list
all unbound ports (unbound ports have blank device_id).

  GET "/ports?device_id="

APIImpact
Change-Id: I9001214de126eb888c2425b6a6275f59ec8478e7
Closes-Bug: #1749304
2018-05-02 20:05:11 +00:00
Isaku Yamahata 0063aa33c6 pecan.jsonify v1.3 adjustment
From pecan v1.3, pecan.jsonify uses json.Encoder unconditionally so that
jsonifying mock fails.
Pecan v1.2 uses simplejson.Encoder as encoder which accidentally encodes
MagicMock as {} due to check of '_asdict' attributes.
Since pecan.jsonify uses __json__ magic method when it's defined,
add __json__ method to mocks to return {} as json encode.

Closes-bug: #1754978
Change-Id: Iac955a7de2a1b66b5b56a73f5cc8a4e75150f82e
2018-04-18 15:37:20 +00:00
Boden R 44292f4c9a consume neutron-lib resources attr map
Today we shim the RESOURCE_ATTRIBUTE_MAP in neutron; it references the
equivelant in neutron-lib named RESOURCES.

This patch removes neutron's RESOURCE_ATTRIBUTE_MAP and cleans up
neutron.api.v2.attributes in prep to delete it.
To do so:
- CORE_RESOURCES and RESOURCE_FOREIGN_KEYS are moved to the single
module that references them respectively and the are made private (no
consumers use them).
- get_collection_info is removed and instead the 2 uses in neutron
just use the get() method of the RESOURCES map. There are no external
uses of get_collection_info.
- References using RESOURCE_ATTRIBUTE_MAP are switched over to
neutron-lib's RESOURCES.
- The neutron.api.v2.attributes module is removed as it's empty now.
- A few api attribute UTs are removed; there's nothing to test as per
this patch.

NeutronLibImpact

Change-Id: Iaacee584d499c4d33d6d2dd9609c7ac0f2cfc386
2018-03-09 13:37:28 -07:00
Boden R 3f1a9846d2 use callback payloads for REQUEST/RESPONSE events
This patch switches callbacks over to the payload object style events
[1] for BEFORE_RESPONSE and AFTER_REQUEST based notifications. To do
so an APIEventPayload object is used with the publish() method to
pass along the API related data. In addition a few UTs are updated to
work with the changes.

NeutronLibImpact

[1] https://docs.openstack.org/neutron-lib/latest/contributor/callbacks.html#event-payloads

Change-Id: Ibd8559e0db9dcc995abf8937a0cb764b21a18531
2017-12-24 07:27:11 +00:00
Boden R 9e67ba5052 use core resource api defs from lib
The core resource API definitions are in neutron-lib and are already
setup in a RESOURCES map, similar to neutron's global
RESOURCE_ATTRIBUTE_MAP. However, a number of consumers directly use
RESOURCE_ATTRIBUTE_MAP and moreover can perform some interesting
operations on it while mockin" for tests. For that reason this
patch proposes we phase in the use of neutron's RESOURCES map rather
than a rip and replace of RESOURCE_ATTRIBUTE_MAP.

This patch removes the API definitions for the core neutron resources
by updating neutron's global RESOURCE_ATTRIBUTE_MAP to reference lib's
RESOURCE map. In addition the AttributeMapMemento class is removed; it
no longer servers a purpose and neutron-lib's fixture should be used
in its place.

This patch should be safe to merge without worry of impacting consumers.
No one is using AttributeMapMemento [1] and the global map only changed
its reference value.

[1] http://codesearch.openstack.org/?q=AttributeMapMemento

Change-Id: Ib04fddcbd4465074452b71b16befa4e33b27259e
2017-11-08 09:48:50 -07:00
Boden R 95f1e03446 use plugin constants from neutron-lib
neutron-lib contains a number of the plugin related constants from
neutron.plugins.common.constants. This patch consumes those constants
from neutron-lib and removes them from neutron. In addition the notion
of the dummy plugin service type is moved strictly into the test
package of neutron since it's not a real service plugin.

NeutronLibImpact

Change-Id: I767c626f3fe6159ab3abd6a7ae3cb9893b79bf66
2017-10-16 09:32:20 -06:00
Kevin Benton a3dff9769b Delete dead API v2 router code
This code is no longer used now that we have switched to
Pecan and have no option to switch to the legacy API
framework.

Change-Id: I0701dfe13024132cf5b9696560b0d027712e7739
2017-09-13 15:11:49 -07:00
Kevin Benton db1058a499 Switch to Pecan for unit tests
This will drop Pecan in place of the old APIRouter for all
unit tests. This will significantly increase the UT coverage
of pecan and will allow us to drop the old API routing logic
completely.

The rest of the inline test changes are due to slight plugin loading
differences.

Implements: blueprint wsgi-pecan-switch
Change-Id: I76dc23fb7b96d82b0da50285bd0aac76142e81e5
2017-09-13 15:11:49 -07:00
Zhengwei Gao 9e185bca08 Allow unprivileged users to get their quota usage
When user try to get quota usage detail for their own project, it will
return null. As process logic of details method is incorrect, it only
allow admin to get other's project quota usage detail.

Change-Id: I2e21dac497a6c5bffba6b55cb4456820900449df
Closes-Bug: #1708133
2017-08-11 06:41:24 +00:00
Sergey Belous a8109af65f Extend Quota API to report usage statistics
Extend existing quota api to report a quota set. The quota set
will contain a set of resources and its corresponding reservation,
limits and in_use count for each tenant.

DocImpact:Documentation describing the new API as well as the new
information that it exposes.
APIImpact

Co-Authored-By: Prince Boateng<prince.a.owusu.boateng@intel.com>
Change-Id: Ief2a6a4d2d7085e2a9dcd901123bc4fe6ac7ca22
Related-bug: #1599488
2017-07-17 20:51:48 +00:00
Boden R 0e2b667bf1 use neutron-lib callbacks
The callback modules have been available in neutron-lib since commit [1]
and are ready for consumption.

As the callback registry is implemented with a singleton manager
instance, sync complications can arise ensuring all consumers switch to
lib's implementation at the same time. Therefore this consumption has
been broken down:
1) Shim neutron's callbacks using lib's callback system and remove
existing neutron internals related to callbacks (devref, UTs, etc.).
2) Switch all neutron's callback imports over to neutron-lib's.
3) Have all sub-projects using callbacks move their imports over to use
neutron-lib's callbacks implementation.
4) Remove the callback shims in neutron-lib once sub-projects are moved
over to lib's callbacks.
5) Follow-on patches moving our existing uses of callbacks to the new
event payload model provided by neutron-lib.callback.events

This patch implements #2 from above, moving all neutron's callback
imports to use neutron-lib's callbacks.

There are also a few places in the UT code that still patch callbacks,
we can address those in step #4 which may need [2].

NeutronLibImpact

[1] fea8bb64ba7ff52632c2bd3e3298eaedf623ee4f
[2] I9966c90e3f90552b41ed84a68b19f3e540426432

Change-Id: I8dae56f0f5c009bdf3e8ebfa1b360756216ab886
2017-04-26 12:12:53 -06:00
fpxie d2976d46d0 Replace six.iteritems with dict.items(Part-1)
according to https://wiki.openstack.org/wiki/Python3,
now we should avoid using six.iteritems and replace
it with dict.items.

Change-Id: I8753e80b34c0f86cf70aebc3bcbd3392ee933f62
Partial-Bug: #1680761
2017-04-17 14:08:47 +08:00
Armando Migliaccio ca751a1486 Spin off context module
NeutronLibImpact

Partially-implements: blueprint neutron-lib

Change-Id: I48cf45dc1b07035d952152eac2548a3bd9fc2832
2017-03-06 16:25:29 +00:00
Cedric Brandily c88debc44f Use addCleanup instead of tearDown
We should use addCleanup instead of tearDown because:
- tearDown is executed only if the test succeeds
- cleanups (defined with addCleanup) are executed even if the test fails

This change removes useless tearDown and transforms remaining ones into
addCleanup.

Change-Id: I44bd26dcb5c8456126a35cb807f0bafc772c0ab0
2017-02-02 22:07:26 +01:00
ZhaoBo 22707fb3d2 Add filter check for quering
Neutron rasises 500 error if the filter is the resources'
object property.

This patch add the check to prevent querying with base_db property.

Change-Id: I1aec4c1537e687e9087c468a592802779f370cb3
Closes-Bug: #1654195
2017-01-06 05:31:33 +00:00
Jenkins 85f748a14c Merge "Correctly print --limit value passed via API" 2016-12-20 02:12:02 +00:00
Brian Haley e45d2a904d Correctly print --limit value passed via API
Passing an invalid limit value, for example '--limit -1'
in neutronclient, generates this error from the API:

  Bad limit request: Limit must be an integer 0 or
  greater and not '%d'.

It should print what was passed.

Closes-bug: #1649665

Change-Id: I9b8bd67d344cd91e008f7c897f1ea6a020a9c30b
2016-12-13 21:27:43 +00:00
Ihar Hrachyshka 61eb74af31 Remove allow_pagination and allow_sorting config options
They were deprecated in Newton. This patch cleans them up.

Note: it does not mean that the features will not work anymore. On the
contrary, now API will consistently sort and paginate for plugins that
honour the relevant sorting/pagination parameters.

Note2: base resource controller still allows to pass
allow_pagination=False and allow_sorting=False parameters to disable the
features if a registered plugin does not support the features yet.

Change-Id: I5fd30b20f645846d9366740372c4815c4b33e2eb
Related-Bug: #1566514
2016-11-29 12:34:19 +00:00
Armando Migliaccio 17563a802e Adopt neutron-lib plugin directory
Neutron Manager is loaded at the very startup of the neutron
server process and with it plugins are loaded and stored for
lookup purposes as their references are widely used across the
entire neutron codebase.

Rather than holding these references directly in NeutronManager
this patch refactors the code so that these references are held
by a plugin directory.

This allows subprojects and other parts of the Neutron codebase
to use the directory in lieu of the manager. The result is a
leaner, cleaner, and more decoupled code.

Usage pattern [1,2] can be translated to [3,4] respectively.

[1] manager.NeutronManager.get_service_plugins()[FOO]
[2] manager.NeutronManager.get_plugin()
[3] directory.get_plugin(FOO)
[4] directory.get_plugin()

The more entangled part is in the neutron unit tests, where the
use of the manager can be simplified as mocking is typically
replaced by a call to the directory add_plugin() method. This is
safe as each test case gets its own copy of the plugin directory.
That said, unit tests that look more like API tests and that rely on
the entire plugin machinery, need some tweaking to avoid stumbling
into plugin loading failures.

Due to the massive use of the manager, deprecation warnings are
considered impractical as they cause logs to bloat out of proportion.

Follow-up patches that show how to adopt the directory in neutron
subprojects are tagged with topic:plugin-directory.

NeutronLibImpact

Partially-implements: blueprint neutron-lib

Change-Id: I7331e914234c5f0b7abe836604fdd7e4067551cf
2016-11-23 04:45:33 -07:00
Dariusz Smigiel dd5976b7ab Accept and return project_id for API calls
Update the API to accept project_id in requests and return
project_id in responses.

For now, the API treats tenant_id and project_id equivalently.
It accepts either or both in requests.
It returns both in responses, depending on filters.

We include an extension to indicate that support for project_id
is enabled in the API.

Completes: blueprint keystone-v3

APIImpact: Describe how the Networking API supports Keystone V3.

Co-Authored-By: Henry Gessau <HenryG@gessau.net>
Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>

Change-Id: I8775aa8a477191ef21e7c3c6da31d098befefc3c
2016-09-12 19:23:53 +00:00
Sławek Kapłoński 38b1b47fe7 Fix internal server error during updating QoS rule
QoS rule can be edited or created only by admin users. Because
rule object don't have tenant_id attribute there was error
in checking tenant_id of object and neutron server got internal
server error.

Now if updating object doesn't have tenant_id at all (like in
case of QoS rules), 404 error will be returned to the user.

New API tests for checking this case are added for QoS.

Change-Id: Ia82ad84a3a07df4df8eaeaed6c47d31be9493cbd
Closes-Bug: #1515564
2016-08-25 12:56:14 +00:00
Kumar Acharya e92b68dd82 delete event payload
This fix will allow the delete event to have the required data
in the notification payload.

Change-Id: I57a001ca2fddc2a750026e7da7980bfd8e5aab40
Closes-Bug: 1593127
2016-07-13 23:48:59 +05:30
Armando Migliaccio 877778ee4c Move DHCP notification logic out of API controller
Bug 1591766 unveiled an issue where calling the plugin API does not trigger
DHCP notifications. This is required by the auto-allocated-topology service
plugin that calls core_plugin.update_network(), and expect notifications
to be sent out on state changes. To accomplish this, the logic has been
encapsulated in the DHCP module, and leveraged via callback mechanisms.

For this reason, new events have been introduced, AFTER_REQUEST, and
BEFORE_RESPONSE. The latter in particular is the one needed to hook up
dhcp notifications in order to preserve backward compatibility.

More precisely, core plugins that use DHCP as is or implement their own,
(with or without an agent) should already instantiate their own notifier,
and if they do not, this should be rectified.

A search on codesearch.openstack.org reveals that out-of-tree plugins
already specify their own notifiers, and the default initialization is
clearly redundant now.

Related-bug: #1591766

Change-Id: I7440becb6d30af7159ecaeba09d7a28eceb71bea
2016-06-24 00:41:20 -07:00
Henry Gessau 78fff41ee3 Use converters and validators from neutron-lib
Related-Blueprint: neutron-lib

Change-Id: I6b9079e9e703c6fd75adbed3846e7257685433e8
2016-04-24 19:13:10 -04:00
Henry Gessau 4148a347b3 Use constants from neutron-lib
With this we enable the deprecation warnings by default.

Related-Blueprint: neutron-lib

Change-Id: I5b9e53751dd164010e5bbeb15f534ac0fe2a5105
2016-04-23 21:23:56 -04:00
Henry Gessau ae5bad49cc Use exceptions from neutron-lib
Related-Blueprint: neutron-lib

Change-Id: Ia014468bd621c4ee6aea95bf19328c61070174c4
2016-04-21 21:29:44 -04:00
Jenkins 1efe482358 Merge "Protect 'show' and 'index' with Retry decorator" 2016-02-05 17:24:06 +00:00
Kevin Benton 2a27361cf5 Protect 'show' and 'index' with Retry decorator
Commit 77de9653fd added a RetryRequest
exception to the policy engine for when items disappeared during policy
enforcement lookups. However, the API was not catching them for the
show and list operations.

This patch adds the decorators to the two methods to catch any
retry exception that may be emitted from the policy engine or
wherever else.

Closes-Bug: #1528031
Change-Id: If4aea5245cdbb2ea545e9a96d73386e3c21a3696
2016-02-04 21:48:43 -07:00
Yatin Kumbhare 6b4be76e14 Fix params order in assertEqual
Fix params order to correspond to real signature:
assertEqual(expected, actual)

Change-Id: I722b998f6eae47076f3d10213073296a0a9a2081
Closes-Bug: #1277104
2016-02-03 11:54:29 +05:30
lzklibj 3491cbc0c5 Unify assertEqual for empty usages
Update previous assertEqual(observed, *empty) usages to
assertEqual(*empty*, observed).

This patch aslo update hacking check for assertEqual with
empty types.

Change-Id: I981277618f92254a5beb9d3308a317d8c14e125c
2016-01-07 10:06:35 +00:00
Jenkins e1195647d2 Merge "Removes the use of mutables as default args" 2015-11-02 07:05:28 +00:00
Brandon Palm 2503dfb239 Fixed a bunch of typos throughout Neutron
Went through all of the docstrings in Neutron and did
some cleanup.  I'm sure there are bunch more that I have missed.

Change-Id: Ib29d2de1c580880c89ed4fd069e1515d0977a3e7
2015-10-30 08:54:41 -05:00
Gary Kotton 2b7fb6ff08 Removes the use of mutables as default args
Passing mutable objects as default args is a known Python pitfall.
We'd better avoid this. This commit changes mutable default args with
None, then use 'arg = arg or {}', 'arg = arg or []'. For unit code which
doesn't use the args , just set with None. This commit also adds hacking
check.

This code was taken from commit 0bea84ac20fe498bd08f7212a0017196c8cb0812
in Nova.

Change-Id: I36d07cade687690dc02a8f6cc3d70f5d00caf112
Co-Authored-By: ChangBo Guo(gcb) <glongwave@gmail.com>
2015-10-29 07:57:31 -07:00