|
From: <jgr...@us...> - 2003-07-27 21:13:43
|
Update of /cvsroot/popfile/engine/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv16357/tests
Modified Files:
TestBayes.tst
Log Message:
Finished test suite for Bayes except for the generation of HTML for the UI which I'll leave until I do the test suite for UI::HTML; have 88% coverage of Classifier::Bayes
Index: TestBayes.tst
===================================================================
RCS file: /cvsroot/popfile/engine/tests/TestBayes.tst,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** TestBayes.tst 27 Jul 2003 20:00:31 -0000 1.18
--- TestBayes.tst 27 Jul 2003 21:13:40 -0000 1.19
***************
*** 446,450 ****
}
! # glob the tests directory for files called TestMailParse\d+.msg which consist of messages
# to be sent through classify_and_modify
--- 446,450 ----
}
! # glob the tests directory for files called TestMailParse\d+.msg which consist of messages
# to be sent through classify_and_modify
***************
*** 664,667 ****
--- 664,751 ----
close MAIL;
close TEMP;
+
+ # test quarantining of a message
+
+ $b->global_config_( 'msgdir', 'messages/' );
+ $b->set_bucket_parameter( 'spam', 'quarantine', 1 );
+
+ open CLIENT, ">temp.tmp";
+ open MAIL, "<messages/one.msg";
+ my ( $class, $nopath ) = $b->classify_and_modify( \*MAIL, \*CLIENT, 0, 0, 0, '', 1 );
+ close CLIENT;
+ close MAIL;
+
+ test_assert_equal( $class, 'spam' );
+ test_assert( -e 'messages/popfile0=0.msg' );
+ test_assert( -e 'messages/popfile0=0.cls' );
+
+ my ( $reclassified, $bucket, $usedtobe, $magnet ) = $b->history_read_class( 'popfile0=0.msg' );
+ test_assert( !$reclassified );
+ test_assert_equal( $bucket, 'spam' );
+ test_assert( !defined( $usedtobe ) );
+ test_assert_equal( $magnet, '' );
+
+ my @lookfor = ( '--popfile0=0.msg', 'Quarantined Message Detail', ' This is the body', '--popfile0=0.msg', '--popfile0=0.msg--', '.' );
+ open CLIENT, "<temp.tmp";
+ while ( $#lookfor > -1 ) {
+ test_assert( !eof( CLIENT ) );
+ my $search = shift @lookfor;
+ while ( <CLIENT> ) {
+ if ( /^\Q$search\E/ ) {
+ last;
+ }
+ }
+ }
+ close CLIENT;
+
+ # test no save option
+
+ unlink( 'messages/popfile0=0.cls' );
+ unlink( 'messages/popfile0=0.msg' );
+ open CLIENT, ">temp.tmp";
+ open MAIL, "<messages/one.msg";
+ my ( $class, $nopath ) = $b->classify_and_modify( \*MAIL, \*CLIENT, 0, 0, 1, '', 1 );
+ close CLIENT;
+ close MAIL;
+
+ test_assert_equal( $class, 'spam' );
+ test_assert( !( -e 'messages/popfile0=0.msg' ) );
+ test_assert( !( -e 'messages/popfile0=0.cls' ) );
+
+ # test no echo option
+
+ open CLIENT, ">temp.tmp";
+ open MAIL, "<messages/one.msg";
+ my ( $class, $nopath ) = $b->classify_and_modify( \*MAIL, \*CLIENT, 0, 0, 0, '', 0 );
+ close CLIENT;
+ close MAIL;
+
+ test_assert_equal( $class, 'spam' );
+ test_assert( -e 'messages/popfile0=0.msg' );
+ test_assert( -e 'messages/popfile0=0.cls' );
+
+ test_assert_equal( ( -s 'temp.tmp' ), 0 );
+
+ # test option where we know the classification
+
+ open CLIENT, ">temp.tmp";
+ open MAIL, "<messages/one.msg";
+ my ( $class, $nopath ) = $b->classify_and_modify( \*MAIL, \*CLIENT, 0, 0, 0, 'other', 1 );
+ close CLIENT;
+ close MAIL;
+
+ test_assert_equal( $class, 'other' );
+ test_assert( -e 'messages/popfile0=0.msg' );
+ test_assert( -e 'messages/popfile0=0.cls' );
+
+ my ( $reclassified, $bucket, $usedtobe, $magnet ) = $b->history_read_class( 'popfile0=0.msg' );
+ test_assert( !$reclassified );
+ test_assert_equal( $bucket, 'other' );
+ test_assert( !defined( $usedtobe ) );
+ test_assert_equal( $magnet, '' );
+
+ # Test X-POPFile-TimeoutPrevention header insertion
+
+ # TODO
# TODO test that stop writes the parameters to disk
|