|
From: <jgr...@us...> - 2003-11-10 19:55:41
|
Update of /cvsroot/popfile/engine/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv311/tests
Modified Files:
TestWordMangle.tst TestPOP3.tst TestMailParse.tst
TestBayes.tst TestHTTP.tst
Log Message:
Multi-user Phase #1
-------------------
Make POPFile work relative to two special environment variables:
POPFILE_ROOT The location where popfile.pl is installed
POPFILE_USER The location where this user's config is kept
POPFile/Module.pm:
Add two methods
get_root_path_
get_user_path_
that convert passed in relative paths to absolute paths relative
to either POPFILE_ROOT or POPFILE_USER. This two helpers simply
call the relevant public interface in POPFile/Configuration.pm.
POPFile/Configuration.pm:
Add two methods
get_root_path
get_user_path
that convert passed in relative paths to absolute paths relative
to either POPFILE_ROOT or POPFILE_USER.
Classifer/WordMangle.pm:
Make this a PLM (with name 'wordmangle') so that it can get access
to the POPFILE_USER variable so that stopwords are per user.
Classifier/Bayes.pm:
Remove unused Classifier::WordMangle object.
Change all path usage to call get_user_path_ to set the path
correctly relative to the current user.
UI/HTML.pm:
Change path usage to call get_root_path_ or get_user_path_ to get
the path relative to the current root or user. The root is used to
access skins, manual and language files. Everything else is in the
user directory.
POPFile/Module.pm:
Use the POPFILE_ROOT to control the loading of modules.
popfile.pl:
If POPFILE_ROOT is defined the add it to @INC so that we can load
the POPFile::Loader module.
tests/TestWordMangle.tst:
Since Classifier::WordMangle is now a PLM the tests need to be
updated to load the mangler correctly and link it in with the
other POPFile modules that is depends on.
tests/TestPOP3.tst
tests/TestMailParse.tst
tests/TestBayes.tst:
Since Classifier::WordMangle is now a PLM test suites that relied
upon Classifier::MailParse creating the mangler needed updating to
actually create and pass in the mangler object.
tests/TestHTTP.tst:
Make tests work on non-Windows systems. One test was relying on
\n being \r\n.
TODO
Write tests for get_user_path and get_root_path, is_absolute_path,
root_path and path_join
Write tests for POPFILE_ROOT and POPFILE_USER
Make HTML test suite run on Linux
Debug MailParse test suite, fix Japanese handling (026).
Debug POP3 suite/TOP handling
Index: TestWordMangle.tst
===================================================================
RCS file: /cvsroot/popfile/engine/tests/TestWordMangle.tst,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** TestWordMangle.tst 4 Nov 2003 20:01:16 -0000 1.7
--- TestWordMangle.tst 10 Nov 2003 19:55:35 -0000 1.8
***************
*** 24,31 ****
use Classifier::WordMangle;
unlink 'stopwords';
! my $w = new Classifier::WordMangle;
# Test basic mangling functions
--- 24,62 ----
use Classifier::WordMangle;
+ use POPFile::Configuration;
+ use POPFile::MQ;
+ use POPFile::Logger;
+
+ # Load the test corpus
+ my $c = new POPFile::Configuration;
+ my $mq = new POPFile::MQ;
+ my $l = new POPFile::Logger;
+ my $w = new Classifier::WordMangle;
+
+ $c->configuration( $c );
+ $c->mq( $mq );
+ $c->logger( $l );
+
+ $c->initialize();
+
+ $l->configuration( $c );
+ $l->mq( $mq );
+ $l->logger( $l );
+
+ $l->initialize();
+
+ $mq->configuration( $c );
+ $mq->mq( $mq );
+ $mq->logger( $l );
+
+ $w->configuration( $c );
+ $w->mq( $mq );
+ $w->logger( $l );
+
+ $w->initialize();
unlink 'stopwords';
! $w->start();
# Test basic mangling functions
***************
*** 79,84 ****
# Make sure that stopping and starting reloads the stopwords
test_assert_equal( $w->add_stopword( 'anotherbigword', 'English' ), 1 );
! my $w2 = new Classifier::WordMangle;
! my @stopwords = $w2->stopwords();
test_assert_equal( $#stopwords, 0 );
test_assert_equal( $stopwords[0], 'anotherbigword' );
--- 110,118 ----
# Make sure that stopping and starting reloads the stopwords
test_assert_equal( $w->add_stopword( 'anotherbigword', 'English' ), 1 );
!
! $w->stop();
!
! $w->start();
! my @stopwords = $w->stopwords();
test_assert_equal( $#stopwords, 0 );
test_assert_equal( $stopwords[0], 'anotherbigword' );
Index: TestPOP3.tst
===================================================================
RCS file: /cvsroot/popfile/engine/tests/TestPOP3.tst,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** TestPOP3.tst 13 Oct 2003 20:23:41 -0000 1.16
--- TestPOP3.tst 10 Nov 2003 19:55:36 -0000 1.17
***************
*** 28,31 ****
--- 28,32 ----
use Proxy::POP3;
use Classifier::Bayes;
+ use Classifier::WordMangle;
use IO::Handle;
use IO::Socket;
***************
*** 241,244 ****
--- 242,246 ----
my $l = new POPFile::Logger;
my $b = new Classifier::Bayes;
+ my $w = new Classifier::WordMangle;
sub forker
***************
*** 281,284 ****
--- 283,292 ----
$l->initialize();
+ $w->configuration( $c );
+ $w->mq( $mq );
+ $w->logger( $l );
+
+ $w->start();
+
$mq->configuration( $c );
$mq->mq( $mq );
***************
*** 293,296 ****
--- 301,305 ----
$b->module_config_( 'html', 'language', 'English' );
$b->config_( 'hostname', '127.0.0.1' );
+ $b->{parser__}->mangle( $w );
$b->start();
Index: TestMailParse.tst
===================================================================
RCS file: /cvsroot/popfile/engine/tests/TestMailParse.tst,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** TestMailParse.tst 20 Oct 2003 22:00:37 -0000 1.23
--- TestMailParse.tst 10 Nov 2003 19:55:36 -0000 1.24
***************
*** 32,35 ****
--- 32,36 ----
use Classifier::MailParse;
use Classifier::Bayes;
+ use Classifier::WordMangle;
use POPFile::Configuration;
use POPFile::MQ;
***************
*** 41,44 ****
--- 42,46 ----
my $l = new POPFile::Logger;
my $b = new Classifier::Bayes;
+ my $w = new Classifier::WordMangle;
$c->configuration( $c );
***************
*** 52,55 ****
--- 54,63 ----
$l->initialize();
+ $w->configuration( $c );
+ $w->mq( $mq );
+ $w->logger( $l );
+
+ $w->start();
+
$mq->configuration( $c );
$mq->mq( $mq );
***************
*** 60,63 ****
--- 68,72 ----
$b->logger( $l );
+ $b->{parser__}->mangle( $w );
$b->initialize();
test_assert( $b->start() );
***************
*** 65,68 ****
--- 74,78 ----
my $cl = new Classifier::MailParse;
+ $cl->mangle( $w );
# map_color()
test_assert_equal( $cl->map_color( 'red' ), 'ff0000' );
Index: TestBayes.tst
===================================================================
RCS file: /cvsroot/popfile/engine/tests/TestBayes.tst,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** TestBayes.tst 30 Oct 2003 14:57:12 -0000 1.34
--- TestBayes.tst 10 Nov 2003 19:55:36 -0000 1.35
***************
*** 37,40 ****
--- 37,41 ----
use POPFile::MQ;
use POPFile::Logger;
+ use Classifier::WordMangle;
# Load the test corpus
***************
*** 43,46 ****
--- 44,48 ----
my $l = new POPFile::Logger;
my $b = new Classifier::Bayes;
+ my $w = new Classifier::WordMangle;
$c->configuration( $c );
***************
*** 54,57 ****
--- 56,65 ----
$l->initialize();
+ $w->configuration( $c );
+ $w->mq( $mq );
+ $w->logger( $l );
+
+ $w->start();
+
$mq->configuration( $c );
$mq->mq( $mq );
***************
*** 63,67 ****
$b->module_config_( 'html', 'language', 'English' );
!
$b->initialize();
--- 71,75 ----
$b->module_config_( 'html', 'language', 'English' );
! $b->{parser__}->mangle( $w );
$b->initialize();
Index: TestHTTP.tst
===================================================================
RCS file: /cvsroot/popfile/engine/tests/TestHTTP.tst,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** TestHTTP.tst 13 Oct 2003 20:23:41 -0000 1.5
--- TestHTTP.tst 10 Nov 2003 19:55:36 -0000 1.6
***************
*** 185,189 ****
open FILE, ">send.tmp";
! print FILE "somechars\n";
close FILE;
--- 185,189 ----
open FILE, ">send.tmp";
! print FILE "somechars$eol";
close FILE;
|