6 use SGN::Test::Fixture;
8 use Test::WWW::Mechanize;
12 use Spreadsheet::Read;
17 my $f = SGN::Test::Fixture->new();
18 my $schema = $f->bcs_schema;
19 my $people_schema = $f->people_schema();
21 my $mech = Test::WWW::Mechanize->new;
26 $mech->post_ok('http://localhost:3010/brapi/v1/token', [ "username"=> "janedoe", "password"=> "secretpw", "grant_type"=> "password" ], 'login with brapi call');
28 $response = decode_json $mech->content;
30 is($response->{'userDisplayName'}, 'Jane Doe', 'check login name');
32 # create a suitable dataset
34 my $ds = CXGN::Dataset->new( { schema=> $schema, people_schema => $people_schema });
36 $ds->trials( [ 139, 141 ]);
38 #replicate_factor =fixed
39 #studyDesign_factor = None
40 my $dataset_id = $ds->sp_dataset_id();
41 my $sin_id = CXGN::List::create_list($f->dbh, "si", "", 41);
42 my $si = CXGN::List-> new({dbh=>$f->dbh, list_id=>$sin_id});
44 $si-> type('dataset');
45 $si -> add_bulk(['traits:dry matter content percentage|CO_334:0000092,fresh root weight|CO_334:0000012,fresh shoot weight measurement in kg|CO_334:0000016',
50 $mech->get_ok('http://localhost:3010/tools/gcpc', 'load gcpc input page');
52 $mech->get_ok('http://localhost:3010/ajax/gcpc/factors?dataset_id='.$dataset_id, 'get factors for dataset');
54 my $sp_data = JSON::Any->decode($mech->content());
56 my $trait_id = $sp_data->{options}->[0]->[0];
58 $mech->get_ok('http://localhost:3010/ajax/gcpc/generate_results?dataset_id='.$dataset_id.'&trait_id='.$trait_id."&method_id=GCPC&replicate_factor=fixed&studyDesign_factor=None&sin_list_id=$sin_id", 'run the GCPC analysis');
60 my $rdata = JSON::Any->decode($mech->content());
62 ok($rdata->{data}, "data created");
63 print STDERR "DATA: ".Dumper($rdata->{data});
64 #is($rdata-> {data}->[0]->[3], 1.3294458276476, "check specific no.");
65 #remove changes to the database