mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-23 05:27:47 +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
|
return newlog
|
||||||
|
|
||||||
def assert_triggered(self):
|
def assertTriggered(self):
|
||||||
"""Check if current hook file was triggered/used by taskwarrior
|
"""Check if current hook file was triggered/used by taskwarrior
|
||||||
"""
|
"""
|
||||||
log = self._parse_log()
|
log = self._parse_log()
|
||||||
|
|
||||||
if log["calls"]:
|
assert log["calls"], "{0} was never called".format(self.hookname)
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def assert_triggered_count(self, count):
|
def assertTriggeredCount(self, count):
|
||||||
"""Check if current hook file was triggered/used by taskwarrior and
|
"""Check if current hook file was triggered/used by taskwarrior and
|
||||||
how many times.
|
how many times.
|
||||||
"""
|
"""
|
||||||
log = self._parse_log()
|
log = self._parse_log()
|
||||||
|
|
||||||
if len(log["calls"]) == count:
|
assert len(log["calls"]) == count, ("{0} calls expected for {1} but "
|
||||||
return True
|
"found {2}".format(
|
||||||
else:
|
count,
|
||||||
return False
|
self.hookname,
|
||||||
|
log["calls"]
|
||||||
|
))
|
||||||
|
|
||||||
def assert_exitcode(self, exitcode):
|
def assertExitcode(self, exitcode):
|
||||||
"""Check if current hook finished with the expected exit code
|
"""Check if current hook finished with the expected exit code
|
||||||
"""
|
"""
|
||||||
log = self._parse_log()
|
log = self._parse_log()
|
||||||
|
|
||||||
if log["exitcode"] == exitcode:
|
assert log["exitcode"] == exitcode, ("Expected exit code {0} for {1} "
|
||||||
return True
|
"but found {2}".format(
|
||||||
else:
|
exitcode,
|
||||||
return False
|
self.hookname,
|
||||||
|
log["exitcode"]
|
||||||
|
))
|
||||||
|
|
||||||
# vim: ai sts=4 et sw=4
|
# vim: ai sts=4 et sw=4
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue