initial import
[Net-Indosoft-Voicebridge.git] / t / 01-Account_Client_Conference.t
1 #!perl
2
3 use Test::More;
4
5 open URL, "t/URL"
6   or do { plan 'skip_all' => 'Put your URL in the t/URL file to test'; exit };
7 chomp( my $URL = scalar(<URL>) );
8
9 plan tests => 6 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2;
10
11 use Net::Indosoft::Voicebridge;
12
13 my $vb = new Net::Indosoft::Voicebridge( 'url' => $URL );
14
15 my $return;
16
17 # addAccount (6)
18
19 $return = $vb->addAccount(
20   'account_name'     => 'aname', #i think this is more like a username
21   'account_password' => 'test54',
22
23   'account_desc'     => 'A test account',
24
25   'account_addr'     => '1234 Test Lane',
26   'account_city'     => 'Testville',
27   'account_state'    => 'CA',
28   'account_zip'      => '54321',
29   'account_country'  => 'US',
30
31   'account_phone'    => '415-555-1212',
32 #  'account_fax'      => '415-555-1212',
33   'account_email'    => 'ivan-voicebridge-test@freeside.biz',
34 );
35
36 ok( ! $return->{error}, 'addAccount successful' ) or warn $return->{error};
37
38 like($return->{account_id}, qr/^(\d+)$/, 'addAccount returned account_id');
39
40 my $account_id = $return->{account_id};
41
42 $return = $vb->addAccount(
43 );
44
45 ok( $return->{error}, 'addAccount empty error test', );
46
47 like($return->{error}, qr/Please, fill in/, 'addAccount empty error test got expected error');
48
49 $return = $vb->addAccount(
50   #'account_name'     => 'A. Name',
51   'account_desc'     => 'A test account',
52   'account_addr'     => '1234 Test Lane',
53   'account_city'     => 'Testville',
54   'account_state'    => 'CA',
55   'account_zip'      => '54321',
56   #'account_phone'    => '415-555-1212',
57   'account_fax'      => '415-555-1212',
58   #'account_email'    => 'ivan-voicebridge-test@freeside.biz',
59   #'account_password' => 'testing',
60 );
61
62 ok( $return->{error}, 'addAccount bad data error test', );
63
64 like($return->{error}, qr/Please, fill in/, 'addAccount bad data error test got expected error');
65
66 # modifyAccount (2)
67
68 $return = $vb->modifyAccount(
69   'account_id'       => $account_id,
70   'account_name'     => 'anewname', #i think this is more like a username
71   'account_password' => 'test32',
72
73   'account_desc'     => 'A modified test account',
74
75   'account_addr'     => '5432 Test Lane',
76   'account_city'     => 'Test City',
77   'account_state'    => 'NY',
78   'account_zip'      => '12345',
79   'account_country'  => 'US',
80
81   'account_phone'    => '212-555-1212',
82   'account_fax'      => '212-555-1212',
83   'account_email'    => 'ivan-voicebridge-test2@freeside.biz',
84 );
85
86 ok( ! $return->{error}, 'modifyAccount successful' ) or warn $return->{error};
87
88 is($return->{account_id}, $account_id, 'modifyAccount returned account_id');
89
90 # addClient (2)
91
92 $return = $vb->addClient(
93   'account_id'              => $account_id,
94
95   'client_contact_name'     => 'Tofu Beast',
96   'client_contact_password' => 'word54',
97
98   'client_contact_addr'     => '5432 Test Lane Suite 11',
99   'client_contact_city'     => 'Test City',
100   'client_contact_state'    => 'NY',
101   'client_contact_country'  => 'US',
102   'client_contact_zip'      => '12345',
103
104   'client_contact_phone'    => '212-555-1234',
105   'client_contact_fax'      => '212-555-1234',
106   'client_contact_email'    => 'ivan-voicebridge-test3@freeside.biz',
107
108 );
109
110 ok( ! $return->{error}, 'addClient successful' ) or warn $return->{error};
111
112 like($return->{client_id}, qr/^(\d+)$/, 'addClient returned client_id');
113
114 my $client_id = $return->{client_id};
115
116 # modifyClient (2)
117
118 $return = $vb->modifyClient(
119   'account_id'              => $account_id,
120   'client_id'               => $client_id,
121
122   'client_contact_name'     => 'Secret Agent X',
123   'client_contact_password' => 'word32',
124
125   'client_contact_addr'     => '1234 Test Lane Suite 55',
126   'client_contact_city'     => 'Testville',
127   'client_contact_state'    => 'CA',
128   'client_contact_country'  => 'US',
129   'client_contact_zip'      => '54321',
130
131   'client_contact_phone'    => '415-555-1234',
132   'client_contact_fax'      => '415-555-1234',
133   'client_contact_email'    => 'ivan-voicebridge-test4@freeside.biz',
134   
135 );
136
137 ok( ! $return->{error}, 'modifyClient successful' ) or warn $return->{error};
138
139 is($return->{client_id}, $client_id, 'modifyClient returned client_id');
140
141 # addConference (2)
142
143 $return = $vb->addConference(
144   'client_id'          => $client_id,
145   'conference_name'    => 'Test Conference',
146   'conference_desc'    => 'Net Indosoft Voicebridge test',
147   'start_time'         => '2010-20-04 16:20:00',
148   #'moderated_flag'     => 0,
149   #'entry_ann_flag'     => 0
150   #'record_flag'        => 0
151   #'moh_flag'           => 0
152   #'talk_detect_flag'   => 0
153   #'play_user_cnt_flag' => 0
154   #'wait_for_admin'     => 0
155   #'stop_on_admin_exit' => 0
156   #'second_pin'         => 0
157   #'secondary_pin'      => 0,
158   #'allow_sub-conf'     => 0,
159   #'duration'           => 0,
160   #'conference_type' => 'reservation', #'reservationless',
161
162 );
163
164 ok( ! $return->{error}, 'addConference successful' ) or warn $return->{error};
165
166 like($return->{conference_id}, qr/^(\d+)$/, 'addConference returned conference_id');
167
168 my $conference_id = $return->{conference_id};
169
170 # modifyConference (2)
171
172 $return = $vb->modifyConference(
173   'conference_id'      => $conference_id,
174   'conference_name'    => 'Modified Test Conference',
175   'conference_desc'    => 'Net Indosoft Voicebridge modify test',
176   'start_time'         => '2010-20-04 16:20:00',
177   'moderated_flag'     => 1,
178   #'entry_ann_flag'     => 0
179   #'record_flag'        => 0
180   #'moh_flag'           => 0
181   #'talk_detect_flag'   => 0
182   #'play_user_cnt_flag' => 0
183   'wait_for_admin'     => 1
184   #'stop_on_admin_exit' => 0
185   #'second_pin'         => 0
186   #'secondary_pin'      => 0,
187   #'allow_sub-conf'     => 0,
188   #'duration'           => 0,
189   #'conference_type' => 'reservation', #'reservationless',
190
191 );
192
193 ok( ! $return->{error}, 'modifyConference successful' ) or warn $return->{error};
194
195 is($return->{conference_id}, $conference_id, 'modifyConference returned conference_id')
196   or warn $return->{'return'};
197
198 # deleteConference (2)
199
200 $return = $vb->deleteConference(
201   'conference_id' => $conference_id,
202 );
203
204 ok( ! $return->{error}, 'deleteConference successful' )
205   or warn $return->{error}. "\n". $return->{return}. "\n";
206
207 TODO: {
208
209   local $TODO = 'deleteConference always returns "Deleted successfully", even when nothing was';
210
211   $return = $vb->deleteConference(
212     'conference_id' => '999999999',
213   );
214
215   ok( $return->{error}, 'deleteConference bad data error test' )
216     ;#or warn $return->{return};
217
218 }
219
220 # deleteClient (2)
221
222 $return = $vb->deleteClient(
223   'client_id' => $client_id,
224 );
225
226 ok( ! $return->{error}, 'deleteClient successful' )
227   or warn $return->{error}. "\n". $return->{return}. "\n";
228
229 TODO: {
230
231   local $TODO = 'deleteClient always returns "Deleted successfully", even when nothing was';
232
233   $return = $vb->deleteClient(
234     'client_id' => '999999999',
235   );
236
237   ok( $return->{error}, 'deleteClient bad data error test' )
238     ;#or warn $return->{return};
239
240 }
241
242 # deleteAccount (2)
243
244 $return = $vb->deleteAccount(
245   'account_id' => $account_id,
246 );
247
248 ok( ! $return->{error}, 'deleteAccount successful' )
249   or warn $return->{error}. "\n". $return->{return}. "\n";
250
251 TODO: {
252
253   local $TODO = 'deleteAccount always returns "Deleted successfully", even when nothing was';
254
255   $return = $vb->deleteAccount(
256     'account_id' => '999999999',
257   );
258
259   ok( $return->{error}, 'deleteAccount bad data error test' )
260     ;#or warn $return->{return};
261
262 }