mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Tests: expose 'args' passed to hook scripts
- Useful to validate that all the expected arguments were passed with correct escaping. - Update test/template.t with one use-case for 'args'
This commit is contained in:
parent
09d86eb165
commit
fd17a68930
4 changed files with 12 additions and 8 deletions
|
@ -10,7 +10,6 @@ try:
|
|||
except ImportError:
|
||||
import json
|
||||
|
||||
from copy import deepcopy
|
||||
from datetime import datetime
|
||||
from .utils import DEFAULT_HOOK_PATH
|
||||
from .exceptions import HookError
|
||||
|
@ -396,7 +395,7 @@ class LoggedHook(Hook):
|
|||
It should look something like this:
|
||||
|
||||
## STDIN file
|
||||
% Called at 1414874711
|
||||
% Called at 1414874711 with 'arg1 arg2 ...'
|
||||
{... JSON received by the hook ... }
|
||||
{... more JSON ...}
|
||||
|
||||
|
@ -424,12 +423,14 @@ class LoggedHook(Hook):
|
|||
for i, line in enumerate(fh):
|
||||
line = line.rstrip("\n")
|
||||
if line.startswith("%"):
|
||||
tstamp, args = line.split(" with ")
|
||||
# Timestamp includes nanosecond resolution
|
||||
timestamp = line.split(" ")[-1]
|
||||
timestamp = tstamp.split(" ")[-1]
|
||||
# convert timestamp to python datetime object
|
||||
log["calls"].append(
|
||||
datetime.fromtimestamp(float(timestamp))
|
||||
)
|
||||
log["calls"].append({
|
||||
"timestamp": datetime.fromtimestamp(float(timestamp)),
|
||||
"args": args,
|
||||
})
|
||||
elif line.startswith("{"):
|
||||
# Decode json input (to hook)
|
||||
log["input"]["json"].append(json_decoder(line))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue