5 use SGN::Test::Fixture;
9 use CXGN::Trial::TrialLayoutDownload;
10 use Test::WWW::Mechanize;
14 my $test = SGN::Test::Fixture->new();
15 my $schema = $test->bcs_schema;
17 my $mech = Test::WWW::Mechanize->new;
19 $mech->post_ok('http://localhost:3010/brapi/v1/token', [ "username"=> "janedoe", "password"=> "secretpw", "grant_type"=> "password" ]);
20 my $response = decode_json $mech->content;
21 print STDERR Dumper $response;
22 is($response->{'metadata'}->{'status'}->[2]->{'message'}, 'Login Successfull');
23 my $sgn_session_id = $response->{access_token};
24 print STDERR $sgn_session_id."\n";
26 my $trial_id = $schema->resultset('Project::Project')->find({name=>'test_trial'})->project_id();
28 my $file = $test->config->{basepath}."/t/data/trial/field_coord_upload.csv";
29 my $ua = LWP::UserAgent->new;
30 $response = $ua->post(
31 'http://localhost:3010/ajax/breeders/trial/coordsupload',
32 Content_Type => 'form-data',
34 trial_coordinates_uploaded_file => [ $file, 'coords_upload', Content_Type => 'application/vnd.ms-excel', ],
35 "trial_coordinates_upload_trial_id"=>$trial_id,
36 "sgn_session_id"=>$sgn_session_id
40 #print STDERR Dumper $response;
41 ok($response->is_success);
42 my $message = $response->decoded_content;
43 my $message_hash = decode_json $message;
44 print STDERR Dumper $message_hash;
46 my $trial_layout_download = CXGN::Trial::TrialLayoutDownload->new({
48 trial_id => $trial_id,
49 data_level => 'plot_fieldMap',
51 'accession_name' => 1,
56 my $output = $trial_layout_download->get_layout_output();
57 my %hash = %{$output->{output}};
58 print STDERR Dumper \%hash;
62 '3' => 'test_accession5',
63 '1' => 'test_accession3',
64 '2' => 'test_accession1'
67 '3' => 'test_accession4',
68 '2' => 'test_accession1',
69 '1' => 'test_accession3'
72 '3' => 'test_accession3',
73 '1' => 'test_accession4',
74 '2' => 'test_accession5'
77 '3' => 'test_accession2',
78 '2' => 'test_accession1',
79 '1' => 'test_accession5'
82 '2' => 'test_accession4',
83 '1' => 'test_accession2',
84 '3' => 'test_accession2'
88 my $trial_layout = CXGN::Trial::TrialLayout->new({
90 trial_id => $trial_id,
91 experiment_type => 'field_layout'
93 my $tl = $trial_layout->get_design();
95 #Remove row_number and col_number so tests downstream don't fail
96 foreach (values %$tl) {
97 my $stock = CXGN::Stock->new({
99 stock_id => $_->{plot_id}
101 $stock->_remove_stockprop('row_number', $_->{row_number});
102 $stock->_remove_stockprop('col_number', $_->{col_number});
104 $trial_layout->generate_and_cache_layout();