Skip to content

Commit

Permalink
tgt_type vs expr_form: fix tests, extra backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
the-glu committed May 3, 2023
1 parent 12780bb commit d368f85
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
17 changes: 11 additions & 6 deletions pepper/libpepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,8 @@ def local(self, tgt, fun, arg=None, kwarg=None, tgt_type='glob',
low['tgt_type'] = tgt_type

if expr_form:

logger.warning('expr_form argument is deprecated in local function, please use tgt_type instead')

if not tgt_type:
low['tgt_type'] = expr_form
low['tgt_type'] = expr_form

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

def local_async(self, tgt, fun, arg=None, kwarg=None, tgt_type='glob',
timeout=None, ret=None):
timeout=None, ret=None, expr_form=None):
'''
Run a single command using the ``local_async`` client
Expand All @@ -366,6 +363,10 @@ def local_async(self, tgt, fun, arg=None, kwarg=None, tgt_type='glob',
if tgt_type:
low['tgt_type'] = tgt_type

if expr_form:
logger.warning('expr_form argument is deprecated in local function, please use tgt_type instead')
low['tgt_type'] = expr_form

if timeout:
low['timeout'] = timeout

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

def local_batch(self, tgt, fun, arg=None, kwarg=None, tgt_type='glob',
batch='50%', ret=None):
batch='50%', ret=None, expr_form=None):
'''
Run a single command using the ``local_batch`` client
Expand All @@ -396,6 +397,10 @@ def local_batch(self, tgt, fun, arg=None, kwarg=None, tgt_type='glob',
if tgt_type:
low['tgt_type'] = tgt_type

if expr_form:
logger.warning('expr_form argument is deprecated in local function, please use tgt_type instead')
low['tgt_type'] = expr_form

if batch:
low['batch'] = batch

Expand Down
7 changes: 4 additions & 3 deletions tests/integration/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ def test_local(pepper_client, session_minion_id):


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


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

0 comments on commit d368f85

Please sign in to comment.