1package main;
2
3use strict;
4use warnings;
5
6use Test::More 0.96;
7
8use Astro::SpaceTrack qw{ :ref };
9use HTTP::Status qw{ HTTP_I_AM_A_TEAPOT };
10
11use lib 'inc';
12
13use Mock::LWP::UserAgent;
14
15use constant DUMP_REQUEST => Astro::SpaceTrack->DUMP_REQUEST |
16    Astro::SpaceTrack->DUMP_NO_EXECUTE;
17use constant DUMP_NONE => Astro::SpaceTrack->DUMP_NONE;
18
19my $loader = Astro::SpaceTrack->__get_loader() or do {
20    plan skip_all => 'JSON required to check Space Track requests.';
21    exit;
22};
23
24note 'Space Track v2 interface';
25
26my $st = Astro::SpaceTrack->new(
27    space_track_version	=> 2,
28    dump_headers => DUMP_REQUEST,
29    username	=> 'Yehudi',
30    password	=> 'Menuhin',
31);
32
33my $base_url = $st->_make_space_track_base_url();
34
35is_resp( qw{retrieve 25544}, [ {
36	args => [
37	    basicspacedata	=> 'query',
38	    class	=> 'tle_latest',
39	    format	=> 'tle',
40	    orderby	=> 'OBJECT_NUMBER asc',
41	    OBJECT_NUMBER => 25544,
42	    ORDINAL	=> 1,
43	],
44	method => 'GET',
45	url => "$base_url/basicspacedata/query/class/tle_latest/format/tle/orderby/OBJECT_NUMBER%20asc/OBJECT_NUMBER/25544/ORDINAL/1",
46	version => 2,
47    } ],
48 );
49
50$st->set( dump_headers => DUMP_NONE );
51
52is_resp( qw{retrieve 25544}, <<'EOD' );
531 25544U First line of data
542 25544 Second line of data
55EOD
56
57$st->set( dump_headers => DUMP_REQUEST );
58
59is_resp( qw{retrieve -sort catnum 25544}, [ {
60	args => [
61	    basicspacedata	=> 'query',
62	    class	=> 'tle_latest',
63	    format	=> 'tle',
64	    orderby	=> 'OBJECT_NUMBER asc',
65	    OBJECT_NUMBER => 25544,
66	    ORDINAL	=> 1,
67	],
68	method => 'GET',
69	url => "$base_url/basicspacedata/query/class/tle_latest/format/tle/orderby/OBJECT_NUMBER%20asc/OBJECT_NUMBER/25544/ORDINAL/1",
70	version => 2,
71    } ],
72 );
73
74is_resp( qw{retrieve -sort epoch 25544}, [ {
75	args => [
76	    basicspacedata	=> 'query',
77	    class	=> 'tle_latest',
78	    format	=> 'tle',
79	    orderby	=> 'EPOCH asc',
80	    OBJECT_NUMBER => 25544,
81	    ORDINAL	=> 1,
82	],
83	method => 'GET',
84	url => "$base_url/basicspacedata/query/class/tle_latest/format/tle/orderby/EPOCH%20asc/OBJECT_NUMBER/25544/ORDINAL/1",
85	version => 2,
86    } ],
87 );
88
89is_resp( qw{retrieve -descending 25544}, [ {
90	args => [
91	    basicspacedata	=> 'query',
92	    class	=> 'tle_latest',
93	    format	=> 'tle',
94	    orderby	=> 'OBJECT_NUMBER desc',
95	    OBJECT_NUMBER => 25544,
96	    ORDINAL	=> 1,
97	],
98	method => 'GET',
99	url => "$base_url/basicspacedata/query/class/tle_latest/format/tle/orderby/OBJECT_NUMBER%20desc/OBJECT_NUMBER/25544/ORDINAL/1",
100	version => 2,
101    } ],
102 );
103
104is_resp( qw{retrieve -last5 25544}, [ {
105	args => [
106	    basicspacedata	=> 'query',
107	    class	=> 'tle_latest',
108	    format	=> 'tle',
109	    orderby	=> 'OBJECT_NUMBER asc',
110	    OBJECT_NUMBER => 25544,
111	    ORDINAL	=> '1--5',
112	],
113	method => 'GET',
114	url => "$base_url/basicspacedata/query/class/tle_latest/format/tle/orderby/OBJECT_NUMBER%20asc/OBJECT_NUMBER/25544/ORDINAL/1--5",
115	version => 2,
116    } ],
117 );
118
119$st->set( dump_headers => DUMP_NONE );
120
121is_resp( qw{retrieve -last5 25544}, <<'EOD' );
1221 25544U First line of data
1232 25544 Second line of data
1241 25544U First line of data
1252 25544 Second line of data
1261 25544U First line of data
1272 25544 Second line of data
1281 25544U First line of data
1292 25544 Second line of data
1301 25544U First line of data
1312 25544 Second line of data
132EOD
133
134$st->set( dump_headers => DUMP_REQUEST );
135
136{
137    no warnings qw{ uninitialized };
138    local $ENV{SPACETRACK_REST_FRACTIONAL_DATE} = undef;
139
140    is_resp( qw{retrieve -start_epoch 2009-04-01 25544}, [ {
141	    args => [
142		basicspacedata	=> 'query',
143		class	=> 'tle',
144		format	=> 'tle',
145		orderby	=> 'OBJECT_NUMBER asc',
146		EPOCH	=> '2009-04-01 00:00:00--2009-04-02 00:00:00',
147		OBJECT_NUMBER => 25544,
148	    ],
149	    method => 'GET',
150	    url => "$base_url/basicspacedata/query/class/tle/format/tle/orderby/OBJECT_NUMBER%20asc/EPOCH/2009-04-01%2000:00:00--2009-04-02%2000:00:00/OBJECT_NUMBER/25544",
151	    version => 2,
152	} ],
153     );
154
155    is_resp( qw{retrieve -last5 -start_epoch 2009-04-01 25544}, [ {
156	    args => [
157		basicspacedata	=> 'query',
158		class	=> 'tle',
159		format	=> 'tle',
160		orderby	=> 'OBJECT_NUMBER asc',
161		EPOCH	=> '2009-04-01 00:00:00--2009-04-02 00:00:00',
162		OBJECT_NUMBER => 25544,
163	    ],
164	    method => 'GET',
165	    url => "$base_url/basicspacedata/query/class/tle/format/tle/orderby/OBJECT_NUMBER%20asc/EPOCH/2009-04-01%2000:00:00--2009-04-02%2000:00:00/OBJECT_NUMBER/25544",
166	    version => 2,
167	} ],
168     );
169
170    is_resp( qw{retrieve -end_epoch 2009-04-01 25544}, [ {
171	    args => [
172		basicspacedata	=> 'query',
173		class	=> 'tle',
174		format	=> 'tle',
175		orderby	=> 'OBJECT_NUMBER asc',
176		EPOCH	=> '2009-03-31 00:00:00--2009-04-01 00:00:00',
177		OBJECT_NUMBER => 25544,
178	    ],
179	    method => 'GET',
180	    url => "$base_url/basicspacedata/query/class/tle/format/tle/orderby/OBJECT_NUMBER%20asc/EPOCH/2009-03-31%2000:00:00--2009-04-01%2000:00:00/OBJECT_NUMBER/25544",
181	    version => 2,
182	} ],
183     );
184
185    is_resp( qw{retrieve -start_epoch 2009-03-01 -end_epoch 2009-04-01 25544}, [ {
186	    args => [
187		basicspacedata	=> 'query',
188		class	=> 'tle',
189		format	=> 'tle',
190		orderby	=> 'OBJECT_NUMBER asc',
191		EPOCH	=> '2009-03-01 00:00:00--2009-04-01 00:00:00',
192		OBJECT_NUMBER => 25544,
193	    ],
194	    method => 'GET',
195	    url => "$base_url/basicspacedata/query/class/tle/format/tle/orderby/OBJECT_NUMBER%20asc/EPOCH/2009-03-01%2000:00:00--2009-04-01%2000:00:00/OBJECT_NUMBER/25544",
196	    version => 2,
197	} ],
198     );
199
200}
201
202note <<'EOD';
203The point of the following test is to ensure that the request is being
204properly broken into two pieces, and that the joining of the JSON in the
205responses is being handled properly.
206EOD
207
208{
209
210    local $Astro::SpaceTrack::RETRIEVAL_SIZE = 50;
211    # Force undocumented hack to be turned off.
212    no warnings qw{ uninitialized };
213    local $ENV{SPACETRACK_REST_RANGE_OPERATOR} = undef;
214
215    is_resp( retrieve => 1 .. 66, [
216	{
217	    args => [
218		basicspacedata	=> 'query',
219		class		=> 'tle_latest',
220		format		=> 'tle',
221		orderby		=> 'OBJECT_NUMBER asc',
222		OBJECT_NUMBER	=> '1--50',
223		ORDINAL		=> 1,
224	    ],
225	    method	=> 'GET',
226	    url => "$base_url/basicspacedata/query/class/tle_latest/format/tle/orderby/OBJECT_NUMBER%20asc/OBJECT_NUMBER/1--50/ORDINAL/1",
227	    version	=> 2
228	},
229	{
230	    args => [
231		basicspacedata	=> 'query',
232		class		=> 'tle_latest',
233		format		=> 'tle',
234		orderby		=> 'OBJECT_NUMBER asc',
235		OBJECT_NUMBER	=> '51--66',
236		ORDINAL		=> 1,
237	    ],
238	    method	=> 'GET',
239	    url => "$base_url/basicspacedata/query/class/tle_latest/format/tle/orderby/OBJECT_NUMBER%20asc/OBJECT_NUMBER/51--66/ORDINAL/1",
240	    version	=> 2
241	},
242    ],
243     );
244
245    $st->set( dump_headers => DUMP_NONE );
246
247    is_resp( retrieve => 1 .. 66, <<'EOD' );
2481 00004U First line of data
2492 00004 Second line of data
2501 00005U First line of data
2512 00005 Second line of data
2521 00008U First line of data
2532 00008 Second line of data
2541 00009U First line of data
2552 00009 Second line of data
2561 00011U First line of data
2572 00011 Second line of data
2581 00012U First line of data
2592 00012 Second line of data
2601 00015U First line of data
2612 00015 Second line of data
2621 00016U First line of data
2632 00016 Second line of data
2641 00017U First line of data
2652 00017 Second line of data
2661 00018U First line of data
2672 00018 Second line of data
2681 00019U First line of data
2692 00019 Second line of data
2701 00020U First line of data
2712 00020 Second line of data
2721 00022U First line of data
2732 00022 Second line of data
2741 00023U First line of data
2752 00023 Second line of data
2761 00024U First line of data
2772 00024 Second line of data
2781 00025U First line of data
2792 00025 Second line of data
2801 00026U First line of data
2812 00026 Second line of data
2821 00028U First line of data
2832 00028 Second line of data
2841 00029U First line of data
2852 00029 Second line of data
2861 00030U First line of data
2872 00030 Second line of data
2881 00031U First line of data
2892 00031 Second line of data
2901 00032U First line of data
2912 00032 Second line of data
2921 00033U First line of data
2932 00033 Second line of data
2941 00034U First line of data
2952 00034 Second line of data
2961 00035U First line of data
2972 00035 Second line of data
2981 00036U First line of data
2992 00036 Second line of data
3001 00037U First line of data
3012 00037 Second line of data
3021 00038U First line of data
3032 00038 Second line of data
3041 00039U First line of data
3052 00039 Second line of data
3061 00040U First line of data
3072 00040 Second line of data
3081 00041U First line of data
3092 00041 Second line of data
3101 00042U First line of data
3112 00042 Second line of data
3121 00043U First line of data
3132 00043 Second line of data
3141 00044U First line of data
3152 00044 Second line of data
3161 00045U First line of data
3172 00045 Second line of data
3181 00046U First line of data
3192 00046 Second line of data
3201 00047U First line of data
3212 00047 Second line of data
3221 00048U First line of data
3232 00048 Second line of data
3241 00049U First line of data
3252 00049 Second line of data
3261 00050U First line of data
3272 00050 Second line of data
3281 00051U First line of data
3292 00051 Second line of data
3301    52U First line of data
3312    52 Second line of data
3321 00053U First line of data
3332 00053 Second line of data
3341 00054U First line of data
3352 00054 Second line of data
3361 00055U First line of data
3372 00055 Second line of data
3381 00056U First line of data
3392 00056 Second line of data
3401 00057U First line of data
3412 00057 Second line of data
3421 00058U First line of data
3432 00058 Second line of data
3441 00059U First line of data
3452 00059 Second line of data
3461 00060U First line of data
3472 00060 Second line of data
3481 00061U First line of data
3492 00061 Second line of data
3501 00062U First line of data
3512 00062 Second line of data
3521 00063U First line of data
3532 00063 Second line of data
3541 00064U First line of data
3552 00064 Second line of data
3561 00065U First line of data
3572 00065 Second line of data
3581 00066U First line of data
3592 00066 Second line of data
360EOD
361
362    $st->set( dump_headers => DUMP_REQUEST );
363}
364
365is_resp( qw{set with_name 1}, 'OK' );
366
367# NOTE That the following request is forced to JSON format so that we
368# can build a NASA-format TLE from the result.
369is_resp( qw{retrieve 25544}, [ {
370	args => [
371	    basicspacedata	=> 'query',
372	    class	=> 'tle_latest',
373	    format	=> '3le',
374	    orderby	=> 'OBJECT_NUMBER asc',
375	    predicates	=> 'OBJECT_NAME,TLE_LINE1,TLE_LINE2',
376	    OBJECT_NUMBER => 25544,
377	    ORDINAL	=> 1,
378	],
379	method => 'GET',
380	url => "$base_url/basicspacedata/query/class/tle_latest/format/3le/orderby/OBJECT_NUMBER%20asc/predicates/OBJECT_NAME,TLE_LINE1,TLE_LINE2/OBJECT_NUMBER/25544/ORDINAL/1",
381	version => 2,
382    } ],
383 );
384
385$st->set( dump_headers => DUMP_NONE );
386
387is_resp( qw{retrieve 25544}, <<'EOD' );
388ISS (ZARYA)
3891 25544U First line of data
3902 25544 Second line of data
391EOD
392
393$st->set( dump_headers => DUMP_REQUEST );
394
395is_resp( qw{search_date 2009-04-01}, [
396    {
397	args => [
398	    basicspacedata	=> 'query',
399	    class	=> 'satcat',
400	    format	=> 'json',
401	    orderby	=> 'OBJECT_NUMBER asc',
402	    predicates	=> 'all',
403	    CURRENT	=> 'Y',
404	    DECAY	=> 'null-val',
405	    LAUNCH	=> '2009-04-01',
406	],
407	method => 'GET',
408	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/LAUNCH/2009-04-01",
409	version => 2,
410    },
411],
412 );
413
414$st->set( dump_headers => DUMP_NONE );
415
416is_resp( qw{search_date 2009-04-01}, '412 No catalog IDs specified.' );
417
418$st->set( dump_headers => DUMP_REQUEST );
419
420is_resp( qw{search_date -status all 2009-04-01}, [
421    {
422	args => [
423	    basicspacedata	=> 'query',
424	    class	=> 'satcat',
425	    format	=> 'json',
426	    orderby	=> 'OBJECT_NUMBER asc',
427	    predicates	=> 'all',
428	    CURRENT	=> 'Y',
429	    LAUNCH	=> '2009-04-01',
430	],
431	method => 'GET',
432	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/LAUNCH/2009-04-01",
433	version => 2,
434    },
435],
436 );
437
438is_resp( qw{search_date -status onorbit 2009-04-01}, [
439    {
440	args => [
441	    basicspacedata	=> 'query',
442	    class	=> 'satcat',
443	    format	=> 'json',
444	    orderby	=> 'OBJECT_NUMBER asc',
445	    predicates	=> 'all',
446	    CURRENT	=> 'Y',
447	    DECAY	=> 'null-val',
448	    LAUNCH	=> '2009-04-01',
449	],
450	method => 'GET',
451	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/LAUNCH/2009-04-01",
452	version => 2,
453    },
454],
455 );
456
457is_resp( qw{search_date -status decayed 2009-04-01}, [
458    {
459	args => [
460	    basicspacedata	=> 'query',
461	    class	=> 'satcat',
462	    format	=> 'json',
463	    orderby	=> 'OBJECT_NUMBER asc',
464	    predicates	=> 'all',
465	    CURRENT	=> 'Y',
466	    DECAY	=> '<>null-val',
467	    LAUNCH	=> '2009-04-01',
468	],
469	method => 'GET',
470	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/%3C%3Enull-val/LAUNCH/2009-04-01",
471	version => 2,
472    },
473],
474 );
475
476is_resp( qw{search_date -exclude debris 2009-04-01}, [
477    {
478	args => [
479	    basicspacedata	=> 'query',
480	    class	=> 'satcat',
481	    format	=> 'json',
482	    orderby	=> 'OBJECT_NUMBER asc',
483	    predicates	=> 'all',
484	    CURRENT	=> 'Y',
485	    DECAY	=> 'null-val',
486	    LAUNCH	=> '2009-04-01',
487	    OBJECT_TYPE	=> 'OTHER,PAYLOAD,ROCKET BODY,TBA,UNKNOWN',
488	],
489	method => 'GET',
490	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/LAUNCH/2009-04-01/OBJECT_TYPE/OTHER,PAYLOAD,ROCKET%20BODY,TBA,UNKNOWN",
491	version => 2,
492    },
493],
494 );
495
496is_resp( qw{search_date -include payload 2009-04-01}, [
497    {
498	args => [
499	    basicspacedata	=> 'query',
500	    class	=> 'satcat',
501	    format	=> 'json',
502	    orderby	=> 'OBJECT_NUMBER asc',
503	    predicates	=> 'all',
504	    CURRENT	=> 'Y',
505	    DECAY	=> 'null-val',
506	    LAUNCH	=> '2009-04-01',
507	    OBJECT_TYPE	=> 'PAYLOAD',
508	],
509	method => 'GET',
510	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/LAUNCH/2009-04-01/OBJECT_TYPE/PAYLOAD",
511	version => 2,
512    },
513],
514 );
515
516is_resp( qw{search_date -exclude rocket 2009-04-01}, [
517    {
518	args => [
519	    basicspacedata	=> 'query',
520	    class	=> 'satcat',
521	    format	=> 'json',
522	    orderby	=> 'OBJECT_NUMBER asc',
523	    predicates	=> 'all',
524	    CURRENT	=> 'Y',
525	    DECAY	=> 'null-val',
526	    LAUNCH	=> '2009-04-01',
527	    OBJECT_TYPE	=> 'DEBRIS,OTHER,PAYLOAD,TBA,UNKNOWN',
528	],
529	method => 'GET',
530	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/LAUNCH/2009-04-01/OBJECT_TYPE/DEBRIS,OTHER,PAYLOAD,TBA,UNKNOWN",
531	version => 2,
532    },
533],
534 );
535
536{
537    no warnings qw{qw};	## no critic (ProhibitNoWarnings)
538    is_resp( qw{search_date -exclude debris,rocket 2009-04-01}, [
539	{
540	    args => [
541		basicspacedata	=> 'query',
542		class	=> 'satcat',
543		format	=> 'json',
544		orderby	=> 'OBJECT_NUMBER asc',
545		predicates	=> 'all',
546		CURRENT	=> 'Y',
547		DECAY	=> 'null-val',
548		LAUNCH	=> '2009-04-01',
549		OBJECT_TYPE	=> 'OTHER,PAYLOAD,TBA,UNKNOWN',
550	    ],
551	    method => 'GET',
552	    url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/LAUNCH/2009-04-01/OBJECT_TYPE/OTHER,PAYLOAD,TBA,UNKNOWN",
553	version => 2,
554	},
555    ],
556     );
557}
558
559is_resp( qw{search_date -exclude debris -exclude rocket 2009-04-01}, [
560    {
561	args => [
562	    basicspacedata	=> 'query',
563	    class	=> 'satcat',
564	    format	=> 'json',
565	    orderby	=> 'OBJECT_NUMBER asc',
566	    predicates	=> 'all',
567	    CURRENT	=> 'Y',
568	    DECAY	=> 'null-val',
569	    LAUNCH	=> '2009-04-01',
570	    OBJECT_TYPE	=> 'OTHER,PAYLOAD,TBA,UNKNOWN',
571	],
572	method => 'GET',
573	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/LAUNCH/2009-04-01/OBJECT_TYPE/OTHER,PAYLOAD,TBA,UNKNOWN",
574	version => 2,
575    },
576],
577 );
578
579is_resp( qw{search_id 98067}, [
580    {
581	args => [
582	    basicspacedata	=> 'query',
583	    class	=> 'satcat',
584	    format	=> 'json',
585	    orderby	=> 'OBJECT_NUMBER asc',
586	    predicates	=> 'all',
587	    CURRENT	=> 'Y',
588	    DECAY	=> 'null-val',
589	    OBJECT_ID	=> '~~1998-067',
590	],
591	method => 'GET',
592	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_ID/~~1998-067",
593	version => 2,
594    },
595],
596 );
597
598$st->set( dump_headers => DUMP_NONE );
599
600is_resp( qw{search_id 98067}, <<'EOD' );
601ISS (ZARYA)
6021 25544U First line of data
6032 25544 Second line of data
604ISS DEB (VSPLESK PLTFRM)
6051 39496U First line of data
6062 39496 Second line of data
607FLOCK 1-3
6081 39512U First line of data
6092 39512 Second line of data
610FLOCK 1-1
6111 39513U First line of data
6122 39513 Second line of data
613FLOCK 1-2
6141 39514U First line of data
6152 39514 Second line of data
616FLOCK 1-4
6171 39515U First line of data
6182 39515 Second line of data
619FLOCK 1-5
6201 39518U First line of data
6212 39518 Second line of data
622FLOCK 1-6
6231 39519U First line of data
6242 39519 Second line of data
625FLOCK 1-7
6261 39520U First line of data
6272 39520 Second line of data
628FLOCK 1-8
6291 39521U First line of data
6302 39521 Second line of data
631FLOCK 1-9
6321 39525U First line of data
6332 39525 Second line of data
634FLOCK 1-10
6351 39526U First line of data
6362 39526 Second line of data
637FLOCK 1-11
6381 39527U First line of data
6392 39527 Second line of data
640FLOCK 1-12
6411 39528U First line of data
6422 39528 Second line of data
643FLOCK 1-13
6441 39529U First line of data
6452 39529 Second line of data
646FLOCK 1-14
6471 39530U First line of data
6482 39530 Second line of data
649FLOCK 1-15
6501 39531U First line of data
6512 39531 Second line of data
652FLOCK 1-16
6531 39532U First line of data
6542 39532 Second line of data
655FLOCK 1-17
6561 39555U First line of data
6572 39555 Second line of data
658FLOCK 1-18
6591 39556U First line of data
6602 39556 Second line of data
661FLOCK 1-21
6621 39557U First line of data
6632 39557 Second line of data
664FLOCK 1-22
6651 39558U First line of data
6662 39558 Second line of data
667FLOCK 1-19
6681 39559U First line of data
6692 39559 Second line of data
670FLOCK 1-20
6711 39560U First line of data
6722 39560 Second line of data
673FLOCK 1-23
6741 39561U First line of data
6752 39561 Second line of data
676FLOCK 1-24
6771 39562U First line of data
6782 39562 Second line of data
679FLOCK 1-25
6801 39563U First line of data
6812 39563 Second line of data
682FLOCK 1-26
6831 39564U First line of data
6842 39564 Second line of data
685FLOCK 1-28
6861 39566U First line of data
6872 39566 Second line of data
688ARDUSAT 2
6891 39567U First line of data
6902 39567 Second line of data
691UAPSAT 1
6921 39568U First line of data
6932 39568 Second line of data
694SKYCUBE
6951 39569U First line of data
6962 39569 Second line of data
697LITSAT 1
6981 39570U First line of data
6992 39570 Second line of data
700LITUANICASAT 1
7011 39571U First line of data
7022 39571 Second line of data
703EOD
704
705$st->set( dump_headers => DUMP_REQUEST );
706
707is_resp( qw{search_id 98}, [
708    {
709	args => [
710	    basicspacedata	=> 'query',
711	    class	=> 'satcat',
712	    format	=> 'json',
713	    orderby	=> 'OBJECT_NUMBER asc',
714	    predicates	=> 'all',
715	    CURRENT	=> 'Y',
716	    DECAY	=> 'null-val',
717	    OBJECT_ID	=> '~~1998-',
718	],
719	method => 'GET',
720	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_ID/~~1998-",
721	version => 2,
722    },
723],
724 );
725
726is_resp( qw{search_id 98067A}, [
727    {
728	args => [
729	    basicspacedata	=> 'query',
730	    class	=> 'satcat',
731	    format	=> 'json',
732	    orderby	=> 'OBJECT_NUMBER asc',
733	    predicates	=> 'all',
734	    CURRENT	=> 'Y',
735	    DECAY	=> 'null-val',
736	    OBJECT_ID	=> '1998-067A',
737	],
738	method => 'GET',
739	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_ID/1998-067A",
740	version => 2,
741    },
742],
743 );
744
745$st->set( dump_headers => DUMP_NONE );
746
747is_resp( qw{search_id 98067A}, <<'EOD' );
748ISS (ZARYA)
7491 25544U First line of data
7502 25544 Second line of data
751EOD
752
753$st->set( dump_headers => DUMP_REQUEST );
754
755# TODO update below here
756
757is_resp( qw{search_id -status all 98067}, [
758    {
759	args => [
760	    basicspacedata	=> 'query',
761	    class	=> 'satcat',
762	    format	=> 'json',
763	    orderby	=> 'OBJECT_NUMBER asc',
764	    predicates	=> 'all',
765	    CURRENT	=> 'Y',
766	    OBJECT_ID	=> '~~1998-067',
767	],
768	method => 'GET',
769	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/OBJECT_ID/~~1998-067",
770	version => 2,
771    },
772],
773 );
774
775is_resp( qw{search_id -status onorbit 98067}, [
776    {
777	args => [
778	    basicspacedata	=> 'query',
779	    class	=> 'satcat',
780	    format	=> 'json',
781	    orderby	=> 'OBJECT_NUMBER asc',
782	    predicates	=> 'all',
783	    CURRENT	=> 'Y',
784	    DECAY	=> 'null-val',
785	    OBJECT_ID	=> '~~1998-067',
786	],
787	method => 'GET',
788	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_ID/~~1998-067",
789	version => 2,
790    },
791],
792 );
793
794is_resp( qw{search_id -status decayed 98067}, [
795    {
796	args => [
797	    basicspacedata	=> 'query',
798	    class	=> 'satcat',
799	    format	=> 'json',
800	    orderby	=> 'OBJECT_NUMBER asc',
801	    predicates	=> 'all',
802	    CURRENT	=> 'Y',
803	    DECAY	=> '<>null-val',
804	    OBJECT_ID	=> '~~1998-067',
805	],
806	method => 'GET',
807	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/%3C%3Enull-val/OBJECT_ID/~~1998-067",
808	version => 2,
809    },
810],
811 );
812
813is_resp( qw{search_id -exclude debris 98067}, [
814    {
815	args => [
816	    basicspacedata	=> 'query',
817	    class	=> 'satcat',
818	    format	=> 'json',
819	    orderby	=> 'OBJECT_NUMBER asc',
820	    predicates	=> 'all',
821	    CURRENT	=> 'Y',
822	    DECAY	=> 'null-val',
823	    OBJECT_ID	=> '~~1998-067',
824	    OBJECT_TYPE	=> 'OTHER,PAYLOAD,ROCKET BODY,TBA,UNKNOWN',
825	],
826	method => 'GET',
827	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_ID/~~1998-067/OBJECT_TYPE/OTHER,PAYLOAD,ROCKET%20BODY,TBA,UNKNOWN",
828	version => 2,
829    },
830],
831 );
832
833is_resp( qw{search_id -exclude rocket 98067}, [
834    {
835	args => [
836	    basicspacedata	=> 'query',
837	    class	=> 'satcat',
838	    format	=> 'json',
839	    orderby	=> 'OBJECT_NUMBER asc',
840	    predicates	=> 'all',
841	    CURRENT	=> 'Y',
842	    DECAY	=> 'null-val',
843	    OBJECT_ID	=> '~~1998-067',
844	    OBJECT_TYPE	=> 'DEBRIS,OTHER,PAYLOAD,TBA,UNKNOWN',
845	],
846	method => 'GET',
847	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_ID/~~1998-067/OBJECT_TYPE/DEBRIS,OTHER,PAYLOAD,TBA,UNKNOWN",
848	version => 2,
849    },
850],
851 );
852
853{
854    no warnings qw{qw};	## no critic (ProhibitNoWarnings)
855    is_resp( qw{search_id -exclude debris,rocket 98067}, [
856	{
857	    args => [
858		basicspacedata	=> 'query',
859		class	=> 'satcat',
860		format	=> 'json',
861		orderby	=> 'OBJECT_NUMBER asc',
862		predicates	=> 'all',
863		CURRENT	=> 'Y',
864		DECAY	=> 'null-val',
865		OBJECT_ID	=> '~~1998-067',
866		OBJECT_TYPE	=> 'OTHER,PAYLOAD,TBA,UNKNOWN',
867	    ],
868	    method => 'GET',
869	    url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_ID/~~1998-067/OBJECT_TYPE/OTHER,PAYLOAD,TBA,UNKNOWN",
870	version => 2,
871	}
872    ],
873     );
874}
875
876is_resp( qw{search_id -exclude debris -exclude rocket 98067}, [
877    {
878	args => [
879	    basicspacedata	=> 'query',
880	    class	=> 'satcat',
881	    format	=> 'json',
882	    orderby	=> 'OBJECT_NUMBER asc',
883	    predicates	=> 'all',
884	    CURRENT	=> 'Y',
885	    DECAY	=> 'null-val',
886	    OBJECT_ID	=> '~~1998-067',
887	    OBJECT_TYPE	=> 'OTHER,PAYLOAD,TBA,UNKNOWN',
888	],
889	method => 'GET',
890	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_ID/~~1998-067/OBJECT_TYPE/OTHER,PAYLOAD,TBA,UNKNOWN",
891	version => 2,
892    },
893],
894 );
895
896is_resp( qw{search_name ISS}, [
897    {
898	args => [
899	    basicspacedata	=> 'query',
900	    class	=> 'satcat',
901	    format	=> 'json',
902	    orderby	=> 'OBJECT_NUMBER asc',
903	    predicates	=> 'all',
904	    CURRENT	=> 'Y',
905	    DECAY	=> 'null-val',
906	    OBJECT_NAME	=> '~~ISS',
907	],
908	method => 'GET',
909	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_NAME/~~ISS",
910	version => 2,
911    },
912],
913 );
914
915is_resp( qw{search_name -status all ISS}, [
916    {
917	args => [
918	    basicspacedata	=> 'query',
919	    class	=> 'satcat',
920	    format	=> 'json',
921	    orderby	=> 'OBJECT_NUMBER asc',
922	    predicates	=> 'all',
923	    CURRENT	=> 'Y',
924	    OBJECT_NAME	=> '~~ISS',
925	],
926	method => 'GET',
927	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/OBJECT_NAME/~~ISS",
928	version => 2,
929    },
930],
931 );
932
933is_resp( qw{search_name -status onorbit ISS}, [
934    {
935	args => [
936	    basicspacedata	=> 'query',
937	    class	=> 'satcat',
938	    format	=> 'json',
939	    orderby	=> 'OBJECT_NUMBER asc',
940	    predicates	=> 'all',
941	    CURRENT	=> 'Y',
942	    DECAY	=> 'null-val',
943	    OBJECT_NAME	=> '~~ISS',
944	],
945	method => 'GET',
946	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_NAME/~~ISS",
947	version => 2,
948    },
949],
950 );
951
952is_resp( qw{search_name -status decayed ISS}, [
953    {
954	args => [
955	    basicspacedata	=> 'query',
956	    class	=> 'satcat',
957	    format	=> 'json',
958	    orderby	=> 'OBJECT_NUMBER asc',
959	    predicates	=> 'all',
960	    CURRENT	=> 'Y',
961	    DECAY	=> '<>null-val',
962	    OBJECT_NAME	=> '~~ISS',
963	],
964	method => 'GET',
965	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/%3C%3Enull-val/OBJECT_NAME/~~ISS",
966	version => 2,
967    },
968],
969 );
970
971is_resp( qw{search_name -exclude debris ISS}, [
972    {
973	args => [
974	    basicspacedata	=> 'query',
975	    class	=> 'satcat',
976	    format	=> 'json',
977	    orderby	=> 'OBJECT_NUMBER asc',
978	    predicates	=> 'all',
979	    CURRENT	=> 'Y',
980	    DECAY	=> 'null-val',
981	    OBJECT_NAME	=> '~~ISS',
982	    OBJECT_TYPE	=> 'OTHER,PAYLOAD,ROCKET BODY,TBA,UNKNOWN',
983	],
984	method => 'GET',
985	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_NAME/~~ISS/OBJECT_TYPE/OTHER,PAYLOAD,ROCKET%20BODY,TBA,UNKNOWN",
986	version => 2,
987    },
988],
989 );
990
991is_resp( qw{search_name -exclude rocket ISS}, [
992    {
993	args => [
994	    basicspacedata	=> 'query',
995	    class	=> 'satcat',
996	    format	=> 'json',
997	    orderby	=> 'OBJECT_NUMBER asc',
998	    predicates	=> 'all',
999	    CURRENT	=> 'Y',
1000	    DECAY	=> 'null-val',
1001	    OBJECT_NAME	=> '~~ISS',
1002	    OBJECT_TYPE	=> 'DEBRIS,OTHER,PAYLOAD,TBA,UNKNOWN',
1003	],
1004	method => 'GET',
1005	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_NAME/~~ISS/OBJECT_TYPE/DEBRIS,OTHER,PAYLOAD,TBA,UNKNOWN",
1006	version => 2,
1007    },
1008],
1009 );
1010
1011{
1012    no warnings qw{qw};	## no critic (ProhibitNoWarnings)
1013    is_resp( qw{search_name -exclude debris,rocket ISS}, [ {
1014	args => [
1015	    basicspacedata	=> 'query',
1016	    class	=> 'satcat',
1017	    format	=> 'json',
1018	    orderby	=> 'OBJECT_NUMBER asc',
1019	    predicates	=> 'all',
1020	    CURRENT	=> 'Y',
1021	    DECAY	=> 'null-val',
1022	    OBJECT_NAME	=> '~~ISS',
1023	    OBJECT_TYPE	=> 'OTHER,PAYLOAD,TBA,UNKNOWN',
1024	],
1025	method => 'GET',
1026	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_NAME/~~ISS/OBJECT_TYPE/OTHER,PAYLOAD,TBA,UNKNOWN",
1027	version => 2,
1028	} ],
1029     );
1030}
1031
1032is_resp( qw{search_name -exclude debris -exclude rocket ISS}, [
1033    {
1034	args => [
1035	    basicspacedata	=> 'query',
1036	    class	=> 'satcat',
1037	    format	=> 'json',
1038	    orderby	=> 'OBJECT_NUMBER asc',
1039	    predicates	=> 'all',
1040	    CURRENT	=> 'Y',
1041	    DECAY	=> 'null-val',
1042	    OBJECT_NAME	=> '~~ISS',
1043	    OBJECT_TYPE	=> 'OTHER,PAYLOAD,TBA,UNKNOWN',
1044	],
1045	method => 'GET',
1046	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_NAME/~~ISS/OBJECT_TYPE/OTHER,PAYLOAD,TBA,UNKNOWN",
1047	version => 2,
1048    },
1049],
1050 );
1051
1052is_resp( qw{ search_oid 25544 }, [
1053    {
1054	args => [
1055	    basicspacedata	=> 'query',
1056	    class	=> 'satcat',
1057	    format	=> 'json',
1058	    orderby	=> 'OBJECT_NUMBER asc',
1059	    predicates	=> 'all',
1060	    CURRENT	=> 'Y',
1061	    DECAY	=> 'null-val',
1062	    OBJECT_NUMBER	=> 25544,
1063	],
1064	method => 'GET',
1065	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_NUMBER/25544",
1066	version => 2,
1067    },
1068],
1069 );
1070
1071$st->set( dump_headers => DUMP_NONE );
1072
1073is_resp( qw{ search_oid 25544 }, <<'EOD' );
1074ISS (ZARYA)
10751 25544U First line of data
10762 25544 Second line of data
1077EOD
1078
1079$st->set( dump_headers => DUMP_REQUEST );
1080
1081is_resp( qw{ search_oid -format json 25544 }, [
1082    {
1083	args => [
1084	    basicspacedata	=> 'query',
1085	    class	=> 'satcat',
1086	    format	=> 'json',
1087	    orderby	=> 'OBJECT_NUMBER asc',
1088	    predicates	=> 'all',
1089	    CURRENT	=> 'Y',
1090	    DECAY	=> 'null-val',
1091	    OBJECT_NUMBER	=> 25544,
1092	],
1093	method => 'GET',
1094	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_NUMBER/25544",
1095	version => 2,
1096    },
1097],
1098 );
1099
1100$st->set( dump_headers => DUMP_NONE );
1101
1102is_resp( qw{ search_oid -format json 25544 },
1103[
1104   {
1105      'COMMENT'	=> 'GENERATED VIA SPACETRACK.ORG API',
1106      'FILE'	=> '1681502',
1107      'INTLDES'	=> '98067A',
1108      'NORAD_CAT_ID'	=> '25544',
1109      'OBJECT_ID'	=> '1998-067A',
1110      'OBJECT_NAME'	=> 'ISS (ZARYA)',
1111      'OBJECT_NUMBER'	=> '25544',
1112      'OBJECT_TYPE'	=> 'PAYLOAD',
1113      'TLE_LINE0'	=> '0 ISS (ZARYA)',
1114      'TLE_LINE1'	=> '1 25544U First line of data',
1115      'TLE_LINE2'	=> '2 25544 Second line of data',
1116   }
1117]
1118 );
1119
1120$st->set( dump_headers => DUMP_REQUEST );
1121
1122is_resp( qw{ search_oid -format tle 25544 }, [
1123    {
1124	args => [
1125	    basicspacedata	=> 'query',
1126	    class	=> 'satcat',
1127	    format	=> 'json',
1128	    orderby	=> 'OBJECT_NUMBER asc',
1129	    predicates	=> 'all',
1130	    CURRENT	=> 'Y',
1131	    DECAY	=> 'null-val',
1132	    OBJECT_NUMBER	=> 25544,
1133	],
1134	method => 'GET',
1135	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_NUMBER/25544",
1136	version => 2,
1137    },
1138],
1139 );
1140
1141$st->set( dump_headers => DUMP_NONE );
1142
1143is_resp( qw{ search_oid -format tle 25544 }, <<'EOD' );
11441 25544U First line of data
11452 25544 Second line of data
1146EOD
1147
1148$st->set( dump_headers => DUMP_REQUEST );
1149
1150is_resp( qw{ search_oid -format 3le 25544 }, [
1151    {
1152	args => [
1153	    basicspacedata	=> 'query',
1154	    class	=> 'satcat',
1155	    format	=> 'json',
1156	    orderby	=> 'OBJECT_NUMBER asc',
1157	    predicates	=> 'all',
1158	    CURRENT	=> 'Y',
1159	    DECAY	=> 'null-val',
1160	    OBJECT_NUMBER	=> 25544,
1161	],
1162	method => 'GET',
1163	url => "$base_url/basicspacedata/query/class/satcat/format/json/orderby/OBJECT_NUMBER%20asc/predicates/all/CURRENT/Y/DECAY/null-val/OBJECT_NUMBER/25544",
1164	version => 2,
1165    },
1166],
1167 );
1168
1169$st->set( dump_headers => DUMP_NONE );
1170
1171is_resp( qw{ search_oid -format 3le 25544 }, <<'EOD' );
11720 ISS (ZARYA)
11731 25544U First line of data
11742 25544 Second line of data
1175EOD
1176
1177{
1178    my $with_name = $st->getv( 'with_name' );
1179
1180    $st->set( with_name => 1 );
1181
1182    is_resp( search_oid => {}, 25544, <<'EOD' );
1183ISS (ZARYA)
11841 25544U First line of data
11852 25544 Second line of data
1186EOD
1187
1188    $st->set( with_name => 0 );
1189
1190    is_resp( search_oid => {}, 25544, <<'EOD' );
11911 25544U First line of data
11922 25544 Second line of data
1193EOD
1194
1195    $st->set( with_name => $with_name );
1196}
1197
1198$st->set( dump_headers => DUMP_REQUEST );
1199
1200is_resp( qw{spacetrack iridium}, [
1201    {
1202	args => [
1203	    basicspacedata	=> 'query',
1204	    class		=> 'tle_latest',
1205	    format		=> '3le',
1206	    orderby		=> 'OBJECT_NUMBER asc',
1207	    predicates		=> 'OBJECT_NAME,TLE_LINE1,TLE_LINE2',
1208	    EPOCH		=> '>now-30',
1209	    OBJECT_NAME		=> 'iridium~~',
1210	    OBJECT_TYPE		=> 'payload',
1211	    ORDINAL		=> 1,
1212	],
1213	method => 'GET',
1214	url => "$base_url/basicspacedata/query/class/tle_latest/format/3le/orderby/OBJECT_NUMBER%20asc/predicates/OBJECT_NAME,TLE_LINE1,TLE_LINE2/EPOCH/%3Enow-30/OBJECT_NAME/iridium~~/OBJECT_TYPE/payload/ORDINAL/1",
1215	version => 2,
1216    },
1217],
1218 );
1219
1220is_resp( qw{ spacetrack special }, [
1221    {
1222	args => [
1223	    basicspacedata	=> 'query',
1224	    class		=> 'tle_latest',
1225	    favorites		=> 'Special_interest',
1226	    format		=> '3le',
1227	    predicates		=> 'OBJECT_NAME,TLE_LINE1,TLE_LINE2',
1228	    EPOCH		=> '>now-30',
1229	    ORDINAL		=> 1
1230	],
1231	method	=> 'GET',
1232	url	=> "$base_url/basicspacedata/query/class/tle_latest/favorites/Special_interest/format/3le/predicates/OBJECT_NAME,TLE_LINE1,TLE_LINE2/EPOCH/%3Enow-30/ORDINAL/1",
1233	version	=> 2
1234    },
1235],
1236 );
1237
1238is_resp( qw{set with_name 0}, 'OK' );
1239
1240
1241is_resp( qw{spacetrack iridium}, [
1242    {
1243	args => [
1244	    basicspacedata	=> 'query',
1245	    class		=> 'tle_latest',
1246	    format		=> 'tle',
1247	    orderby		=> 'OBJECT_NUMBER asc',
1248	    EPOCH		=> '>now-30',
1249	    OBJECT_NAME		=> 'iridium~~',
1250	    OBJECT_TYPE		=> 'payload',
1251	    ORDINAL		=> 1,
1252	],
1253	method => 'GET',
1254	url => "$base_url/basicspacedata/query/class/tle_latest/format/tle/orderby/OBJECT_NUMBER%20asc/EPOCH/%3Enow-30/OBJECT_NAME/iridium~~/OBJECT_TYPE/payload/ORDINAL/1",
1255	version => 2,
1256    },
1257],
1258 );
1259
1260is_resp( qw{retrieve -json -since_file 1848000 25544 25546}, [
1261    {
1262	args => [
1263	    basicspacedata	=> 'query',
1264	    class		=> 'tle',
1265	    format		=> 'json',
1266	    orderby		=> 'OBJECT_NUMBER asc',
1267	    FILE		=> '>1848000',
1268	    OBJECT_NUMBER	=> '25544,25546',
1269	],
1270	method	=> "GET",
1271	url	=> "https://www.space-track.org/basicspacedata/query/class/tle/format/json/orderby/OBJECT_NUMBER%20asc/FILE/%3E1848000/OBJECT_NUMBER/25544,25546",
1272	version	=> 2,
1273    }
1274],
1275 );
1276
1277=begin comment
1278
1279# TODO Not supported by Space Track v2 interface
1280is_resp( qw{spacetrack 10}, {
1281	args => [
1282	    basicspacedata	=> 'query',
1283	],
1284	method => 'GET',
1285	url => $base_url,
1286	version => 2,
1287    },
1288 );
1289
1290=end comment
1291
1292=cut
1293
1294is_resp( qw{box_score}, [
1295    {
1296	args => [
1297	    basicspacedata	=> 'query',
1298	    class	=> 'boxscore',
1299	    format	=> 'json',
1300	    predicates	=> 'all',
1301	],
1302	method => 'GET',
1303	url => "$base_url/basicspacedata/query/class/boxscore/format/json/predicates/all",
1304	version => 2,
1305    },
1306],
1307 );
1308
1309done_testing;
1310
1311my $warning;
1312
1313sub warning_like {
1314    splice @_, 0, 0, $warning;
1315    goto &like;
1316}
1317
1318sub is_resp {	## no critic (RequireArgUnpacking)
1319    my @args = @_;
1320    my $opt = HASH_REF eq ref $args[0] ? shift @args : {};
1321    my $method = shift @args;
1322    my $query = pop @args;
1323    my $name = "\$st->$method(" . join( ', ', map {"'$_'"} @args ) . ')';
1324    my ( $resp, @extra );
1325    {
1326	$warning = undef;
1327	local $SIG{__WARN__} = sub { $warning = $_[0] };
1328	if ( $opt->{list_context} ) {
1329	    ( $resp, @extra ) = $st->$method( @args );
1330	} else {
1331	    $resp = $st->$method( @args );
1332	}
1333	not defined $warning
1334	    or $opt->{allow_warning}
1335	    or do {
1336	    $warning =~ s{\bat t/spacetrack_request.t\b.*}{}sm;
1337	    @_ = qq{$name. Unexpected warning "$warning"};
1338	    goto &fail;
1339	};
1340    }
1341    my ($got);
1342
1343    if ( $resp && $resp->isa('HTTP::Response') ) {
1344	if ( $resp->code() == HTTP_I_AM_A_TEAPOT ) {
1345	    $got = $loader->( $resp->content() );
1346	} elsif ( $resp->is_success() ) {
1347	    $got = $resp->content();
1348	    $got =~ m/ \A \s* [[] \s* [{] .* [}] \s* []] \s* \z /smx
1349		and $got = $loader->( $got );
1350	} else {
1351	    $got = $resp->status_line();
1352	}
1353    } else {
1354	$got = $resp;
1355    }
1356    $opt->{list_context}
1357	and $got = [ $got, @extra ];
1358
1359    @_ = ($got, $query, $name);
1360    ref $query
1361	and goto &is_deeply;
1362    goto &is;
1363}
1364
1365sub year {
1366    return (localtime)[5] + 1900;
1367}
1368
13691;
1370
1371__END__
1372
1373# ex: set filetype=perl textwidth=72 :
1374