]>
git.defcon.no Git - hermes/blob - api/t/numbers.t
4 use Test
::More
'no_plan';
8 # Configuration variables defined in tests_common
9 # Make sure those are updated/set correctly..
13 # Further variables defined in tests_common:
18 my ($data, $temp, $test_number_start, $test_number_end);
20 $test_number_end .= int(rand(255))
21 while ( length( $test_number_end ) < 8 );
23 $test_number_end = substr( $test_number_end, 0, 8 );
24 $test_number_start = $test_number_end - 1;
26 $test_number_start = '+47' . $test_number_start;
27 $test_number_end = '+47' . $test_number_end;
29 isa_ok
( $g_ua, 'LWP::UserAgent', '$g_ua');
30 isa_ok
( $g_ua->cookie_jar, 'HTTP::Cookies', '$g_ua->cookies');
34 $data = exec_apinode
("numbers/list", undef);
35 is
( $data->{'response'}, 'ok', 'numbers/list result');
36 ok
($data->{'list'}, 'numbers/list array');
39 $data = exec_apinode
("numbers/add_range", {
40 'start' => $test_number_end,
41 'end' => $test_number_start,
44 is
( $data->{'response'}, 'failed', 'numbers/add_range invalid result');
47 $data = exec_apinode
("numbers/add_range", {
48 'start' => $test_number_start,
49 'end' => $test_number_end,
51 is
( $data->{'response'}, 'ok', 'numbers/add_range result');
54 $data = exec_apinode
("numbers/inpool", { 'number' => $test_number_start, });
55 is
( $data->{'response'}, 'ok', 'numbers/inpool result');
58 $data = exec_apinode
("numbers/remove", { 'number' => $test_number_start, });
59 is
( $data->{'response'}, 'ok', 'numbers/remove 1 result');
62 $data = exec_apinode
("numbers/remove", { 'number' => $test_number_end, });
63 is
( $data->{'response'}, 'ok', 'numbers/remove 2 result');
66 $data = exec_apinode
("numbers/add", { 'number' => $test_number_start, });
67 is
( $data->{'response'}, 'ok', 'numbers/add result');
70 $data = exec_apinode
("numbers/remove", { 'number' => $test_number_start, });
71 is
( $data->{'response'}, 'ok', 'numbers/remove 3 result');
74 $data = exec_apinode
("numbers/inpool", { 'number' => $test_number_start, });
75 is
( $data->{'response'}, 'failed', 'numbers/remove inpool removed');
78 $data = exec_apinode
("numbers/remove", { 'number' => $test_number_start, });
79 is
( $data->{'response'}, 'failed', 'numbers/remove invalid remove result');