# HG changeset patch # User Paul Boddie # Date 1454949620 -3600 # Node ID c06cdeae95a38f6cf5c13c2bd4fa468f2992975e # Parent 84c6d38d2c9aff3d160548fc0914fa33b99e690d Added a test of booking two resources sharing a quota at the same time. diff -r 84c6d38d2c9a -r c06cdeae95a3 tests/templates/event-request-cars.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/templates/event-request-cars.txt Mon Feb 08 17:40:20 2016 +0100 @@ -0,0 +1,36 @@ +Content-Type: multipart/alternative; boundary="===============0047278175==" +MIME-Version: 1.0 +From: paul.boddie@example.com +To: resource-car-porsche911@example.com, resource-car-fiat500@example.com +Subject: Invitation! + +--===============0047278175== +Content-Type: text/plain; charset="us-ascii" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit + +Reserve both cars at the same time. + +--===============0047278175== +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/calendar; charset="us-ascii"; method="REQUEST" + +BEGIN:VCALENDAR +PRODID:-//imip-agent/test//EN +METHOD:REQUEST +VERSION:2.0 +BEGIN:VEVENT +ORGANIZER:mailto:paul.boddie@example.com +ATTENDEE;ROLE=CHAIR:mailto:paul.boddie@example.com +ATTENDEE;RSVP=TRUE:mailto:resource-car-porsche911@example.com +ATTENDEE;RSVP=TRUE:mailto:resource-car-fiat500@example.com +DTSTAMP:20141127T123456Z +DTSTART;TZID=Europe/Oslo:20141127T160000 +DTEND;TZID=Europe/Oslo:20141127T170000 +SUMMARY:Test drive +UID:event23@example.com +END:VEVENT +END:VCALENDAR + +--===============0047278175==-- diff -r 84c6d38d2c9a -r c06cdeae95a3 tests/test_resource_invitation_constraints_quota.sh --- a/tests/test_resource_invitation_constraints_quota.sh Mon Feb 08 16:52:02 2016 +0100 +++ b/tests/test_resource_invitation_constraints_quota.sh Mon Feb 08 17:40:20 2016 +0100 @@ -303,3 +303,52 @@ && [ `grep "event22@example.com" "$JOURNALFILE" | wc -l` = '1' ] \ && echo "Success" \ || echo "Failed" + +# Increase the quota. + +echo '* PT3H' > "$JOURNAL/$QUOTA/limits" + +# Attempt to schedule an event involving both resources. + +"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-cars.txt" 2>> $ERROR + + grep -q "^20141127T150000Z${TAB}20141127T160000Z" "$FBSENDERFILE" \ +&& echo "Success" \ +|| echo "Failed" + +# Present the request to both resources. + + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-cars.txt" 2>> $ERROR \ +| tee out8r.tmp \ +| "$SHOWMAIL" \ +> out8.tmp + +# Since the email module used by showmail.py cannot stop after reading a single +# message, the second message is obtained. + + grep -n '^From ' out8r.tmp \ +| tail -n 1 \ +| cut -d ':' -f 1 \ +| xargs -I{} tail -n +'{}' out8r.tmp \ +| "$SHOWMAIL" \ +>> out8.tmp + + grep -q 'METHOD:REPLY' out8.tmp \ +&& grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out8.tmp \ +&& grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out8.tmp \ +&& echo "Success" \ +|| echo "Failed" + + ( grep -q "^20141127T150000Z${TAB}20141127T160000Z" "$FBFILE1" \ + && ! grep -q "^20141127T150000Z${TAB}20141127T160000Z" "$FBFILE2" ) \ +|| ( ! grep -q "^20141127T150000Z${TAB}20141127T160000Z" "$FBFILE1" \ + && grep -q "^20141127T150000Z${TAB}20141127T160000Z" "$FBFILE2" ) \ +&& echo "Success" \ +|| echo "Failed" + +# Check the quota (event is confirmed, but only for one resource). + + [ -e "$JOURNALFILE" ] \ +&& grep -q "event23@example.com" "$JOURNALFILE" \ +&& echo "Success" \ +|| echo "Failed"