/[notice-sender]/trunk/t/1_nos.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/t/1_nos.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 56 - (hide annotations)
Tue Jun 21 09:14:54 2005 UTC (18 years, 10 months ago) by dpavlin
File MIME type: application/x-troff
File size: 2669 byte(s)
added from address to SOAP method NewList, added ext_id to add_member_to_list

1 dpavlin 20 #!/usr/bin/perl -w
2    
3     use strict;
4     use blib;
5    
6 dpavlin 56 use Test::More tests => 50;
7 dpavlin 31
8 dpavlin 24 BEGIN { use_ok('Nos') };
9 dpavlin 20
10 dpavlin 24 ok(my $nos = new Nos('dsn' => 'dbi:Pg:dbname=notices'), "new");
11 dpavlin 25
12 dpavlin 33 ok($nos->new_list( list => 'My list', email => 'my-list@example.com'), "new_list my-list");
13 dpavlin 36 ok($nos->new_list( list => 'another', email => 'another@example.com'), "new_list another");
14     ok($nos->new_list( list => 'test', email => 'test@example.com'), "new_list test");
15 dpavlin 31
16 dpavlin 36 ok($nos->_get_list('My list'), "_get_list");
17     ok($nos->_get_list('another'), "_get_list");
18     ok($nos->_get_list('test'), "_get_list");
19 dpavlin 29
20 dpavlin 56 my %ext_id;
21    
22 dpavlin 36 my $i = 0;
23 dpavlin 32 foreach my $email (qw(foo@example.com bar@example.com baz@example.com)) {
24 dpavlin 45 my $full_name = uc($1)." Doe" if ($email =~ m/^([^@]+)@/);
25 dpavlin 56 ok($nos->add_member_to_list( list => 'My list', email => $email, name => $full_name, ext_id => $i ), "add_member_to_list $email, ext_id = $i");
26 dpavlin 36 ok($nos->add_member_to_list( list => 'another', email => $email ), "add_member_to_list $email") if ($i % 2 == 0);
27 dpavlin 56 ok($nos->add_member_to_list( list => 'test', email => $email, ext_id => $i ), "add_member_to_list $email, ext_id = $i") if ($i % 3 == 0);
28     $ext_id{$email} = $i;
29 dpavlin 45 $i++;
30 dpavlin 32 }
31    
32 dpavlin 36 ok($nos->add_message_to_list( list => 'My list', message => "Subject: test\n\nJust a test\n\n" ), "add_message_to_list");
33 dpavlin 32
34     foreach my $i ( 1 .. 10 ) {
35 dpavlin 45 ok($nos->add_message_to_list( list => 'another', message => "Subject: test $i" ), "add_message_to_list another $i");
36     ok($nos->add_message_to_list( list => 'test', message => "Subject: test e-mail $i\n\nIsn't life great?\n" ), "add_message_to_list test $i") if ($i % 3 == 0);
37 dpavlin 32 }
38 dpavlin 45
39     cmp_ok(scalar $nos->list_members( list => 'My list' ), '==', 3, 'members of My list');
40     cmp_ok(scalar $nos->list_members( list => 'another' ), '==', 2, 'members of another');
41     cmp_ok(scalar $nos->list_members( list => 'test' ), '==', 1, 'members of test');
42    
43 dpavlin 56 foreach my $list (('My list', 'another', 'test')) {
44     diag "checking list $list";
45     foreach my $m ( $nos->list_members( list => $list ) ) {
46     ok(my $email = $m->{'email'}, "have email");
47     cmp_ok($m->{'ext_id'}, 'eq', $ext_id{$email}, "ext_id($email)=$ext_id{$email}");
48     }
49     }
50    
51    
52 dpavlin 45 ok($nos->delete_member( email => 'foo@example.com' ), "delete");
53    
54     cmp_ok(scalar $nos->list_members( list => 'My list' ), '==', 2, 'members of My list');
55     cmp_ok(scalar $nos->list_members( list => 'another' ), '==', 1, 'members of another');
56     cmp_ok(scalar $nos->list_members( list => 'test' ), '==', 0, 'members of test');
57    
58     ok($nos->delete_member( name => 'BAZ Doe' ), "delete");
59    
60     cmp_ok(scalar $nos->list_members( list => 'My list' ), '==', 1, 'members of My list');
61     cmp_ok(scalar $nos->list_members( list => 'another' ), '==', 0, 'members of another');

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26