summaryrefslogtreecommitdiff
path: root/saharaclient/tests/unit/test_jobs.py
diff options
context:
space:
mode:
authorAndrey Pavlov <apavlov@mirantis.com>2016-01-26 14:39:33 +0300
committerAndrey Pavlov <apavlov@mirantis.com>2016-01-29 15:02:17 +0300
commitadf19185c4e9bbd3d245a15cbccb37f56b7464c5 (patch)
tree7c227234ce75d7f4e352ff7352aae2006df0aa90 /saharaclient/tests/unit/test_jobs.py
parent421476157dca5d154c354fb8d00c375a02e2b0d6 (diff)
downloadpython-saharaclient-adf19185c4e9bbd3d245a15cbccb37f56b7464c5.tar.gz
Adding ability to unset fields with update calls
Adding a sentinel object that will be used as a default value in update methods. This object will allow to distinguish whether a field should be unset or should not be updated. Change-Id: Ie6679c8f64623e8570176b8009380b08de2be6a5 Closes-bug: #1534050
Diffstat (limited to 'saharaclient/tests/unit/test_jobs.py')
-rw-r--r--saharaclient/tests/unit/test_jobs.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/saharaclient/tests/unit/test_jobs.py b/saharaclient/tests/unit/test_jobs.py
index 39acb7c..b5e2ec2 100644
--- a/saharaclient/tests/unit/test_jobs.py
+++ b/saharaclient/tests/unit/test_jobs.py
@@ -96,6 +96,7 @@ class JobTest(base.BaseTestCase):
self.responses.patch(url, status_code=202, json=update_body)
+ # check that all parameters will be updated
resp = self.client.jobs.update('id', name='new_name',
description='description')
@@ -103,3 +104,20 @@ class JobTest(base.BaseTestCase):
self.assertIsInstance(resp, jobs.Job)
self.assertEqual(update_body,
json.loads(self.responses.last_request.body))
+
+ # check that parameters will not be updated
+ self.client.jobs.update("id")
+ self.assertEqual(url, self.responses.last_request.url)
+ self.assertEqual({},
+ json.loads(self.responses.last_request.body))
+
+ # check that all parameters will be unset
+ unset_json = {
+ "name": None, "description": None, "is_public": None,
+ "is_protected": None
+ }
+
+ self.client.jobs.update("id", **unset_json)
+ self.assertEqual(url, self.responses.last_request.url)
+ self.assertEqual(unset_json,
+ json.loads(self.responses.last_request.body))