8 use SGN
::Test
qw( get request );
10 use CXGN
::Genomic
::Clone
;
14 my $test_clone_id = 8978;
15 my $test_clone = CXGN
::Genomic
::Clone
->retrieve($test_clone_id)
16 or BAIL_OUT
("can't retrieve clone $test_clone_id from db!");
17 my $clone_info = $test_clone->reg_info_hashref;
19 my $base = '/maps/physical/clone_async.pl';
21 ## tests JSON clone query
22 my $qjson_url = "$base?action=qclonejson&clone_id=$test_clone_id";
23 my $qjson = get
( $qjson_url );
24 like
( $qjson, qr/ver_int_read/, 'got back something from from_json' )
25 or diag
"failing url: $qjson_url";
26 my $qjson_result = eval { from_json
( $qjson ) };
27 is
(ref($qjson_result),'HASH','json seems to have parsed')
28 or diag
"$EVAL_ERROR\n$qjson_url";
29 is_deeply
( $clone_info, $qjson_result, "JSON return is the same as the reg_info_hashref from the clone object" );
32 ## tests Perl-format clone query
33 my $qperl_url = "$base?action=qcloneperl&clone_name=".$test_clone->clone_name_with_chromosome;
34 my $qperl = request
( $qperl_url );
35 is
( $qperl->code, 200, 'perl clone query succeeded')
36 or diag
"text returned was:\n".$qperl->content;
37 my $qperl_result = eval $qperl->content;
38 ok
( !$EVAL_ERROR, 'perl return evaled ok' )
39 or diag
"$EVAL_ERROR\n(url was $qperl_url)";
40 is_deeply
( $clone_info, $qperl_result, "Perl return is the same as the reg_info_hashref from the clone object" );
42 # tests that JSON and perl data structures agree
43 is_deeply
( $qjson_result, $qperl_result, "JSON and Perl return the same data structure" );
46 # test the project stats image
47 { my $pi_req = request
("$base?action=project_stats_img_html");
48 is
( $pi_req->code, 200, 'got async project stats image ok' );
49 like
( $pi_req->content, qr/\.png"/, 'a .png image url is somewhere in the html' );
50 like
( $pi_req->content, qr/<img /, 'contains an image' );
51 like
( $pi_req->content, qr/<map /, 'contains an image map' );