imip-agent

Annotated tests/resource_request.sh

871:b38466ae1e51
2015-10-18 Paul Boddie Handle rule-based occurrences as exceptions when removed by attendees for counter-proposals.
paul@716 1
#!/bin/sh
paul@716 2
paul@716 3
THIS_DIR=`dirname $0`
paul@716 4
paul@716 5
TEMPLATES="$THIS_DIR/templates"
paul@716 6
RESOURCE_SCRIPT="$THIS_DIR/../imip_resource.py"
paul@716 7
SHOWMAIL="$THIS_DIR/../tools/showmail.py"
paul@716 8
STORE=/tmp/store
paul@716 9
STATIC=/tmp/static
paul@716 10
PREFS=/tmp/prefs
paul@716 11
ARGS="-S $STORE -P $STATIC -p $PREFS -d"
paul@716 12
paul@716 13
ERROR=err.tmp
paul@716 14
paul@716 15
export N=$1
paul@716 16
export START=20141126T090000
paul@716 17
export END=20141126T100000
paul@716 18
export SENDERADDRESS="person-$N@example.com"
paul@716 19
export SENDER="mailto:person-$N@example.com"
paul@716 20
paul@716 21
# Exit if a previous result indicates acceptance of a request.
paul@716 22
paul@716 23
   [ -e "outP${N}.tmp" ] \
paul@716 24
&& `grep 'PARTSTAT' "outP${N}.tmp" | grep -q 'ACCEPTED'` \
paul@716 25
&& exit 0
paul@716 26
paul@716 27
FBRESULT=$2
paul@716 28
paul@716 29
# Find the end of a busy period or use the initial start.
paul@716 30
paul@716 31
FBSTART=`grep 'FREEBUSY' "$FBRESULT" | grep -v 'VFREEBUSY' | tail -n 1 | cut -d: -f2 | cut -d/ -f2 | tr -d '\\r'`
paul@716 32
FBEND=`python "$THIS_DIR/next_time.py" "$FBSTART" 09 16`
paul@716 33
START=${FBSTART:-$START}
paul@716 34
END=${FBEND:-$END}
paul@716 35
paul@716 36
echo "Try for $N with $START and $END..."
paul@716 37
paul@716 38
# Request a resource on behalf of a numbered person identity.
paul@716 39
paul@716 40
  envsubst < "$TEMPLATES/event-request-group.txt" \
paul@716 41
| tee "inP${N}.tmp" \
paul@716 42
| "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \
paul@716 43
| "$SHOWMAIL" 2>> $ERROR \
paul@716 44
> "outP${N}.tmp"