63
ok($sa->{bayes_scanner});
65
ok($sa->{bayes_scanner}->{store}->tie_db_writable());
64
return $sa->call_plugins("learner_get_implementation");
67
ok($sa->{bayes_scanner} && getimpl);
69
ok(getimpl->{store}->tie_db_writable());
67
71
# This bit breaks abstraction a bit, the userid is an implementation detail,
68
72
# but is necessary to perform some of the tests. Perhaps in the future we
69
73
# can add some sort of official API for this sort of thing.
70
my $testuserid = $sa->{bayes_scanner}->{store}->{_userid};
74
my $testuserid = getimpl->{store}->{_userid};
71
75
ok(defined($testuserid));
73
ok($sa->{bayes_scanner}->{store}->clear_database());
77
ok(getimpl->{store}->clear_database());
75
79
ok(database_clear_p($testuser, $testuserid));
141
my $body = $sa->{bayes_scanner}->get_body_from_msg($mail);
145
my $body = getimpl->get_body_from_msg($mail);
145
my $toks = $sa->{bayes_scanner}->tokenize($mail, $body);
149
my $toks = getimpl->tokenize($mail, $body);
147
151
ok(scalar(keys %{$toks}) > 0);
149
my($msgid,$msgid_hdr) = $sa->{bayes_scanner}->get_msgid($mail);
153
my($msgid,$msgid_hdr) = getimpl->get_msgid($mail);
151
155
# $msgid is the generated hash messageid
152
156
# $msgid_hdr is the Message-Id header
153
157
ok($msgid eq 'ce33e4a8bc5798c65428d6018380bae346c7c126@sa_generated');
154
158
ok($msgid_hdr eq '9PS291LhupY');
156
ok($sa->{bayes_scanner}->{store}->tie_db_writable());
158
ok(!$sa->{bayes_scanner}->{store}->seen_get($msgid));
160
$sa->{bayes_scanner}->{store}->untie_db();
160
ok(getimpl->{store}->tie_db_writable());
162
ok(!getimpl->{store}->seen_get($msgid));
164
getimpl->{store}->untie_db();
162
166
ok($sa->{bayes_scanner}->learn(1, $mail));
164
168
ok(!$sa->{bayes_scanner}->learn(1, $mail));
166
ok($sa->{bayes_scanner}->{store}->tie_db_writable());
168
ok($sa->{bayes_scanner}->{store}->seen_get($msgid) eq 's');
170
$sa->{bayes_scanner}->{store}->untie_db();
172
ok($sa->{bayes_scanner}->{store}->tie_db_writable());
170
ok(getimpl->{store}->tie_db_writable());
172
ok(getimpl->{store}->seen_get($msgid) eq 's');
174
getimpl->{store}->untie_db();
176
ok(getimpl->{store}->tie_db_writable());
174
178
my $tokerror = 0;
175
179
foreach my $tok (keys %{$toks}) {
176
my ($spam, $ham, $atime) = $sa->{bayes_scanner}->{store}->tok_get($tok);
180
my ($spam, $ham, $atime) = getimpl->{store}->tok_get($tok);
177
181
if ($spam == 0 || $ham > 0) {
183
my $tokens = $sa->{bayes_scanner}->{store}->tok_get_all(keys %{$toks});
187
my $tokens = getimpl->{store}->tok_get_all(keys %{$toks});
197
$sa->{bayes_scanner}->{store}->untie_db();
201
getimpl->{store}->untie_db();
199
203
ok($sa->{bayes_scanner}->learn(0, $mail));
201
ok($sa->{bayes_scanner}->{store}->tie_db_writable());
203
ok($sa->{bayes_scanner}->{store}->seen_get($msgid) eq 'h');
205
$sa->{bayes_scanner}->{store}->untie_db();
207
ok($sa->{bayes_scanner}->{store}->tie_db_writable());
205
ok(getimpl->{store}->tie_db_writable());
207
ok(getimpl->{store}->seen_get($msgid) eq 'h');
209
getimpl->{store}->untie_db();
211
ok(getimpl->{store}->tie_db_writable());
210
214
foreach my $tok (keys %{$toks}) {
211
my ($spam, $ham, $atime) = $sa->{bayes_scanner}->{store}->tok_get($tok);
215
my ($spam, $ham, $atime) = getimpl->{store}->tok_get($tok);
212
216
if ($spam > 0 || $ham == 0) {
218
$sa->{bayes_scanner}->{store}->untie_db();
222
getimpl->{store}->untie_db();
220
224
ok($sa->{bayes_scanner}->forget($mail));
222
ok($sa->{bayes_scanner}->{store}->tie_db_writable());
224
ok(!$sa->{bayes_scanner}->{store}->seen_get($msgid));
226
$sa->{bayes_scanner}->{store}->untie_db();
226
ok(getimpl->{store}->tie_db_writable());
228
ok(!getimpl->{store}->seen_get($msgid));
230
getimpl->{store}->untie_db();
228
232
# This bit breaks abstraction a bit, the userid is an implementation detail,
229
233
# but is necessary to perform some of the tests. Perhaps in the future we
230
234
# can add some sort of official API for this sort of thing.
231
$testuserid = $sa->{bayes_scanner}->{store}->{_userid};
235
$testuserid = getimpl->{store}->{_userid};
232
236
ok(defined($testuserid));
234
ok($sa->{bayes_scanner}->{store}->clear_database());
238
ok(getimpl->{store}->clear_database());
236
240
ok(database_clear_p($testuser, $testuserid));
294
298
$mail = $sa->parse( \@msg );
296
$body = $sa->{bayes_scanner}->get_body_from_msg($mail);
300
$body = getimpl->get_body_from_msg($mail);
298
302
my $msgstatus = Mail::SpamAssassin::PerMsgStatus->new($sa, $mail);
302
my $score = $sa->{bayes_scanner}->scan($msgstatus, $mail, $body);
306
my $score = getimpl->scan($msgstatus, $mail, $body);
304
308
# Pretty much we can't count on the data returned with such little training
305
309
# so just make sure that the score wasn't equal to .5 which is the default
325
329
$mail = $sa->parse( \@msg );
327
$body = $sa->{bayes_scanner}->get_body_from_msg($mail);
331
$body = getimpl->get_body_from_msg($mail);
329
333
$msgstatus = Mail::SpamAssassin::PerMsgStatus->new($sa, $mail);
331
$score = $sa->{bayes_scanner}->scan($msgstatus, $mail, $body);
335
$score = getimpl->scan($msgstatus, $mail, $body);
333
337
# Pretty much we can't count on the data returned with such little training
334
338
# so just make sure that the score wasn't equal to .5 which is the default
340
344
# This bit breaks abstraction a bit, the userid is an implementation detail,
341
345
# but is necessary to perform some of the tests. Perhaps in the future we
342
346
# can add some sort of official API for this sort of thing.
343
$testuserid = $sa->{bayes_scanner}->{store}->{_userid};
347
$testuserid = getimpl->{store}->{_userid};
344
348
ok(defined($testuserid));
346
ok($sa->{bayes_scanner}->{store}->clear_database());
350
ok(getimpl->{store}->clear_database());
348
352
ok(database_clear_p($testuser, $testuserid));