mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Unittest - properly implement Hook.assert* functions
This commit is contained in:
parent
bb3555f217
commit
6a3edc88a1
1 changed files with 16 additions and 15 deletions
|
@ -460,35 +460,36 @@ class LoggedHook(Hook):
|
|||
|
||||
return newlog
|
||||
|
||||
def assert_triggered(self):
|
||||
def assertTriggered(self):
|
||||
"""Check if current hook file was triggered/used by taskwarrior
|
||||
"""
|
||||
log = self._parse_log()
|
||||
|
||||
if log["calls"]:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
assert log["calls"], "{0} was never called".format(self.hookname)
|
||||
|
||||
def assert_triggered_count(self, count):
|
||||
def assertTriggeredCount(self, count):
|
||||
"""Check if current hook file was triggered/used by taskwarrior and
|
||||
how many times.
|
||||
"""
|
||||
log = self._parse_log()
|
||||
|
||||
if len(log["calls"]) == count:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
assert len(log["calls"]) == count, ("{0} calls expected for {1} but "
|
||||
"found {2}".format(
|
||||
count,
|
||||
self.hookname,
|
||||
log["calls"]
|
||||
))
|
||||
|
||||
def assert_exitcode(self, exitcode):
|
||||
def assertExitcode(self, exitcode):
|
||||
"""Check if current hook finished with the expected exit code
|
||||
"""
|
||||
log = self._parse_log()
|
||||
|
||||
if log["exitcode"] == exitcode:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
assert log["exitcode"] == exitcode, ("Expected exit code {0} for {1} "
|
||||
"but found {2}".format(
|
||||
exitcode,
|
||||
self.hookname,
|
||||
log["exitcode"]
|
||||
))
|
||||
|
||||
# vim: ai sts=4 et sw=4
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue