summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Natsume <takanattie@gmail.com>2022-08-05 23:35:50 +0900
committerTakashi Natsume <takanattie@gmail.com>2022-08-05 23:58:30 +0900
commitbe9517cb027d960caf4c9c8171b3ad2568bedae9 (patch)
tree64fd29d0aab7ecc4c748c2248a8f7ad701c8b4de
parentcdea416cce0b81b096a0907a7f283534c9f06323 (diff)
downloadpython-novaclient-be9517cb027d960caf4c9c8171b3ad2568bedae9.tar.gz
Fix a fixture for keypairs tests18.1.0
This patch is a follow-up for I03570d0a49b73021de91dc50b65b1bbf5d4b878b. The following file is for shell (CLI) tests, so it does not need to be changed anymore. * novaclient/tests/unit/v2/fakes.py Change-Id: I3b1cf5d402b04854177265f2ba429956edb73203 Signed-off-by: Takashi Natsume <takanattie@gmail.com>
-rw-r--r--novaclient/tests/unit/fixture_data/keypairs.py12
-rw-r--r--novaclient/tests/unit/v2/fakes.py7
2 files changed, 12 insertions, 7 deletions
diff --git a/novaclient/tests/unit/fixture_data/keypairs.py b/novaclient/tests/unit/fixture_data/keypairs.py
index 1d73d252..5ac1b4ad 100644
--- a/novaclient/tests/unit/fixture_data/keypairs.py
+++ b/novaclient/tests/unit/fixture_data/keypairs.py
@@ -10,16 +10,20 @@
# License for the specific language governing permissions and limitations
# under the License.
+from novaclient import api_versions
from novaclient.tests.unit import fakes
from novaclient.tests.unit.fixture_data import base
class V1(base.Fixture):
+ api_version = '2.1'
base_url = 'os-keypairs'
def setUp(self):
super(V1, self).setUp()
+ api_version = api_versions.APIVersion(self.api_version)
+
keypair = {'fingerprint': 'FAKE_KEYPAIR', 'name': 'test'}
headers = self.json_headers
@@ -39,7 +43,13 @@ class V1(base.Fixture):
def post_os_keypairs(request, context):
body = request.json()
assert list(body) == ['keypair']
- fakes.assert_has_keys(body['keypair'], required=['name'])
+ if api_version >= api_versions.APIVersion("2.92"):
+ # In 2.92, public_key becomes mandatory
+ required = ['name', 'public_key']
+ else:
+ required = ['name']
+ fakes.assert_has_keys(body['keypair'],
+ required=required)
return {'keypair': keypair}
self.requests_mock.post(self.url(),
diff --git a/novaclient/tests/unit/v2/fakes.py b/novaclient/tests/unit/v2/fakes.py
index c7687c1e..059a7147 100644
--- a/novaclient/tests/unit/v2/fakes.py
+++ b/novaclient/tests/unit/v2/fakes.py
@@ -1228,13 +1228,8 @@ class FakeSessionClient(base_client.SessionClient):
def post_os_keypairs(self, body, **kw):
assert list(body) == ['keypair']
- if self.api_version >= api_versions.APIVersion("2.92"):
- # In 2.92, public_key becomes mandatory
- required = ['name', 'public_key']
- else:
- required = ['name']
fakes.assert_has_keys(body['keypair'],
- required=required)
+ required=['name'])
r = {'keypair': self.get_os_keypairs()[2]['keypairs'][0]['keypair']}
return (202, {}, r)