1.1 --- a/imiptools/handlers/person.py Sun Sep 13 20:02:49 2015 +0200
1.2 +++ b/imiptools/handlers/person.py Mon Sep 14 19:03:13 2015 +0200
1.3 @@ -72,6 +72,33 @@
1.4
1.5 return True
1.6
1.7 + def _counter(self):
1.8 +
1.9 + """
1.10 + Record details from a counter-proposal, updating the stored object with
1.11 + attendance information.
1.12 + """
1.13 +
1.14 + # Obtain valid organiser and attendee details.
1.15 +
1.16 + oa = self.require_organiser_and_attendees(from_organiser=False)
1.17 + if not oa:
1.18 + return False
1.19 +
1.20 + (organiser, organiser_attr), attendees = oa
1.21 +
1.22 + # The responding attendee is regarded as not attending.
1.23 +
1.24 + for attendee, attendee_attr in attendees.items():
1.25 + attendee_attr["PARTSTAT"] = "DECLINED"
1.26 +
1.27 + # Update this attendance.
1.28 +
1.29 + if self.merge_attendance(attendees):
1.30 + self.update_freebusy_from_attendees(attendees)
1.31 +
1.32 + return True
1.33 +
1.34 def _record(self, from_organiser=True, queue=False, cancel=False):
1.35
1.36 """
1.37 @@ -224,9 +251,12 @@
1.38
1.39 def counter(self):
1.40
1.41 + "Record a counter-proposal to a proposed event."
1.42 +
1.43 # NOTE: Queue a suggested modification to any active event.
1.44
1.45 - return self.wrap("A counter proposal to an event invitation has been received.", link=False)
1.46 + if self._counter():
1.47 + return self.wrap("A counter proposal to an event invitation has been received.", link=False)
1.48
1.49 def declinecounter(self):
1.50
2.1 --- a/tests/test_resource_invitation_constraints.sh Sun Sep 13 20:02:49 2015 +0200
2.2 +++ b/tests/test_resource_invitation_constraints.sh Mon Sep 14 19:03:13 2015 +0200
2.3 @@ -3,6 +3,7 @@
2.4 THIS_DIR=`dirname $0`
2.5
2.6 TEMPLATES="$THIS_DIR/templates"
2.7 +PERSON_SCRIPT="$THIS_DIR/../imip_person.py"
2.8 RESOURCE_SCRIPT="$THIS_DIR/../imip_resource.py"
2.9 SHOWMAIL="$THIS_DIR/../tools/showmail.py"
2.10 STORE=/tmp/store
2.11 @@ -10,10 +11,17 @@
2.12 PREFS=/tmp/prefs
2.13 ARGS="-S $STORE -P $STATIC -p $PREFS -d"
2.14 USER="mailto:resource-room-sauna@example.com"
2.15 +SENDER="mailto:paul.boddie@example.com"
2.16 +RIVALSENDER="mailto:vincent.vole@example.com"
2.17 FBFILE="$STORE/$USER/freebusy"
2.18 FBOFFERFILE="$STORE/$USER/freebusy-offers"
2.19 +FBSENDERFILE="$STORE/$SENDER/freebusy"
2.20 +FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER"
2.21 +FBRIVALSENDERFILE="$STORE/$RIVALSENDER/freebusy"
2.22 TAB=`printf '\t'`
2.23
2.24 +OUTGOING_SCRIPT="$THIS_DIR/../imip_person_outgoing.py"
2.25 +
2.26 ERROR=err.tmp
2.27
2.28 rm -r $STORE
2.29 @@ -37,6 +45,16 @@
2.30 && echo "Success" \
2.31 || echo "Failed"
2.32
2.33 +# Attempt to schedule an event.
2.34 +
2.35 +"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-bad.txt" 2>> $ERROR
2.36 +
2.37 + grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \
2.38 +&& echo "Success" \
2.39 +|| echo "Failed"
2.40 +
2.41 +# Present the request to the resource.
2.42 +
2.43 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-bad.txt" 2>> $ERROR \
2.44 | "$SHOWMAIL" \
2.45 > out1.tmp
2.46 @@ -55,34 +73,88 @@
2.47 && echo "Success" \
2.48 || echo "Failed"
2.49
2.50 -# Attempt to schedule an event in the proposed period.
2.51 +# Present the response to the organiser.
2.52
2.53 - "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-rival.txt" 2>> $ERROR \
2.54 + "$PERSON_SCRIPT" $ARGS < out1.tmp 2>> $ERROR \
2.55 +| tee out2r.tmp \
2.56 | "$SHOWMAIL" \
2.57 > out2.tmp
2.58
2.59 - grep -q 'METHOD:REPLY' out2.tmp \
2.60 -&& grep -q 'ATTENDEE;PARTSTAT=DECLINED' out2.tmp \
2.61 + ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDEROTHERFILE" \
2.62 +&& echo "Success" \
2.63 +|| echo "Failed"
2.64 +
2.65 + grep -q 'ATTENDEE;PARTSTAT=DECLINED' "$STORE/$SENDER/objects/event13@example.com" \
2.66 && echo "Success" \
2.67 || echo "Failed"
2.68
2.69 - "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \
2.70 +# Attempt to schedule an event in the proposed period.
2.71 +
2.72 +"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-rival.txt" 2>> $ERROR
2.73 +
2.74 + ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \
2.75 +&& grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \
2.76 +&& echo "Success" \
2.77 +|| echo "Failed"
2.78 +
2.79 +# Present the request to the resource.
2.80 +
2.81 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-rival.txt" 2>> $ERROR \
2.82 | "$SHOWMAIL" \
2.83 > out3.tmp
2.84
2.85 grep -q 'METHOD:REPLY' out3.tmp \
2.86 -&& ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151000Z/20141126T154500Z' out3.tmp \
2.87 -&& ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151500Z/20141126T154500Z' out3.tmp \
2.88 -&& ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T153000Z/20141126T154500Z' out3.tmp \
2.89 +&& grep -q 'ATTENDEE;PARTSTAT=DECLINED' out3.tmp \
2.90 +&& echo "Success" \
2.91 +|| echo "Failed"
2.92 +
2.93 +# Present the response to the organiser.
2.94 +
2.95 + "$PERSON_SCRIPT" $ARGS < out3.tmp 2>> $ERROR \
2.96 +| tee out4r.tmp \
2.97 +| "$SHOWMAIL" \
2.98 +> out4.tmp
2.99 +
2.100 + ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \
2.101 +&& grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \
2.102 +&& echo "Success" \
2.103 +|| echo "Failed"
2.104 +
2.105 + grep -q 'ATTENDEE;PARTSTAT=DECLINED' "$STORE/$RIVALSENDER/objects/event18@example.com" \
2.106 && echo "Success" \
2.107 || echo "Failed"
2.108
2.109 +# Check the free/busy state of the resource so far.
2.110 +
2.111 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \
2.112 +| "$SHOWMAIL" \
2.113 +> out5.tmp
2.114 +
2.115 + grep -q 'METHOD:REPLY' out5.tmp \
2.116 +&& ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151000Z/20141126T154500Z' out5.tmp \
2.117 +&& ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151500Z/20141126T154500Z' out5.tmp \
2.118 +&& ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T153000Z/20141126T154500Z' out5.tmp \
2.119 +&& echo "Success" \
2.120 +|| echo "Failed"
2.121 +
2.122 +# Attempt to schedule again in response to the counter-proposal.
2.123 +
2.124 +"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR
2.125 +
2.126 + ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \
2.127 +&& ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBSENDERFILE" \
2.128 +&& ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \
2.129 +&& echo "Success" \
2.130 +|| echo "Failed"
2.131 +
2.132 +# Present the request to the resource.
2.133 +
2.134 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR \
2.135 | "$SHOWMAIL" \
2.136 -> out4.tmp
2.137 +> out6.tmp
2.138
2.139 - grep -q 'METHOD:REPLY' out4.tmp \
2.140 -&& grep -q 'ATTENDEE;PARTSTAT=ACCEPTED' out4.tmp \
2.141 + grep -q 'METHOD:REPLY' out6.tmp \
2.142 +&& grep -q 'ATTENDEE;PARTSTAT=ACCEPTED' out6.tmp \
2.143 && echo "Success" \
2.144 || echo "Failed"
2.145
2.146 @@ -96,12 +168,29 @@
2.147 && echo "Success" \
2.148 || echo "Failed"
2.149
2.150 +# Present the response to the organiser.
2.151 +
2.152 + "$PERSON_SCRIPT" $ARGS < out6.tmp 2>> $ERROR \
2.153 +| tee out7r.tmp \
2.154 +| "$SHOWMAIL" \
2.155 +> out7.tmp
2.156 +
2.157 + grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \
2.158 +&& ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \
2.159 +&& ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBSENDERFILE" \
2.160 +&& ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \
2.161 +&& echo "Success" \
2.162 +|| echo "Failed"
2.163 +
2.164 +# Check the free/busy state of the resource again.
2.165 +
2.166 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \
2.167 | "$SHOWMAIL" \
2.168 > out6.tmp
2.169
2.170 grep -q 'METHOD:REPLY' out6.tmp \
2.171 && grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T150000Z/20141126T154500Z' out6.tmp \
2.172 +&& ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151000Z/20141126T154500Z' out6.tmp \
2.173 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151500Z/20141126T154500Z' out6.tmp \
2.174 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T153000Z/20141126T154500Z' out6.tmp \
2.175 && echo "Success" \