Add "override" CLI command

Change-Id: I88b059db3ec4349252498fa97cdfe933a6d36fcd
This commit is contained in:
Yuriy Taraday 2016-04-14 15:54:03 +03:00
parent 065d95b598
commit 3951026d99
3 changed files with 17 additions and 3 deletions

View File

@ -51,3 +51,4 @@ nailgun.extensions =
tuning_box.cli =
get = tuning_box.cli.get:Get
set = tuning_box.cli.set:Set
override = tuning_box.cli.set:Override

View File

@ -118,3 +118,7 @@ class Set(base.ResourceCommand):
else:
resource = value
client.put(resource_url, resource)
class Override(Set):
url_last_part = 'overrides'

View File

@ -210,8 +210,12 @@ class TestSet(testscenarios.WithScenarios, _BaseCLITest):
should_get = True
stdin = None
url_last_part = 'values'
cmd = 'set'
def test_set(self):
url = self.BASE_URL + '/environments/1/lvl1/value1/resources/1/values'
url = self.BASE_URL + '/environments/1/lvl1/value1/resources/1/' + \
self.url_last_part
self.req_mock.put(url)
if self.should_get:
self.req_mock.get(
@ -219,8 +223,8 @@ class TestSet(testscenarios.WithScenarios, _BaseCLITest):
headers={'Content-Type': 'application/json'},
json={'a': 1, 'b': True},
)
args = ("set --env 1 --level lvl1=value1 --resource 1 " +
self.args).split()
args = [self.cmd] + ("--env 1 --level lvl1=value1 --resource 1 " +
self.args).split()
if self.stdin:
self.cli.stdin.write(self.stdin)
self.cli.stdin.seek(0)
@ -230,3 +234,8 @@ class TestSet(testscenarios.WithScenarios, _BaseCLITest):
self.assertEqual('GET', req_history[0].method)
self.assertEqual('PUT', req_history[-1].method)
self.assertEqual(self.expected_body, req_history[-1].json())
class TestOverride(TestSet):
url_last_part = 'overrides'
cmd = 'override'