| 1 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 |
# not use this file except in compliance with the License. You may obtain |
| 3 |
# a copy of the License at |
| 4 |
# |
| 5 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 |
# |
| 7 |
# Unless required by applicable law or agreed to in writing, software |
| 8 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 |
# License for the specific language governing permissions and limitations |
| 11 |
# under the License. |
| 12 |
# |
| 13 |
|
| 14 |
import argparse |
| 15 |
from unittest import mock |
| 16 |
|
| 17 |
from cliff import columns as cliff_columns |
| 18 |
from osc_lib.tests import utils |
| 19 |
|
| 20 |
|
| 21 |
class TestNeutronClientOSCV2(utils.TestCommand): |
| 22 |
|
| 23 |
def setUp(self): |
| 24 |
super(TestNeutronClientOSCV2, self).setUp() |
| 25 |
self.namespace = argparse.Namespace() |
| 26 |
self.app.client_manager.session = mock.Mock() |
| 27 |
self.app.client_manager.neutronclient = mock.Mock() |
| 28 |
self.neutronclient = self.app.client_manager.neutronclient |
| 29 |
|
| 30 |
self.app.client_manager.network = mock.Mock() |
| 31 |
self.networkclient = self.app.client_manager.network |
| 32 |
|
| 33 |
self.addCleanup(mock.patch.stopall) |
| 34 |
|
| 35 |
# TODO(amotoki): Move this to osc_lib |
| 36 |
def assertListItemEqual(self, expected, actual): |
| 37 |
self.assertEqual(len(expected), len(actual)) |
| 38 |
for item_expected, item_actual in zip(expected, actual): |
| 39 |
self.assertItemEqual(item_expected, item_actual) |
| 40 |
|
| 41 |
# TODO(amotoki): Move this to osc_lib |
| 42 |
def assertItemEqual(self, expected, actual): |
| 43 |
self.assertEqual(len(expected), len(actual)) |
| 44 |
for col_expected, col_actual in zip(expected, actual): |
| 45 |
if isinstance(col_expected, cliff_columns.FormattableColumn): |
| 46 |
self.assertIsInstance(col_actual, col_expected.__class__) |
| 47 |
self.assertEqual(col_expected.human_readable(), |
| 48 |
col_actual.human_readable()) |
| 49 |
else: |
| 50 |
self.assertEqual(col_expected, col_actual) |