From: <cra...@us...> - 2003-05-10 14:12:00
|
Update of /cvsroot/twikiplugins/twikiplugins/ActionTrackerPlugin/lib/TWiki/Plugins/ActionTrackerPlugin/test In directory sc8-pr-cvs1:/tmp/cvs-serv1676/ActionTrackerPlugin/lib/TWiki/Plugins/ActionTrackerPlugin/test Modified Files: ActionNotifyTests.pm Log Message: Release candidate 1 for 10 May release Index: ActionNotifyTests.pm =================================================================== RCS file: /cvsroot/twikiplugins/twikiplugins/ActionTrackerPlugin/lib/TWiki/Plugins/ActionTrackerPlugin/test/ActionNotifyTests.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ActionNotifyTests.pm 8 May 2003 20:54:56 -0000 1.2 --- ActionNotifyTests.pm 10 May 2003 14:11:56 -0000 1.3 *************** *** 14,19 **** { package ActionNotifyTests; sub setUp { - ActionTrackerPlugin::Action::forceTime("2 Jan 2002"); TWiki::TestMaker::init("ActionTrackerPlugin"); --- 14,51 ---- { package ActionNotifyTests; + # Actor 1 - wikiname in main, not a member of any groups + # email: actor-1\@an-address.net + # Should be notified with: A3 A6 + # Actor 2 - wikiname in main and member of emailgroup only + # email: actorTwo\@another-address.net + # Should be notified with: A3 A5 A6 + # Actor 3 - wikiname in main and member of twikigroup only + # email: actor3\@yet-another-address.net + # Should be notified with: A3 A4 A6 + # Actor 4 - wikiname in main and member of emailgroup and twikigroup + # email: actorfour\@yet-another-address.net + # Should be notified with: A3 A4 A5 A6 + # Actor 5 - wikiname in main, address in Main.WebNotify + # email: actor5\@correct.address + # Should be notified with: A3 A6 A7 + # Actor 6 - wikiname in main and wrong address in Main.WebNotify + # email: actor6\@correct-address + # Should be notified with: A3 A6 A8 + # Actor 7 - email address on action line + # email: actor.7\@seven.net + # Should be notified with: A3 A6 + # Actor 8 - no topic in main, address in Test.WebNotify + # email: actor-8\@correct.address + # Should be notified with: A3 A6 A8 + + # A1 - on time - should never be notified + # A2 - closed - should never be notified + # A3 - open, late - notify everybody + # A4 - notify TWikiFormGroup, Actor3,Actor4 + # A5 - notify EMailGroup, Actor2,Actor4 + # A6 - notify everyone many times + # A7 - notify changes to Actor5 + # A8 - notify changes to Actor6, Actor8 sub setUp { TWiki::TestMaker::init("ActionTrackerPlugin"); *************** *** 53,63 **** %ACTION{who=\"ActorOne,ActorTwo,ActorThree,ActorFour,ActorFive,ActorSix,ActorSeven,ActorEight\" due=\"3 Jan 02\" state=open}% A1: ontime"); TWiki::TestMaker::writeTopic("Test", "Topic2", " ! %ACTION{who=\"ActorOne,ActorTwo,ActorThree,ActorFour,ActorFive,ActorSix,actor.7\@seven.net,ActorEight\" due=\"3 Jan 02\" state=closed}% A2: closed"); TWiki::TestMaker::writeTopic("Main", "Topic1", " %ACTION{who=\"ActorOne,ActorTwo,ActorThree,ActorFour,ActorFive,ActorSix,actor.7\@seven.net,ActorEight\",due=\"3 Jan 01\",state=open}% A3: late ! %ACTION{who=TWikiFormGroup,due=\"3 Jan 01\",state=open}% A4: late "); TWiki::TestMaker::writeTopic("Main", "Topic2", " ! %ACTION{who=EMailGroup,due=\"3 Jan 01\",state=open}% A5: late ! %ACTION{who=\"ActorOne,ActorTwo,ActorThree,ActorFour,TWikiFormGroup,ActorFive,ActorSix,actor.7\@seven.net,ActorEight,EMailGroup\",due=\"3 Jan 99\",open}% A6: late"); # Action changes are hard to fake because the RCS files are not there. --- 85,95 ---- %ACTION{who=\"ActorOne,ActorTwo,ActorThree,ActorFour,ActorFive,ActorSix,ActorSeven,ActorEight\" due=\"3 Jan 02\" state=open}% A1: ontime"); TWiki::TestMaker::writeTopic("Test", "Topic2", " ! %ACTION{who=\"ActorOne,ActorTwo,ActorThree,ActorFour,ActorFive,ActorSix,actor.7\@seven.net,ActorEight\" due=\"2 Jan 02\" state=closed}% A2: closed"); TWiki::TestMaker::writeTopic("Main", "Topic1", " %ACTION{who=\"ActorOne,ActorTwo,ActorThree,ActorFour,ActorFive,ActorSix,actor.7\@seven.net,ActorEight\",due=\"3 Jan 01\",state=open}% A3: late ! %ACTION{who=TWikiFormGroup,due=\"4 Jan 01\",state=open}% A4: late "); TWiki::TestMaker::writeTopic("Main", "Topic2", " ! %ACTION{who=EMailGroup,due=\"5 Jan 01\",state=open}% A5: late ! %ACTION{who=\"ActorOne,ActorTwo,ActorThree,ActorFour,TWikiFormGroup,ActorFive,ActorSix,actor.7\@seven.net,ActorEight,EMailGroup\",due=\"6 Jan 99\",open}% A6: late"); # Action changes are hard to fake because the RCS files are not there. *************** *** 93,98 **** \@%META:TOPICINFO{author=\"guest\" date=\"1032890093\" format=\"1.0\" version=\"1.2\"}% %ACTION{who=ActorFive,due=\"22-jun-2002\",notify=Main.ActorFive}% A7: Date change ! %ACTION{who=ActorFive,due=\"22-jun-2002\"}% Stuck in ! %ACTION{who=ActorFour,due=\"22-jul-2001\",notify=\"Main.ActorSix,Main.ActorEight\"}% A8: Text change from original \@ --- 125,130 ---- \@%META:TOPICINFO{author=\"guest\" date=\"1032890093\" format=\"1.0\" version=\"1.2\"}% %ACTION{who=ActorFive,due=\"22-jun-2002\",notify=Main.ActorFive}% A7: Date change ! %ACTION{who=ActorFive,due=\"22-jun-2002\" notify=Main.ActorOne}% Stuck in ! %ACTION{who=ActorSix,due=\"22-jul-2001\",notify=\"Main.ActorSix,Main.ActorEight\"}% A8: Text change from original, late \@ *************** *** 112,157 **** } ! sub testWholeShebang { ! # Do the whole shebang; the output generation is rather dependent on the ! # correct format of the template, however... ActionTrackerPlugin::ActionNotify::actionNotify( "late" ); Assert::equals(scalar(@TWiki::Net::sent), 8); my $html; - # Actor 1 - wikiname in main, not a member of any groups - #actor-1\@an-address.net - #A3 A6 - # Actor 2 - wikiname in main and member of emailgroup only - #actorTwo\@another-address.net - #A3 A5 A6 - # Actor 3 - wikiname in main and member of twikigroup only - #actor3\@yet-another-address.net - #A3 A4 A6 - # Actor 4 - wikiname in main and member of emailgroup and twikigroup - #actorfour\@yet-another-address.net - #A3 A4 A5 A6 - # Actor 5 - wikiname in main, address in Main.WebNotify - #actor5\@correct.address - #A3 A6 A7 - # Actor 6 - wikiname in main and wrong address in Main.WebNotify - #actor6\@correct-address - #A3 A6 A8 - # Actor 7 - email address on action line - #actor.7\@seven.net - #A3 A6 - # Actor 8 - no topic in main, address in Test.WebNotify - #actor-8\@correct.address - #A3 A6 A8 - - # A1 - on time - # A2 - closed - # A3 - open, late - # A4 - notify TWikiGroup - # A5 - notify EMailGroup - # A6 - notify everyone many times my $ok = ""; while ( $html = shift(@TWiki::Net::sent)) { ! Assert::assert($html !~ /A[1|2]/, $html); ! Assert::assert($html !~ /^To: (.*),/os); #$html =~ /To: (.*)/; #print STDERR "Shebang $1\n"; --- 144,157 ---- } ! sub testANotifyLate { ! ActionTrackerPlugin::Action::forceTime("2 Jan 2002"); ActionTrackerPlugin::ActionNotify::actionNotify( "late" ); Assert::equals(scalar(@TWiki::Net::sent), 8); my $html; my $ok = ""; while ( $html = shift(@TWiki::Net::sent)) { ! Assert::assert($html !~ /A[12]:/, $html); ! #Assert::assert($html !~ /^To: (.*),/os); #$html =~ /To: (.*)/; #print STDERR "Shebang $1\n"; *************** *** 161,164 **** --- 161,166 ---- Assert::assert($html !~ /A5:/,$html); Assert::assert($html =~ /A6:/,$html); + Assert::assert($html !~ /A7:/,$html); + Assert::assert($html !~ /A8:/,$html); $ok .= "A"; } elsif ($html =~ /To: actorTwo\@another-address\.net/) { *************** *** 167,170 **** --- 169,174 ---- Assert::assert($html =~ /A5:/,$html); Assert::assert($html =~ /A6:/,$html); + Assert::assert($html !~ /A7:/,$html); + Assert::assert($html !~ /A8:/,$html); $ok .= "B"; } elsif ($html =~ /To: actor3\@yet-another-address\.net/) { *************** *** 173,176 **** --- 177,182 ---- Assert::assert($html !~ /A5:/,$html); Assert::assert($html =~ /A6:/,$html); + Assert::assert($html !~ /A7:/,$html); + Assert::assert($html !~ /A8:/,$html); $ok .= "C"; } elsif ($html =~ /To: actorfour\@yet-another-address\.net/) { *************** *** 179,182 **** --- 185,190 ---- Assert::assert($html =~ /A5:/,$html); Assert::assert($html =~ /A6:/,$html); + Assert::assert($html !~ /A7:/,$html); + Assert::assert($html !~ /A8:/,$html); $ok .= "D"; } elsif ($html =~ /To: actor5\@correct.address/) { *************** *** 185,188 **** --- 193,198 ---- Assert::assert($html !~ /A5:/,$html); Assert::assert($html =~ /A6:/,$html); + Assert::assert($html !~ /A7:/,$html); + Assert::assert($html !~ /A8:/,$html); $ok .= "E"; } elsif ($html =~ /To: actor6\@correct-address/) { *************** *** 191,194 **** --- 201,206 ---- Assert::assert($html !~ /A5:/,$html); Assert::assert($html =~ /A6:/,$html); + Assert::assert($html !~ /A7:/,$html); + Assert::assert($html =~ /A8:/,$html); $ok .= "F"; } elsif ($html =~ /To: actor\.7\@seven\.net/) { *************** *** 197,200 **** --- 209,214 ---- Assert::assert($html !~ /A5:/,$html); Assert::assert($html =~ /A6:/,$html); + Assert::assert($html !~ /A7:/,$html); + Assert::assert($html !~ /A8:/,$html); $ok .= "G"; } elsif ($html =~ /To: actor-8\@correct\.address/) { *************** *** 203,206 **** --- 217,222 ---- Assert::assert($html !~ /A5:/,$html); Assert::assert($html =~ /A6:/,$html); + Assert::assert($html !~ /A7:/,$html); + Assert::assert($html !~ /A8:/,$html); $ok .= "H"; } else { *************** *** 218,234 **** Assert::sContains($ok, "H"); } - #actor5\@correct.address - #A3 A6 A7 - # Actor 6 - wikiname in main and wrong address in Main.WebNotify - #actor6\@correct-address - #A3 A6 A8 - # Actor 8 - no topic in main, address in Test.WebNotify - #actor-8\@correct.address - #A3 A6 A8 ! sub testChangedSince { ActionTrackerPlugin::ActionNotify::actionNotify( "changedsince=\"1 dec 2001\"" ); Assert::equals(scalar(@TWiki::Net::sent), 3); ! my %saw; while( $html = shift(@TWiki::Net::sent) ) { Assert::sContains($html, "From: mailsender"); --- 234,243 ---- Assert::sContains($ok, "H"); } ! sub testBChangedSince { ! ActionTrackerPlugin::Action::forceTime("2 Jan 2002"); ActionTrackerPlugin::ActionNotify::actionNotify( "changedsince=\"1 dec 2001\"" ); Assert::equals(scalar(@TWiki::Net::sent), 3); ! my $saw = ""; while( $html = shift(@TWiki::Net::sent) ) { Assert::sContains($html, "From: mailsender"); *************** *** 238,269 **** Assert::sContains($html, "Changes to actions since Sat Dec 1 00:00:00 2001"); Assert::sContains($html, "Attribute \"due\" changed, was \"Fri, 22 Jun 2001 (LATE)\", now \"Sat, 22 Jun 2002\""); ! $saw{1} = 1; } elsif ($html =~ /To: actor6\@correct-address/) { ! Assert::assert($html !~ /A3:/,$html); ! Assert::assert($html !~ /A4:/,$html); ! Assert::assert($html !~ /A5:/,$html); ! Assert::assert($html !~ /A6:/,$html); ! Assert::assert($html !~ /A7:/,$html); Assert::assert($html =~ /A8:/,$html); ! Assert::sContains($html, "Attribute \"text\" changed, was \"A8: Text change\", now \"A8: Text change from original\""); ! Assert::htmlContains($html, "<tr><td>text</td><td> A8: Text change</td><td> A8: Text change from original</td></tr>"); ! $saw{2} = 1; } elsif ($html =~ /To: actor-8\@correct.address/) { ! Assert::assert($html !~ /A3:/,$html); ! Assert::assert($html !~ /A4:/,$html); ! Assert::assert($html !~ /A5:/,$html); ! Assert::assert($html !~ /A6:/,$html); ! Assert::assert($html !~ /A7:/,$html); Assert::assert($html =~ /A8:/,$html); ! Assert::sContains($html, "Attribute \"text\" changed, was \"A8: Text change\", now \"A8: Text change from original\""); ! Assert::htmlContains($html, "<tr><td>text</td><td> A8: Text change</td><td> A8: Text change from original</td></tr>"); ! $saw{3} = 1; } else { Assert::assert(0, "Not good $html"); } } ! Assert::assert($saw{1} == 1,"Arg"); ! Assert::assert($saw{2} == 1,"Arrgh"); ! Assert::assert($saw{3} == 1,"Aaaaaargh"); } } --- 247,321 ---- Assert::sContains($html, "Changes to actions since Sat Dec 1 00:00:00 2001"); Assert::sContains($html, "Attribute \"due\" changed, was \"Fri, 22 Jun 2001 (LATE)\", now \"Sat, 22 Jun 2002\""); ! $saw .= "A"; } elsif ($html =~ /To: actor6\@correct-address/) { ! Assert::assert($html !~ /A[1234567]:/,$html); Assert::assert($html =~ /A8:/,$html); ! Assert::sContains($html, "Attribute \"text\" changed, was \"A8: Text change\", now \"A8: Text change from original, late\""); ! Assert::htmlContains($html, "<tr><td>text</td><td> A8: Text change</td><td> A8: Text change from original, late</td></tr>"); ! $saw .= "B"; } elsif ($html =~ /To: actor-8\@correct.address/) { ! Assert::assert($html !~ /A[1234567]:/,$html); Assert::assert($html =~ /A8:/,$html); ! Assert::sContains($html, "Attribute \"text\" changed, was \"A8: Text change\", now \"A8: Text change from original, late\""); ! Assert::htmlContains($html, "<tr><td>text</td><td> A8: Text change</td><td> A8: Text change from original, late</td></tr>"); ! $saw .= "C"; } else { Assert::assert(0, "Not good $html"); } } ! Assert::equals(length($saw), 3, $saw); ! Assert::sContains($saw, "A"); ! Assert::sContains($saw, "B"); ! Assert::sContains($saw, "C"); ! } ! ! # should notify A8, to Actor6 and Actor8, A7 to Actor5 and ! # A8 to Actor 6 late ! sub testCNotifyLateAndChanged { ! ActionTrackerPlugin::Action::forceTime("2 Jan 2002"); ! ActionTrackerPlugin::ActionNotify::actionNotify( "due=22-Jul-2001,changedsince=\"1 dec 2001\"" ); ! Assert::equals(scalar(@TWiki::Net::sent), 3); ! my $html; ! ! my $ok = ""; ! while ( $html = shift(@TWiki::Net::sent)) { ! if ($html =~ /To: actor6\@correct-address/) { ! Assert::assert($html !~ /A[1234567]:/,$html); ! Assert::assert($html =~ /A8:/,$html); ! Assert::sContains($html, "Action for Main.ActorSix, due Sun, 22 Jul 2001 (LATE), open"); ! Assert::sContains($html, "Attribute \"text\" changed, was \"A8: Text change\", now \"A8: Text change from original, late\""); ! $ok .= "A"; ! # deconstruct ! $html =~ /.*?attention follow:(.*?)Changes to.*?with the action\.(.*?)For help /so; ! my $acts = $1; ! my $chgs = $2; ! $acts =~ s/Action for Main.ActorSix, due Sun, 22 Jul 2001 \(LATE\), open//so; ! $acts =~ s/A8: Text change from original, late//so; ! $chgs =~ s/Action for Main.ActorSix, due Sun, 22 Jul 2001 \(LATE\), open//so; ! $chgs =~ s/- Attribute \"text\" changed, was \"A8: Text change\", now \"A8: Text change from original, late\"//so; ! $chgs =~ s/A8: Text change from original, late//so; ! $acts =~ s/\s+//so; ! Assert::sEquals($acts,""); ! $chgs =~ s/\s+//so; ! Assert::sEquals($chgs,""); ! } elsif ($html =~ /To: actor-8\@correct\.address/) { ! Assert::assert($html !~ /A[1234567]:/,$html); ! Assert::assert($html =~ /A8:/,$html); ! Assert::sContains($html, "Action for Main.ActorSix, due Sun, 22 Jul 2001 (LATE), open"); ! Assert::sContains($html, "Attribute \"text\" changed, was \"A8: Text change\", now \"A8: Text change from original, late\""); ! $ok .= "B"; ! } elsif ($html=~ /To: actor5\@correct.address/) { ! Assert::sContains($html, "Subject: Changes to actions on mailsender"); ! Assert::sContains($html, "Changes to actions since Sat Dec 1 00:00:00 2001"); ! Assert::sContains($html, "Attribute \"due\" changed, was \"Fri, 22 Jun 2001 (LATE)\", now \"Sat, 22 Jun 2002\""); ! $ok .= "C"; ! } else { ! Assert::assert(0, $html); ! } ! } ! Assert::equals(length($ok),3); ! Assert::sContains($ok, "A"); ! Assert::sContains($ok, "B"); ! Assert::sContains($ok, "C"); } } |