Skip to content

Commit

Permalink
tgt_type vs expr_form: add backward compatilibty, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
the-glu committed Apr 24, 2023
1 parent bbe3f97 commit 37631fe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pepper/libpepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def low(self, lowstate, path='/'):
return self.req(path, lowstate)

def local(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`` client
Expand All @@ -329,6 +329,13 @@ def local(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')

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

if timeout:
low['timeout'] = timeout

Expand Down
10 changes: 10 additions & 0 deletions tests/integration/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@

def test_local(pepper_client, session_minion_id):
assert pepper_client.local('*', 'test.ping')['return'][0][session_minion_id] is True


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 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

0 comments on commit 37631fe

Please sign in to comment.