Annotation of HOPE/Net-OpenAMD/t/network_tests.t, Revision 1.8
1.1 andrew 1: #!perl
2: package NetworkTests;
1.2 andrew 3:
1.8 ! andrew 4: # $AFresh1: network_tests.t,v 1.7 2010/06/30 18:04:20 andrew Exp $
1.1 andrew 5:
6: use strict;
7: use warnings;
8:
9: use Test::More;
10: use Net::OpenAMD;
1.8 ! andrew 11: use Data::Dumper;
1.1 andrew 12:
1.2 andrew 13: if ( !caller() ) {
14: if ( $ENV{'NETWORK_TESTS'} ) {
1.8 ! andrew 15: plan tests => 13;
1.1 andrew 16: }
17: else {
1.6 andrew 18: plan skip_all =>
19: 'Network test. Set $ENV{NETWORK_TESTS} to a true value to run.';
1.1 andrew 20: }
21:
1.2 andrew 22: my %tests = (
23: location => [
24: { args => undef,
1.4 andrew 25: expect => [
1.8 ! andrew 26: { 'y' => '43.4861220266',
1.6 andrew 27: 'user' => 'user6',
1.8 ! andrew 28: 'x' => '18.2468971683'
1.6 andrew 29: },
30: { 'y' => '36.5212503999',
31: 'user' => 'user7',
32: 'x' => '27.138154414'
33: },
34: { 'y' => '45.4561205517',
35: 'user' => 'user4',
36: 'x' => '43.2247016461'
37: },
38: { 'y' => '33.3876312219',
39: 'user' => 'user5',
40: 'x' => '1.88999914202'
41: },
42: { 'y' => '6.24512871596',
43: 'user' => 'user2',
44: 'x' => '19.3851425782'
45: },
46: { 'y' => '11.5686903901',
47: 'user' => 'user3',
48: 'x' => '37.0118334017'
49: },
50: { 'y' => '39.6231665024',
51: 'user' => 'user0',
52: 'x' => '4.80925926012'
53: },
54: { 'y' => '30.0999230116',
55: 'user' => 'user1',
56: 'x' => '1.48091119245'
57: },
58: { 'y' => '44.0085836003',
59: 'user' => 'user8',
60: 'x' => '15.5482823414'
61: },
62: { 'y' => '35.8354729961',
63: 'user' => 'user9',
64: 'x' => '1.3539559599'
65: },
66: { 'y' => '23.0220504783',
67: 'user' => 'user10',
68: 'x' => '16.5797941904'
69: },
70: { 'y' => '18.1245161319',
71: 'user' => 'user11',
72: 'x' => '39.2951848533'
73: },
74: { 'y' => '11.3998081612',
75: 'user' => 'user12',
76: 'x' => '3.99920632586'
77: },
78: { 'y' => '13.1865736157',
79: 'user' => 'user13',
80: 'x' => '20.5159017473'
81: },
82: { 'y' => '17.742550877',
83: 'user' => 'user14',
84: 'x' => '4.55691655225'
85: },
86: { 'y' => '18.7671525659',
87: 'user' => 'user15',
88: 'x' => '0.262498111169'
89: },
90: { 'y' => '44.2762837418',
91: 'user' => 'user16',
92: 'x' => '35.5124464395'
93: },
94: { 'y' => '36.5340075619',
95: 'user' => 'user17',
96: 'x' => '9.14220464394'
97: },
98: { 'y' => '29.2264569149',
99: 'user' => 'user18',
100: 'x' => '3.47406301583'
101: },
102: { 'y' => '1.68159309609',
103: 'user' => 'user19',
104: 'x' => '1.41024785197'
1.4 andrew 105: }
106: ],
1.2 andrew 107: },
1.8 ! andrew 108: { args => [ user => 'user0' ],
! 109: expect => [],
! 110: },
1.2 andrew 111: ],
112: speakers => [
113: { args => undef,
1.4 andrew 114: expect => [
1.8 ! andrew 115: [ '9000',
! 116: { 'name' => 'The Cheshire Catalyst',
! 117: 'bio' => 'Jacob\'s bio'
! 118: }
! 119: ],
1.6 andrew 120: [ 'user0',
121: { 'name' => 'Jacob',
122: 'bio' => 'Jacob\'s bio'
123: }
124: ],
125: [ 'user1',
126: { 'name' => 'Emma',
127: 'bio' => 'Emma\'s bio'
128: }
129: ],
130: [ 'user10',
131: { 'name' => 'Alexander',
132: 'bio' => 'Alexander\'s bio'
133: }
134: ],
135: [ 'user11',
136: { 'name' => 'Olivia',
137: 'bio' => 'Olivia\'s bio'
138: }
139: ],
140: [ 'user12',
141: { 'name' => 'Anthony',
142: 'bio' => 'Anthony\'s bio'
143: }
144: ],
145: [ 'user13',
146: { 'name' => 'Sophia',
147: 'bio' => 'Sophia\'s bio'
148: }
149: ],
150: [ 'user14',
151: { 'name' => 'William',
152: 'bio' => 'William\'s bio'
153: }
154: ],
155: [ 'user15',
156: { 'name' => 'Abigail',
157: 'bio' => 'Abigail\'s bio'
158: }
159: ],
160: [ 'user16',
161: { 'name' => 'Christopher',
162: 'bio' => 'Christopher\'s bio'
163: }
164: ],
165: [ 'user17',
166: { 'name' => 'Elizabeth',
167: 'bio' => 'Elizabeth\'s bio'
168: }
169: ],
170: [ 'user18',
171: { 'name' => 'Matthew',
172: 'bio' => 'Matthew\'s bio'
173: }
174: ],
175: [ 'user19',
176: { 'name' => 'Chloe',
177: 'bio' => 'Chloe\'s bio'
178: }
179: ],
180: [ 'user2',
181: { 'name' => 'Michael',
182: 'bio' => 'Michael\'s bio'
183: }
184: ],
185: [ 'user3',
186: { 'name' => 'Isabella',
187: 'bio' => 'Isabella\'s bio'
188: }
189: ],
190: [ 'user4',
191: { 'name' => 'Ethan',
192: 'bio' => 'Ethan\'s bio'
193: }
194: ],
195: [ 'user5',
196: { 'name' => 'Emily',
197: 'bio' => 'Emily\'s bio'
198: }
199: ],
200: [ 'user6',
201: { 'name' => 'Joshua',
202: 'bio' => 'Joshua\'s bio'
203: }
204: ],
205: [ 'user7',
206: { 'name' => 'Madison',
207: 'bio' => 'Madison\'s bio'
208: }
209: ],
210: [ 'user8',
211: { 'name' => 'Daniel',
212: 'bio' => 'Daniel\'s bio'
213: }
214: ],
215: [ 'user9',
216: { 'name' => 'Ava',
217: 'bio' => 'Ava\'s bio'
218: },
219: ],
1.4 andrew 220: ],
1.2 andrew 221: },
222: ],
223: talks => [
224: { args => undef,
1.4 andrew 225: expect => [
1.6 andrew 226: [ 'Hacking Democracy: An In Depth Analysis of the ES&S Voting Systems',
227: { 'speakers' =>
228: '["Matt Blaze", "Sandy Clark", "Eric Cronin", "Gaurav Shah", "Micah Sherr", "Adam Aviv", "Pavol Cerny"]',
229: 'interests' => '["crypto", "telephones"]',
230: 'time' => '2008/07/14 13:00:00',
231: 'track' => 'Hooper',
232: 'abstract' => '
233: This talk will outline the U. Penn team\'s findings, which included
234: the discovery of exploitable security vulnerabilities in almost every
235: hardware and software component of the ES&S touch-screen and optical
236: scan systems.
237: ',
238: 'title' =>
239: 'Hacking Democracy: An In Depth Analysis of the ES&S Voting Systems',
240: },
241: ],
1.4 andrew 242: ],
1.2 andrew 243: },
244: ],
245: interests => [
246: { args => undef,
1.4 andrew 247: expect => [
1.6 andrew 248: 'new tech',
249: 'activism',
250: 'radio',
251: 'lockpicking',
252: 'crypto',
253: 'privacy',
254: 'ethics',
255: 'telephones',
256: 'social engineering',
257: 'hacker spaces',
258: 'hardware hacking',
259: 'nostalgia',
260: 'communities',
261: 'science',
262: 'government',
263: 'network security',
264: 'malicious software',
265: 'pen testing',
266: 'web',
267: 'niche hacks',
1.4 andrew 268: 'media',
269: ],
1.2 andrew 270: },
271: ],
272: users => [
273: { args => undef,
1.6 andrew 274: expect => [],
1.2 andrew 275: },
276: ],
277: stats => [
278: { args => undef,
1.4 andrew 279: expect => qr/^Unused \s feature/xms,
1.2 andrew 280: },
281: ],
282: );
283:
1.6 andrew 284: my $amd
285: = Net::OpenAMD->new( { base_uri => 'http://api.hope.net/api/', } );
286: run_tests( $amd, \%tests );
287:
1.7 andrew 288: #done_testing();
1.6 andrew 289: }
290:
291: 1;
292:
293: sub run_tests {
294: my ( $amd, $tests ) = @_;
295:
296: foreach my $method ( keys %{$tests} ) {
297: foreach my $test ( @{ $tests->{$method} } ) {
1.2 andrew 298: no warnings 'uninitialized';
299: my $result;
300: eval { $result = $amd->$method( $test->{args} ) };
1.4 andrew 301: if ( ref $test->{expect} eq 'Regexp' ) {
302: like( $@, $test->{expect}, "AMD->$method($test->{args})" );
303: }
304: elsif ( ref $test->{expect} ) {
305: is( $@, '', "AMD->$method($test->{args})" );
1.6 andrew 306: is_deeply( $result, $test->{expect},
307: "AMD->$method($test->{args}) - "
308: . 'got expected result' );
1.4 andrew 309: }
310: else {
311: is( $@, $test->{expect}, "AMD->$method($test->{args})" );
312: }
1.2 andrew 313: }
314: }
1.1 andrew 315: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>