Skip to content

Commit

Permalink
#31 Allowing inputless jaanch. But input key must exist
Browse files Browse the repository at this point in the history
  • Loading branch information
thenakliman committed Apr 13, 2018
1 parent dcf6e95 commit 71e5a0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions nirikshak/tests/unit/workers/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ def func(self, **kwargs):
self.assertRaises(exceptions.MissingRequiredArgsException,
FakePlugin().func, **jaanch)

def test_if_args_are_not_required_for_a_jaanch(self):
@plugins.register('ini')
class FakePlugin(object):
@worker_base.validate(required=tuple())
def func(self, **kwargs):
return 10

jaanch = self.jaanch
del jaanch['input']['args']
self.assertEqual(10, FakePlugin().func(**jaanch))

def test_if_extra_args_are_provided(self):
@plugins.register('ini')
class FakePlugin(object):
Expand Down
2 changes: 2 additions & 0 deletions nirikshak/workers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def validator(self, **kwargs):
available = set(list(kwargs['input']['args'].keys()))
except KeyError:
available = set()
except AttributeError:
available = set()

missing = require - available
if missing:
Expand Down

0 comments on commit 71e5a0f

Please sign in to comment.