From: Manni H. <man...@us...> - 2007-11-26 11:07:44
|
Update of /cvsroot/popfile/engine/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9951/tests Modified Files: Tag: b0_22_2 TestIMAP.tst Log Message: Add yet more tests and make the module disconnect when the connection options are changed so that the changes will take immediate effect. Index: TestIMAP.tst =================================================================== RCS file: /cvsroot/popfile/engine/tests/TestIMAP.tst,v retrieving revision 1.3.4.9 retrieving revision 1.3.4.10 diff -C2 -d -r1.3.4.9 -r1.3.4.10 *** TestIMAP.tst 24 Nov 2007 16:15:22 -0000 1.3.4.9 --- TestIMAP.tst 26 Nov 2007 11:07:37 -0000 1.3.4.10 *************** *** 112,116 **** # the difference between the (manipulated) stored value and # the value from the server. ! my $client = $im->{folders__}{'spam'}{imap}; $client->uid_validity( 'spam', 50 ); $im->{last_update__} = 0; --- 112,116 ---- # the difference between the (manipulated) stored value and # the value from the server. ! my $client = $im->{folders__}{spam}{imap}; $client->uid_validity( 'spam', 50 ); $im->{last_update__} = 0; *************** *** 146,149 **** --- 146,151 ---- # If the hash is unknown, it should reclassify either test_assert( ! $im->can_reclassify__( 'hash', 'other' ) ); + # But with a good hash and a valid bucket: + test_assert( $im->can_reclassify__( $hash, 'other' ) ); # move msgs 1, 2, and 3 to folder personal *************** *** 234,237 **** --- 236,240 ---- $im->disconnect_folders__(); + # Check what happens when we time out $im->log_( 0, "---- Testing time-out behaviour for the module." ); *************** *** 431,435 **** # Now let the IMAP module populate the template $im->config_( hostname => 'some host' ); ! $im->config_( port => 'some port' ); $im->config_( password => 'some password' ); $im->config_( login => 'some login' ); --- 434,438 ---- # Now let the IMAP module populate the template $im->config_( hostname => 'some host' ); ! $im->config_( port => 1234 ); $im->config_( password => 'some password' ); $im->config_( login => 'some login' ); *************** *** 438,442 **** test_assert_equal( $tmpl->param( 'IMAP_hostname'), 'some host' ); ! test_assert_equal( $tmpl->param( 'IMAP_port' ), 'some port' ); test_assert_equal( $tmpl->param( 'IMAP_password' ), 'some password' ); test_assert_equal( $tmpl->param( 'IMAP_login' ), 'some login' ); --- 441,445 ---- test_assert_equal( $tmpl->param( 'IMAP_hostname'), 'some host' ); ! test_assert_equal( $tmpl->param( 'IMAP_port' ), 1234 ); test_assert_equal( $tmpl->param( 'IMAP_password' ), 'some password' ); test_assert_equal( $tmpl->param( 'IMAP_login' ), 'some login' ); *************** *** 615,619 **** test_assert_equal( $im->config_( 'port' ), 123 ); test_assert_equal( $im->config_( 'hostname' ), 'hostname' ); ! # TODO: test with values that will NOT validate # imap-watch-folders.thtml --- 618,644 ---- test_assert_equal( $im->config_( 'port' ), 123 ); test_assert_equal( $im->config_( 'hostname' ), 'hostname' ); ! ! $form->{imap_use_ssl} = undef; ! $im->validate_item( 'imap_0_connection_details', $tmpl, $language, $form ); ! test_assert_equal( $im->config_( 'use_ssl' ), 0 ); ! ! # After updating the connection details, the module must disconnect ! # and empty its folders hash: ! test_assert_equal( scalar keys %{$im->{folders__}}, 0 ); ! ! # Now test some values that should NOT validate: ! ! # all the parameters need to be set to something (except for use_ssl) ! foreach ( qw/ imap_hostname imap_port imap_login imap_password / ) { ! my %invalid_form = %$form; ! delete $invalid_form{$_}; ! $tmpl = HTML::Template->new( filename => '../skins/default/imap-connection-details.thtml' ); ! $im->validate_item( 'imap_0_connection_details', $tmpl, $language, \%invalid_form ); ! my $template_param = $_; ! $template_param =~ s/imap_//; ! $template_param = 'IMAP_connection_if_' . $template_param . '_error'; ! test_assert_equal( $tmpl->param( $template_param ), 1, $_ ); ! } ! # imap-watch-folders.thtml *************** *** 643,649 **** $form = {}; $form->{imap_3_bucket_folders} = 1; $tmpl = HTML::Template->new( filename => '../skins/default/imap-bucket-folders.thtml' ); $im->validate_item('imap_3_bucket_folders', $tmpl, $language, $form ); ! # imap-update-mailbox-list.thtml --- 668,679 ---- $form = {}; $form->{imap_3_bucket_folders} = 1; + $form->{imap_folder_for_other} = 'personal'; + $form->{imap_folder_for_personal} = 'other'; + $tmpl = HTML::Template->new( filename => '../skins/default/imap-bucket-folders.thtml' ); $im->validate_item('imap_3_bucket_folders', $tmpl, $language, $form ); ! test_assert_equal( $im->{folder_change_flag__}, 1 ); ! test_assert_equal( $im->folder_for_bucket__( 'other' ), 'personal' ); ! test_assert_equal( $im->folder_for_bucket__( 'personal' ), 'other' ); # imap-update-mailbox-list.thtml *************** *** 651,655 **** --- 681,707 ---- $form->{do_imap_4_update_mailbox_list} = 1; $tmpl = HTML::Template->new( filename => '../skins/default/imap-update-mailbox-list.thtml' ); + $im->config_( 'hostname', '127.0.0.1' ); + $im->config_( 'password', 'password' ); + $im->config_( 'username', 'someone' ); + $im->config_( 'port', '1143' ); + $im->config_( 'update_interval', 10 ); + $im->config_( 'use_ssl', 0 ); + $im->validate_item( 'imap_4_update_mailbox_list', $tmpl, $language, $form ); + test_assert_equal( scalar @{$im->{mailboxes__}}, 5 ); + test_assert( ! $tmpl->param( 'IMAP_update_list_failed' ) ); + + $im->config_( 'hostname', '' ); + $im->validate_item( 'imap_4_update_mailbox_list', $tmpl, $language, $form ); + test_assert( $tmpl->param( 'IMAP_update_list_failed' ) ); + + $im->config_( 'hostname', '127.0.0.1' ); + $im->config_( 'port', '12345' ); $im->validate_item( 'imap_4_update_mailbox_list', $tmpl, $language, $form ); + test_assert( $tmpl->param( 'IMAP_update_list_failed' ) ); + + $im->config_( 'port', 1143 ); + $im->config_( 'username', 'fail' ); + $im->validate_item( 'imap_4_update_mailbox_list', $tmpl, $language, $form ); + test_assert( $tmpl->param( 'IMAP_update_list_failed' ) ); *************** *** 690,694 **** $im->config_( 'expunge', 1 ); $im->config_( 'hostname', '127.0.0.1' ); - $im->config_( 'password', 'password' ); $im->config_( 'port', '1143' ); --- 742,745 ---- *************** *** 714,718 **** sub start_popfile { - rmtree( 'messages' ); rmtree( 'corpus' ); --- 765,768 ---- |