summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2021-09-01 11:27:31 +0100
committerStephen Finucane <stephenfin@redhat.com>2021-09-02 10:50:52 +0100
commit01c7a3aa10f13eb889221f609dc4fb1463904fe3 (patch)
tree77abb1835b5276a7a42aa1c7ca0b038a39fee1c9
parent4a5bdde3b0c330a06c9aa56f28541cd22bc438f3 (diff)
downloadpython-novaclient-01c7a3aa10f13eb889221f609dc4fb1463904fe3.tar.gz
tests: Add missing 'nova update' unit tests
We have functional tests for the 'nova update' commands, but no unit tests to verify e.g. that we can't set a description for the server before microversion 2.19. Add such tests. Change-Id: I9af89655a7e7276446a881fd28d21ddd6581048c Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
-rw-r--r--novaclient/tests/unit/v2/fakes.py3
-rw-r--r--novaclient/tests/unit/v2/test_shell.py29
2 files changed, 32 insertions, 0 deletions
diff --git a/novaclient/tests/unit/v2/fakes.py b/novaclient/tests/unit/v2/fakes.py
index 29492cbf..07216adc 100644
--- a/novaclient/tests/unit/v2/fakes.py
+++ b/novaclient/tests/unit/v2/fakes.py
@@ -2408,6 +2408,9 @@ class FakeSessionClient(base_client.SessionClient):
def delete_servers_1234_migrations_1(self):
return (202, {}, None)
+ def put_servers_1234(self, **kw):
+ return (201, {}, None)
+
def put_servers_1234_tags_tag(self, **kw):
return (201, {}, None)
diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py
index 10e8c732..ed36685f 100644
--- a/novaclient/tests/unit/v2/test_shell.py
+++ b/novaclient/tests/unit/v2/test_shell.py
@@ -2395,6 +2395,35 @@ class ShellTest(utils.TestCase):
self.assert_called('POST', '/servers/1234/action',
{'migrate': {'host': 'target-host'}})
+ def test_update(self):
+ self.run_command('update --name new-name sample-server')
+ expected_put_body = {
+ "server": {
+ "name": "new-name"
+ }
+ }
+ self.assert_called('GET', '/servers/1234', pos=-2)
+ self.assert_called('PUT', '/servers/1234', expected_put_body, pos=-1)
+
+ def test_update_with_description(self):
+ self.run_command(
+ 'update --description new-description sample-server',
+ api_version='2.19')
+ expected_put_body = {
+ "server": {
+ "description": "new-description"
+ }
+ }
+ self.assert_called('GET', '/servers/1234', pos=-2)
+ self.assert_called('PUT', '/servers/1234', expected_put_body, pos=-1)
+
+ def test_update_with_description_pre_v219(self):
+ self.assertRaises(
+ SystemExit,
+ self.run_command,
+ 'update --description new-description sample-server',
+ api_version='2.18')
+
def test_resize(self):
self.run_command('resize sample-server 1')
self.assert_called('POST', '/servers/1234/action',