Annotation of HOPE/Net-OpenAMD/t/network_tests.t, Revision 1.6
1.1 andrew 1: #!perl
2: package NetworkTests;
1.2 andrew 3:
1.6 ! andrew 4: # $AFresh1: network_tests.t,v 1.5 2010/06/28 20:40:38 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'} ) {
14:
15: # plan tests => ??;
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.6 ! andrew 26: { 'y' => '7.33745396305',
! 27: 'user' => 'user6',
! 28: 'x' => '41.0283030135'
! 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: },
108: ],
109: speakers => [
110: { args => undef,
1.4 andrew 111: expect => [
1.6 ! andrew 112: [ 'user0',
! 113: { 'name' => 'Jacob',
! 114: 'bio' => 'Jacob\'s bio'
! 115: }
! 116: ],
! 117: [ 'user1',
! 118: { 'name' => 'Emma',
! 119: 'bio' => 'Emma\'s bio'
! 120: }
! 121: ],
! 122: [ 'user10',
! 123: { 'name' => 'Alexander',
! 124: 'bio' => 'Alexander\'s bio'
! 125: }
! 126: ],
! 127: [ 'user11',
! 128: { 'name' => 'Olivia',
! 129: 'bio' => 'Olivia\'s bio'
! 130: }
! 131: ],
! 132: [ 'user12',
! 133: { 'name' => 'Anthony',
! 134: 'bio' => 'Anthony\'s bio'
! 135: }
! 136: ],
! 137: [ 'user13',
! 138: { 'name' => 'Sophia',
! 139: 'bio' => 'Sophia\'s bio'
! 140: }
! 141: ],
! 142: [ 'user14',
! 143: { 'name' => 'William',
! 144: 'bio' => 'William\'s bio'
! 145: }
! 146: ],
! 147: [ 'user15',
! 148: { 'name' => 'Abigail',
! 149: 'bio' => 'Abigail\'s bio'
! 150: }
! 151: ],
! 152: [ 'user16',
! 153: { 'name' => 'Christopher',
! 154: 'bio' => 'Christopher\'s bio'
! 155: }
! 156: ],
! 157: [ 'user17',
! 158: { 'name' => 'Elizabeth',
! 159: 'bio' => 'Elizabeth\'s bio'
! 160: }
! 161: ],
! 162: [ 'user18',
! 163: { 'name' => 'Matthew',
! 164: 'bio' => 'Matthew\'s bio'
! 165: }
! 166: ],
! 167: [ 'user19',
! 168: { 'name' => 'Chloe',
! 169: 'bio' => 'Chloe\'s bio'
! 170: }
! 171: ],
! 172: [ 'user2',
! 173: { 'name' => 'Michael',
! 174: 'bio' => 'Michael\'s bio'
! 175: }
! 176: ],
! 177: [ 'user3',
! 178: { 'name' => 'Isabella',
! 179: 'bio' => 'Isabella\'s bio'
! 180: }
! 181: ],
! 182: [ 'user4',
! 183: { 'name' => 'Ethan',
! 184: 'bio' => 'Ethan\'s bio'
! 185: }
! 186: ],
! 187: [ 'user5',
! 188: { 'name' => 'Emily',
! 189: 'bio' => 'Emily\'s bio'
! 190: }
! 191: ],
! 192: [ 'user6',
! 193: { 'name' => 'Joshua',
! 194: 'bio' => 'Joshua\'s bio'
! 195: }
! 196: ],
! 197: [ 'user7',
! 198: { 'name' => 'Madison',
! 199: 'bio' => 'Madison\'s bio'
! 200: }
! 201: ],
! 202: [ 'user8',
! 203: { 'name' => 'Daniel',
! 204: 'bio' => 'Daniel\'s bio'
! 205: }
! 206: ],
! 207: [ 'user9',
! 208: { 'name' => 'Ava',
! 209: 'bio' => 'Ava\'s bio'
! 210: },
! 211: ],
1.4 andrew 212: ],
1.2 andrew 213: },
214: ],
215: talks => [
216: { args => undef,
1.4 andrew 217: expect => [
1.6 ! andrew 218: [ 'Hacking Democracy: An In Depth Analysis of the ES&S Voting Systems',
! 219: { 'speakers' =>
! 220: '["Matt Blaze", "Sandy Clark", "Eric Cronin", "Gaurav Shah", "Micah Sherr", "Adam Aviv", "Pavol Cerny"]',
! 221: 'interests' => '["crypto", "telephones"]',
! 222: 'time' => '2008/07/14 13:00:00',
! 223: 'track' => 'Hooper',
! 224: 'abstract' => '
! 225: This talk will outline the U. Penn team\'s findings, which included
! 226: the discovery of exploitable security vulnerabilities in almost every
! 227: hardware and software component of the ES&S touch-screen and optical
! 228: scan systems.
! 229: ',
! 230: 'title' =>
! 231: 'Hacking Democracy: An In Depth Analysis of the ES&S Voting Systems',
! 232: },
! 233: ],
1.4 andrew 234: ],
1.2 andrew 235: },
236: ],
237: interests => [
238: { args => undef,
1.4 andrew 239: expect => [
1.6 ! andrew 240: 'new tech',
! 241: 'activism',
! 242: 'radio',
! 243: 'lockpicking',
! 244: 'crypto',
! 245: 'privacy',
! 246: 'ethics',
! 247: 'telephones',
! 248: 'social engineering',
! 249: 'hacker spaces',
! 250: 'hardware hacking',
! 251: 'nostalgia',
! 252: 'communities',
! 253: 'science',
! 254: 'government',
! 255: 'network security',
! 256: 'malicious software',
! 257: 'pen testing',
! 258: 'web',
! 259: 'niche hacks',
1.4 andrew 260: 'media',
261: ],
1.2 andrew 262: },
263: ],
264: users => [
265: { args => undef,
1.6 ! andrew 266: expect => [],
1.2 andrew 267: },
268: ],
269: stats => [
270: { args => undef,
1.4 andrew 271: expect => qr/^Unused \s feature/xms,
1.2 andrew 272: },
273: ],
274: );
275:
1.6 ! andrew 276: my $amd
! 277: = Net::OpenAMD->new( { base_uri => 'http://api.hope.net/api/', } );
! 278: run_tests( $amd, \%tests );
! 279:
! 280: done_testing();
! 281: }
! 282:
! 283: 1;
! 284:
! 285: sub run_tests {
! 286: my ( $amd, $tests ) = @_;
! 287:
! 288: foreach my $method ( keys %{$tests} ) {
! 289: foreach my $test ( @{ $tests->{$method} } ) {
1.2 andrew 290: no warnings 'uninitialized';
291: my $result;
292: eval { $result = $amd->$method( $test->{args} ) };
1.4 andrew 293: if ( ref $test->{expect} eq 'Regexp' ) {
294: like( $@, $test->{expect}, "AMD->$method($test->{args})" );
295: }
296: elsif ( ref $test->{expect} ) {
297: is( $@, '', "AMD->$method($test->{args})" );
1.6 ! andrew 298: is_deeply( $result, $test->{expect},
! 299: "AMD->$method($test->{args}) - "
! 300: . 'got expected result' );
1.4 andrew 301: }
302: else {
303: is( $@, $test->{expect}, "AMD->$method($test->{args})" );
304: }
1.2 andrew 305: }
306: }
1.1 andrew 307: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>