Skip to content

Commit d368f85

Browse files
committed
tgt_type vs expr_form: fix tests, extra backward compatibility
1 parent 12780bb commit d368f85

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

pepper/libpepper.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,8 @@ def local(self, tgt, fun, arg=None, kwarg=None, tgt_type='glob',
330330
low['tgt_type'] = tgt_type
331331

332332
if expr_form:
333-
334333
logger.warning('expr_form argument is deprecated in local function, please use tgt_type instead')
335-
336-
if not tgt_type:
337-
low['tgt_type'] = expr_form
334+
low['tgt_type'] = expr_form
338335

339336
if timeout:
340337
low['timeout'] = timeout
@@ -345,7 +342,7 @@ def local(self, tgt, fun, arg=None, kwarg=None, tgt_type='glob',
345342
return self.low([low])
346343

347344
def local_async(self, tgt, fun, arg=None, kwarg=None, tgt_type='glob',
348-
timeout=None, ret=None):
345+
timeout=None, ret=None, expr_form=None):
349346
'''
350347
Run a single command using the ``local_async`` client
351348
@@ -366,6 +363,10 @@ def local_async(self, tgt, fun, arg=None, kwarg=None, tgt_type='glob',
366363
if tgt_type:
367364
low['tgt_type'] = tgt_type
368365

366+
if expr_form:
367+
logger.warning('expr_form argument is deprecated in local function, please use tgt_type instead')
368+
low['tgt_type'] = expr_form
369+
369370
if timeout:
370371
low['timeout'] = timeout
371372

@@ -375,7 +376,7 @@ def local_async(self, tgt, fun, arg=None, kwarg=None, tgt_type='glob',
375376
return self.low([low])
376377

377378
def local_batch(self, tgt, fun, arg=None, kwarg=None, tgt_type='glob',
378-
batch='50%', ret=None):
379+
batch='50%', ret=None, expr_form=None):
379380
'''
380381
Run a single command using the ``local_batch`` client
381382
@@ -396,6 +397,10 @@ def local_batch(self, tgt, fun, arg=None, kwarg=None, tgt_type='glob',
396397
if tgt_type:
397398
low['tgt_type'] = tgt_type
398399

400+
if expr_form:
401+
logger.warning('expr_form argument is deprecated in local function, please use tgt_type instead')
402+
low['tgt_type'] = expr_form
403+
399404
if batch:
400405
low['batch'] = batch
401406

tests/integration/test_local.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ def test_local(pepper_client, session_minion_id):
66

77

88
def test_local_with_tgt_type(pepper_client, session_minion_id):
9-
assert pepper_client.local('*', 'test.ping', tgt_type='list')['return'][0][session_minion_id] is False
9+
assert session_minion_id not in pepper_client.local('*', 'test.ping', tgt_type='list')['return'][0]
1010
assert pepper_client.local(session_minion_id, 'test.ping', tgt_type='list')['return'][0][session_minion_id] is True
1111

1212

1313
def test_local_with_deprecated_expr_form(pepper_client, session_minion_id):
14-
assert pepper_client.local('*', 'test.ping', expr_form='list')['return'][0][session_minion_id] is False
15-
assert pepper_client.local(session_minion_id, 'test.ping', expr_form='list')['return'][0][session_minion_id] is True
14+
assert session_minion_id not in pepper_client.local('*', 'test.ping', expr_form='list')['return'][0]
15+
r = pepper_client.local(session_minion_id, 'test.ping', expr_form='list')['return'][0][session_minion_id]
16+
assert r is True

0 commit comments

Comments
 (0)