nova/nova/tests/unit/api/openstack/placement/handlers
Chris Dent db6aa64062 [placement] Fix incorrect exception import
In change I2b94945a0963d6a61af931505b69afe2d4733759 the exceptions that
placement uses were moved into the placement hierarchy and most of the
code that uses those exceptions was updated to reflect the change.

I86416e35da1798cdf039b42c9ed7629f0f9c75fc merged slightly before,
and had not made the change to the new style.

As the old aggregate handler had no exceptions imported, there was no
merge conflict when the exceptions change merged. At the same time
the exception in question is not covered by tests, because it only
happens if there is a concurrent update, which we don't cover in the
gabbi tests. We do cover a generation conflict on a supplied
generation, but that's not the same thing.

So basically this went by without us noticing and I happened to notice
while doing something else, so here's a fix for it.

To test it, a new directory for unit tests for handlers is added and
a new file, test_aggregate. Following the guidelines in
https://docs.openstack.org/nova/latest/contributor/placement.html#testing
the problematic code has been extracted to its own private method so that
it can be tested as a unit with limited mocking. The overarching flow
of setting aggregates continues to be tested by the gabbi functional
tests.

Note the added NOTE in the new _set_aggregates method: It appears that
the DBDuplicateEntry exception maybe doesn't need to be there.

Change-Id: I4b7b29270b2d9900b59c7dd74082688164430252
Closes-Bug: #1761295
2018-04-05 18:10:28 +00:00
..
__init__.py [placement] Fix incorrect exception import 2018-04-05 18:10:28 +00:00
test_aggregate.py [placement] Fix incorrect exception import 2018-04-05 18:10:28 +00:00