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