|
From: <jgr...@us...> - 2003-07-27 01:38:01
|
Update of /cvsroot/popfile/engine/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv21492/tests
Modified Files:
TestBayes.tst TestMailParse.tst
Log Message:
Tests for Bayes API functions
Index: TestBayes.tst
===================================================================
RCS file: /cvsroot/popfile/engine/tests/TestBayes.tst,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** TestBayes.tst 26 Jul 2003 14:59:47 -0000 1.13
--- TestBayes.tst 27 Jul 2003 01:37:58 -0000 1.14
***************
*** 36,42 ****
$b->logger( $l );
-
$b->initialize();
! $b->start();
# getting and setting values
--- 36,211 ----
$b->logger( $l );
$b->initialize();
! test_assert( $b->start() );
!
! # test the API functions
!
! # get_buckets
!
! my @buckets = $b->get_buckets();
! test_assert_equal( $#buckets, 2 );
! test_assert_equal( $buckets[0], 'other' );
! test_assert_equal( $buckets[1], 'personal' );
! test_assert_equal( $buckets[2], 'spam' );
!
! # get_bucket_word_count
!
! test_assert_equal( $b->get_bucket_word_count($buckets[0]), 1785 );
! test_assert_equal( $b->get_bucket_word_count($buckets[1]), 103 );
! test_assert_equal( $b->get_bucket_word_count($buckets[2]), 12114 );
!
! # get_bucket_word_list
!
! # TODO
!
! # get_word_count
!
! test_assert_equal( $b->get_word_count(), 14002 );
!
! # get_count_for_word
!
! test_assert_equal( $b->get_count_for_word($buckets[0], 'foo'), 0 );
! test_assert_equal( $b->get_count_for_word($buckets[1], 'foo'), 1 );
! test_assert_equal( $b->get_count_for_word($buckets[2], 'foo'), 0 );
!
! # get_bucket_unique_count
!
! test_assert_equal( $b->get_bucket_unique_count($buckets[0]), 656 );
! test_assert_equal( $b->get_bucket_unique_count($buckets[1]), 3 );
! test_assert_equal( $b->get_bucket_unique_count($buckets[2]), 3353 );
!
! # get_bucket_color
!
! test_assert_equal( $b->get_bucket_color($buckets[0]), 'red' );
! test_assert_equal( $b->get_bucket_color($buckets[1]), 'green' );
! test_assert_equal( $b->get_bucket_color($buckets[2]), 'blue' );
!
! # set_bucket_color
!
! test_assert_equal( $b->get_bucket_color($buckets[0]), 'red' );
! $b->set_bucket_color( $buckets[0], 'yellow' );
! test_assert_equal( $b->get_bucket_color($buckets[0]), 'yellow' );
! $b->set_bucket_color( $buckets[0], 'red' );
! test_assert_equal( $b->get_bucket_color($buckets[0]), 'red' );
!
! # get_bucket_parameter
!
! test_assert_equal( $b->get_bucket_parameter( $buckets[0], 'dummy' ), 0 );
! test_assert_equal( $b->get_bucket_parameter( $buckets[0], 'quarantine' ), 0 );
! test_assert_equal( $b->get_bucket_parameter( $buckets[0], 'subject' ), 1 );
!
! # set_bucket_parameter
!
! test_assert_equal( $b->get_bucket_parameter( $buckets[0], 'dummy2' ), 0 );
! $b->set_bucket_parameter( $buckets[0], 'dummy2', 'value' );
! test_assert_equal( $b->get_bucket_parameter( $buckets[0], 'dummy2' ), 'value' );
! my $found = 0;
! open FILE, "<corpus/$buckets[0]/params";
! while( <FILE> ) {
! if ( /dummy2 value/ ) {
! $found = 1;
! last;
! }
! }
! close FILE;
! test_assert( $found );
! $b->set_bucket_parameter( $buckets[0], 'dummy2', 0 );
! test_assert_equal( $b->get_bucket_parameter( $buckets[0], 'dummy2' ), 0 );
!
! # get_html_colored_message
!
! my $html = $b->get_html_colored_message( 'TestMailParse019.msg' );
! open FILE, "<TestMailParse019.clr";
! my $check = <FILE>;
! close FILE;
! # TODO test_assert_equal( $html, $check );
!
! if ( $html ne $check ) {
! my $color_test = 'get_html_colored_message';
! open FILE, ">$color_test.expecting.html";
! print FILE $check;
! close FILE;
! open FILE, ">$color_test.got.html";
! print FILE $html;
! close FILE;
! }
!
! # create_bucket
!
! $b->create_bucket( 'zebra' );
!
! @buckets = $b->get_buckets();
! test_assert_equal( $#buckets, 3 );
! test_assert_equal( $buckets[0], 'other' );
! test_assert_equal( $buckets[1], 'personal' );
! test_assert_equal( $buckets[2], 'spam' );
! test_assert_equal( $buckets[3], 'zebra' );
!
! test_assert_equal( $b->get_bucket_parameter( 'zebra', 'count' ), 0 );
! test_assert_equal( $b->get_bucket_parameter( 'zebra', 'subject' ), 1 );
! test_assert_equal( $b->get_bucket_parameter( 'zebra', 'quarantine' ), 0 );
!
! test_assert_equal( $b->get_bucket_word_count( 'zebra' ), 0 );
! test_assert_equal( $b->get_bucket_unique_count( 'zebra' ), 0 );
!
! test_assert_equal( $b->get_word_count(), 14002 );
!
! test_assert( -e 'corpus/zebra' );
! test_assert( -e 'corpus/zebra/table' );
!
! open FILE, "<corpus/zebra/table";
! my $line = <FILE>;
! test_assert_regexp( $line, '__CORPUS__ __VERSION__ 1' );
! close FILE;
!
! # rename_bucket
!
! test_assert( !$b->rename_bucket( 'none', 'some' ) );
! test_assert( $b->rename_bucket( 'zebra', 'zeotrope' ) );
!
! @buckets = $b->get_buckets();
! test_assert_equal( $#buckets, 3 );
! test_assert_equal( $buckets[0], 'other' );
! test_assert_equal( $buckets[1], 'personal' );
! test_assert_equal( $buckets[2], 'spam' );
! test_assert_equal( $buckets[3], 'zeotrope' );
!
! test_assert_equal( $b->get_bucket_parameter( 'zeotrope', 'count' ), 0 );
! test_assert_equal( $b->get_bucket_parameter( 'zeotrope', 'subject' ), 1 );
! test_assert_equal( $b->get_bucket_parameter( 'zeotrope', 'quarantine' ), 0 );
!
! test_assert_equal( $b->get_bucket_word_count( 'zeotrope' ), 0 );
! test_assert_equal( $b->get_bucket_unique_count( 'zeotrope' ), 0 );
!
! test_assert_equal( $b->get_word_count(), 14002 );
!
! test_assert( -e 'corpus/zeotrope' );
! test_assert( -e 'corpus/zeotrope/table' );
!
! open FILE, "<corpus/zeotrope/table";
! $line = <FILE>;
! test_assert_regexp( $line, '__CORPUS__ __VERSION__ 1' );
! close FILE;
!
! # add_message_to_bucket
!
! # remove_message_from_bucket
!
! # add_messages_to_bucket
!
! # delete_bucket
!
! test_assert( !$b->delete_bucket( 'zebrazerba' ) );
! test_assert( $b->delete_bucket( 'zeotrope' ) );
! test_assert( !( -e 'corpus/zeotrope/table' ) );
! test_assert( !( -e 'corpus/zeotrope' ) );
!
! @buckets = $b->get_buckets();
! test_assert_equal( $#buckets, 2 );
! test_assert_equal( $buckets[0], 'other' );
! test_assert_equal( $buckets[1], 'personal' );
! test_assert_equal( $buckets[2], 'spam' );
!
!
# getting and setting values
***************
*** 49,59 ****
test_assert_equal( $b->get_value_( 'personal', 'foo' ), -log(10) );
! # test the API functions
! my @buckets = $b->get_buckets();
! test_assert_equal( $buckets[0], '' );
! test_assert_equal( $buckets[1], '' );
! test_assert_equal( $buckets[2], '' );
!
! # glob the tests directory for files called TestMailParse\d+.msg which consist of messages
# to be parsed with the resulting classification in TestMailParse.cls
--- 218,222 ----
test_assert_equal( $b->get_value_( 'personal', 'foo' ), -log(10) );
! # glob the tests directory for files called TestMailParse\d+.msg which consist of messages
# to be parsed with the resulting classification in TestMailParse.cls
***************
*** 70,74 ****
close CLASS;
}
!
test_assert_equal( $b->classify( $class_test ), $class, $class_test );
}
--- 233,237 ----
close CLASS;
}
!
test_assert_equal( $b->classify( $class_test ), $class, $class_test );
}
Index: TestMailParse.tst
===================================================================
RCS file: /cvsroot/popfile/engine/tests/TestMailParse.tst,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** TestMailParse.tst 26 Jul 2003 22:53:24 -0000 1.15
--- TestMailParse.tst 27 Jul 2003 01:37:58 -0000 1.16
***************
*** 40,46 ****
$b->logger( $l );
-
$b->initialize();
! $b->start();
my $cl = new Classifier::MailParse;
--- 40,45 ----
$b->logger( $l );
$b->initialize();
! test_assert( $b->start() );
my $cl = new Classifier::MailParse;
***************
*** 206,213 ****
if ( $check ne $html ) {
! open FILE, ">$color_test.expecting";
print FILE $check;
close FILE;
! open FILE, ">$color_test.got";
print FILE $html;
close FILE;
--- 205,212 ----
if ( $check ne $html ) {
! open FILE, ">$color_test.expecting.html";
print FILE $check;
close FILE;
! open FILE, ">$color_test.got.html";
print FILE $html;
close FILE;
|