imip-agent

Changeset

1047:c06cdeae95a3
2016-02-08 Paul Boddie raw files shortlog changelog graph Added a test of booking two resources sharing a quota at the same time.
tests/templates/event-request-cars.txt (file) tests/test_resource_invitation_constraints_quota.sh (file)
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tests/templates/event-request-cars.txt	Mon Feb 08 17:40:20 2016 +0100
     1.3 @@ -0,0 +1,36 @@
     1.4 +Content-Type: multipart/alternative; boundary="===============0047278175=="
     1.5 +MIME-Version: 1.0
     1.6 +From: paul.boddie@example.com
     1.7 +To: resource-car-porsche911@example.com, resource-car-fiat500@example.com
     1.8 +Subject: Invitation!
     1.9 +
    1.10 +--===============0047278175==
    1.11 +Content-Type: text/plain; charset="us-ascii"
    1.12 +MIME-Version: 1.0
    1.13 +Content-Transfer-Encoding: 7bit
    1.14 +
    1.15 +Reserve both cars at the same time.
    1.16 +
    1.17 +--===============0047278175==
    1.18 +MIME-Version: 1.0
    1.19 +Content-Transfer-Encoding: 7bit
    1.20 +Content-Type: text/calendar; charset="us-ascii"; method="REQUEST"
    1.21 +
    1.22 +BEGIN:VCALENDAR
    1.23 +PRODID:-//imip-agent/test//EN
    1.24 +METHOD:REQUEST
    1.25 +VERSION:2.0
    1.26 +BEGIN:VEVENT
    1.27 +ORGANIZER:mailto:paul.boddie@example.com
    1.28 +ATTENDEE;ROLE=CHAIR:mailto:paul.boddie@example.com
    1.29 +ATTENDEE;RSVP=TRUE:mailto:resource-car-porsche911@example.com
    1.30 +ATTENDEE;RSVP=TRUE:mailto:resource-car-fiat500@example.com
    1.31 +DTSTAMP:20141127T123456Z
    1.32 +DTSTART;TZID=Europe/Oslo:20141127T160000
    1.33 +DTEND;TZID=Europe/Oslo:20141127T170000
    1.34 +SUMMARY:Test drive
    1.35 +UID:event23@example.com
    1.36 +END:VEVENT
    1.37 +END:VCALENDAR
    1.38 +
    1.39 +--===============0047278175==--
     2.1 --- a/tests/test_resource_invitation_constraints_quota.sh	Mon Feb 08 16:52:02 2016 +0100
     2.2 +++ b/tests/test_resource_invitation_constraints_quota.sh	Mon Feb 08 17:40:20 2016 +0100
     2.3 @@ -303,3 +303,52 @@
     2.4  && [ `grep "event22@example.com" "$JOURNALFILE" | wc -l` = '1' ] \
     2.5  && echo "Success" \
     2.6  || echo "Failed"
     2.7 +
     2.8 +# Increase the quota.
     2.9 +
    2.10 +echo '* PT3H' > "$JOURNAL/$QUOTA/limits"
    2.11 +
    2.12 +# Attempt to schedule an event involving both resources.
    2.13 +
    2.14 +"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-cars.txt" 2>> $ERROR
    2.15 +
    2.16 +   grep -q "^20141127T150000Z${TAB}20141127T160000Z" "$FBSENDERFILE" \
    2.17 +&& echo "Success" \
    2.18 +|| echo "Failed"
    2.19 +
    2.20 +# Present the request to both resources.
    2.21 +
    2.22 +  "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-cars.txt" 2>> $ERROR \
    2.23 +| tee out8r.tmp \
    2.24 +| "$SHOWMAIL" \
    2.25 +> out8.tmp
    2.26 +
    2.27 +# Since the email module used by showmail.py cannot stop after reading a single
    2.28 +# message, the second message is obtained.
    2.29 +
    2.30 +  grep -n '^From ' out8r.tmp \
    2.31 +| tail -n 1 \
    2.32 +| cut -d ':' -f 1 \
    2.33 +| xargs -I{} tail -n +'{}' out8r.tmp \
    2.34 +| "$SHOWMAIL" \
    2.35 +>> out8.tmp
    2.36 +
    2.37 +   grep -q 'METHOD:REPLY' out8.tmp \
    2.38 +&& grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out8.tmp \
    2.39 +&& grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out8.tmp \
    2.40 +&& echo "Success" \
    2.41 +|| echo "Failed"
    2.42 +
    2.43 +   ( grep -q "^20141127T150000Z${TAB}20141127T160000Z" "$FBFILE1" \
    2.44 +     && ! grep -q "^20141127T150000Z${TAB}20141127T160000Z" "$FBFILE2" ) \
    2.45 +|| ( ! grep -q "^20141127T150000Z${TAB}20141127T160000Z" "$FBFILE1" \
    2.46 +     && grep -q "^20141127T150000Z${TAB}20141127T160000Z" "$FBFILE2" ) \
    2.47 +&& echo "Success" \
    2.48 +|| echo "Failed"
    2.49 +
    2.50 +# Check the quota (event is confirmed, but only for one resource).
    2.51 +
    2.52 +   [ -e "$JOURNALFILE" ] \
    2.53 +&& grep -q "event23@example.com" "$JOURNALFILE" \
    2.54 +&& echo "Success" \
    2.55 +|| echo "Failed"