Skip to content

Commit

Permalink
util/agent: add test to check that the handlers are registered correctly
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Luebbe <[email protected]>
  • Loading branch information
jluebbe committed May 16, 2019
1 parent 41d3c15 commit ee7cc71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions labgrid/util/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Agent:
def __init__(self):
self.methods = {}
self.register('load', self.load)
self.register('list', self.list)

# use real stdin/stdout
self.stdin = sys.stdin
Expand All @@ -38,6 +39,9 @@ def load(self, name, source):
for k, v in module.methods.items():
self.register('{}.{}'.format(name, k), v)

def list(self):
return list(self.methods.keys())

def run(self):
for line in self.stdin:
if not line:
Expand Down
3 changes: 3 additions & 0 deletions tests/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,6 @@ def test_local():
def test_all_modules():
aw = AgentWrapper(None)
aw.load('deditec_relais8')
methods = aw.list()
assert 'deditec_relais8.set' in methods
assert 'deditec_relais8.get' in methods

0 comments on commit ee7cc71

Please sign in to comment.