From ebe7ed73e170cef2ee777fe4e99a9dd34edc6c5e Mon Sep 17 00:00:00 2001 From: nickmorales Date: Wed, 26 Jul 2017 12:04:41 -0400 Subject: [PATCH] tests pass --- t/unit_fixture/AJAX/Accession_usage.t | 8 +- t/unit_fixture/AJAX/BrAPI.t | 2 +- t/unit_fixture/AJAX/Search/CrossSearch.t | 184 +++++++++------------ t/unit_fixture/AJAX/Search/Stock.t | 264 +++++++++++++++---------------- 4 files changed, 211 insertions(+), 247 deletions(-) rewrite t/unit_fixture/AJAX/Search/CrossSearch.t (62%) rewrite t/unit_fixture/AJAX/Search/Stock.t (70%) diff --git a/t/unit_fixture/AJAX/Accession_usage.t b/t/unit_fixture/AJAX/Accession_usage.t index 35c209f58..f7d5c1857 100644 --- a/t/unit_fixture/AJAX/Accession_usage.t +++ b/t/unit_fixture/AJAX/Accession_usage.t @@ -42,17 +42,13 @@ $mech->get_ok('http://localhost:3010/ajax/accession_usage_female'); $response = decode_json $mech->content; print STDERR Dumper $response; -is_deeply($response,{'data' =>[ -['test_accession4', 15] -]}, 'female usage'); +is_deeply($response,{'data' => [['test_accession4',15],['test_accession1',1],['test_accession3',1]]}, 'female usage'); $mech->get_ok('http://localhost:3010/ajax/accession_usage_male'); $response = decode_json $mech->content; print STDERR Dumper $response; -is_deeply($response, {'data'=>[ -['test_accession5', 15] -]}, 'male usage'); +is_deeply($response, {'data' => [['test_accession5',15],['test_accession2',1]]}, 'male usage'); done_testing(); diff --git a/t/unit_fixture/AJAX/BrAPI.t b/t/unit_fixture/AJAX/BrAPI.t index 4a6bbf134..a696246d6 100644 --- a/t/unit_fixture/AJAX/BrAPI.t +++ b/t/unit_fixture/AJAX/BrAPI.t @@ -72,7 +72,7 @@ is_deeply($response, {'result' => {'donors' => [],'acquisitionDate' => undef,'ge $mech->get_ok('http://localhost:3010/brapi/v1/germplasm/38876/pedigree'); $response = decode_json $mech->content; print STDERR Dumper $response; -is_deeply($response, {'result' => {'parent2Id' => 38843,'pedigree' => 'test_accession4/test_accession5','parent1Id' => 38843,'germplasmDbId' => '38876'},'metadata' => {'datafiles' => [],'status' => [{'info' => 'BrAPI base call found with page=0, pageSize=10'},{'info' => 'Loading CXGN::BrAPI::v1::Germplasm'},{'success' => 'Germplasm pedigree result constructed'}],'pagination' => {'currentPage' => 0,'totalCount' => 1,'pageSize' => 1,'totalPages' => 1}}}, 'germplasm pedigree'); +is_deeply($response, {'result' => {'parent2Id' => 38844,'pedigree' => 'test_accession4/test_accession5','parent1Id' => 38843,'germplasmDbId' => '38876'},'metadata' => {'datafiles' => [],'status' => [{'info' => 'BrAPI base call found with page=0, pageSize=10'},{'info' => 'Loading CXGN::BrAPI::v1::Germplasm'},{'success' => 'Germplasm pedigree result constructed'}],'pagination' => {'currentPage' => 0,'totalCount' => 1,'pageSize' => 1,'totalPages' => 1}}}, 'germplasm pedigree'); $mech->get_ok('http://localhost:3010/brapi/v1/germplasm/38937/markerprofiles'); $response = decode_json $mech->content; diff --git a/t/unit_fixture/AJAX/Search/CrossSearch.t b/t/unit_fixture/AJAX/Search/CrossSearch.t dissimilarity index 62% index 9474ceb7e..95a162275 100644 --- a/t/unit_fixture/AJAX/Search/CrossSearch.t +++ b/t/unit_fixture/AJAX/Search/CrossSearch.t @@ -1,108 +1,76 @@ - -use strict; -use warnings; - -use lib 't/lib'; -use SGN::Test::Fixture; -use Test::More; -use Test::WWW::Mechanize; - -use Data::Dumper; -use JSON; -local $Data::Dumper::Indent = 0; - -my $f = SGN::Test::Fixture->new(); -my $schema = $f->bcs_schema; - -my $mech = Test::WWW::Mechanize->new; -my $response; - - -$mech->post_ok('http://localhost:3010/ajax/search/pedigree_male_parents',["pedigree_female_parent" => "test_accession4"] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'data' => [ -['test_accession5'] -]},'male parent search'); - -$mech->post_ok('http://localhost:3010/ajax/search/progenies',["pedigree_female_parent" => "test_accession4","pedigree_male_parent" => "test_accession5"] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'data' => [ -['test_accession4','test_accession5','new_test_crossP001', undef], -['test_accession4','test_accession5','new_test_crossP002', undef], -['test_accession4','test_accession5','new_test_crossP003', undef], -['test_accession4','test_accession5','new_test_crossP004', undef], -['test_accession4','test_accession5','new_test_crossP005', undef], -['test_accession4','test_accession5','new_test_crossP006', undef], -['test_accession4','test_accession5','new_test_crossP007', undef], -['test_accession4','test_accession5','new_test_crossP008', undef], -['test_accession4','test_accession5','new_test_crossP009', undef], -['test_accession4','test_accession5','new_test_crossP010', undef], -['test_accession4','test_accession5','test5P001', undef], -['test_accession4','test_accession5','test5P002', undef], -['test_accession4','test_accession5','test5P003', undef], -['test_accession4','test_accession5','test5P004', undef], -['test_accession4','test_accession5','test5P005', undef] -]}, 'progeny search'); - -$mech->post_ok('http://localhost:3010/ajax/search/all_progenies',["female_parent" => "test_accession4"] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'data' => [ -['test_accession4','test_accession5','new_test_crossP001', undef], -['test_accession4','test_accession5','new_test_crossP002', undef], -['test_accession4','test_accession5','new_test_crossP003', undef], -['test_accession4','test_accession5','new_test_crossP004', undef], -['test_accession4','test_accession5','new_test_crossP005', undef], -['test_accession4','test_accession5','new_test_crossP006', undef], -['test_accession4','test_accession5','new_test_crossP007', undef], -['test_accession4','test_accession5','new_test_crossP008', undef], -['test_accession4','test_accession5','new_test_crossP009', undef], -['test_accession4','test_accession5','new_test_crossP010', undef], -['test_accession4','test_accession5','test5P001', undef], -['test_accession4','test_accession5','test5P002', undef], -['test_accession4','test_accession5','test5P003', undef], -['test_accession4','test_accession5','test5P004', undef], -['test_accession4','test_accession5','test5P005', undef] -]}, 'all progeny search'); - - -$mech->post_ok('http://localhost:3010/ajax/search/cross_male_parents',["female_parent" => "TestAccession1"] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'data' => [ -['TestAccession1'], -['TestAccession2'], -['TestAccession3'], -['TestAccession4'], -['TestPopulation1'], -['TestPopulation2'] -]},'male parent search'); - -$mech->post_ok('http://localhost:3010/ajax/search/cross_info',["female_parent" => "TestAccession1","male_parent" => "TestAccession2"] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'data' => [ -['TestAccession1','TestAccession2','TestCross1', 'biparental'] -]}, 'cross info search'); - -$mech->post_ok('http://localhost:3010/ajax/search/all_crosses',["female_parent" => "TestAccession1"] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'data' => [ -['TestAccession1','TestAccession2','TestCross1', 'biparental'], -['TestAccession1','TestAccession3','TestCross2', 'biparental'], -['TestAccession1','TestAccession4','TestCross3', 'biparental'], -['TestAccession1','TestPopulation1','TestCross5', 'open'], -['TestAccession1','TestPopulation2','TestCross6', 'open'], -['TestAccession1','TestAccession1','TestCross4', 'self'] -]}, 'all crosses search'); - -done_testing(); + +use strict; +use warnings; + +use lib 't/lib'; +use SGN::Test::Fixture; +use Test::More; +use Test::WWW::Mechanize; + +use Data::Dumper; +use JSON; +local $Data::Dumper::Indent = 0; + +my $f = SGN::Test::Fixture->new(); +my $schema = $f->bcs_schema; + +my $mech = Test::WWW::Mechanize->new; +my $response; + + +$mech->post_ok('http://localhost:3010/ajax/search/pedigree_male_parents',["pedigree_female_parent" => "test_accession4"] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'data' => [ +['test_accession5'] +]},'male parent search'); + +$mech->post_ok('http://localhost:3010/ajax/search/progenies',["pedigree_female_parent" => "test_accession4","pedigree_male_parent" => "test_accession5"] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'data' => [['test_accession4','test_accession5','new_test_crossP001',''],['test_accession4','test_accession5','new_test_crossP002',''],['test_accession4','test_accession5','new_test_crossP003',''],['test_accession4','test_accession5','new_test_crossP004',''],['test_accession4','test_accession5','new_test_crossP005',''],['test_accession4','test_accession5','new_test_crossP006',''],['test_accession4','test_accession5','new_test_crossP007',''],['test_accession4','test_accession5','new_test_crossP008',''],['test_accession4','test_accession5','new_test_crossP009',''],['test_accession4','test_accession5','new_test_crossP010',''],['test_accession4','test_accession5','test5P001',''],['test_accession4','test_accession5','test5P002',''],['test_accession4','test_accession5','test5P003',''],['test_accession4','test_accession5','test5P004',''],['test_accession4','test_accession5','test5P005','']]}, 'progeny search'); + +$mech->post_ok('http://localhost:3010/ajax/search/all_progenies',["female_parent" => "test_accession4"] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'data' => [['test_accession1','test_accession2','test_accession4','biparental'],['test_accession4','test_accession5','new_test_crossP001',''],['test_accession4','test_accession5','new_test_crossP002',''],['test_accession4','test_accession5','new_test_crossP003',''],['test_accession4','test_accession5','new_test_crossP004',''],['test_accession4','test_accession5','new_test_crossP005',''],['test_accession4','test_accession5','new_test_crossP006',''],['test_accession4','test_accession5','new_test_crossP007',''],['test_accession4','test_accession5','new_test_crossP008',''],['test_accession4','test_accession5','new_test_crossP009',''],['test_accession4','test_accession5','new_test_crossP010',''],['test_accession4','test_accession5','test5P001',''],['test_accession4','test_accession5','test5P002',''],['test_accession4','test_accession5','test5P003',''],['test_accession4','test_accession5','test5P004',''],['test_accession4','test_accession5','test5P005',''],['test_accession3','','test_accession5','open']]}, 'all progeny search'); + + +$mech->post_ok('http://localhost:3010/ajax/search/cross_male_parents',["female_parent" => "TestAccession1"] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'data' => [ +['TestAccession1'], +['TestAccession2'], +['TestAccession3'], +['TestAccession4'], +['TestPopulation1'], +['TestPopulation2'] +]},'male parent search'); + +$mech->post_ok('http://localhost:3010/ajax/search/cross_info',["female_parent" => "TestAccession1","male_parent" => "TestAccession2"] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'data' => [ +['TestAccession1','TestAccession2','TestCross1', 'biparental'] +]}, 'cross info search'); + +$mech->post_ok('http://localhost:3010/ajax/search/all_crosses',["female_parent" => "TestAccession1"] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'data' => [ +['TestAccession1','TestAccession2','TestCross1', 'biparental'], +['TestAccession1','TestAccession3','TestCross2', 'biparental'], +['TestAccession1','TestAccession4','TestCross3', 'biparental'], +['TestAccession1','TestPopulation1','TestCross5', 'open'], +['TestAccession1','TestPopulation2','TestCross6', 'open'], +['TestAccession1','TestAccession1','TestCross4', 'self'] +]}, 'all crosses search'); + +done_testing(); diff --git a/t/unit_fixture/AJAX/Search/Stock.t b/t/unit_fixture/AJAX/Search/Stock.t dissimilarity index 70% index caa6c8bbf..5b338f9c0 100644 --- a/t/unit_fixture/AJAX/Search/Stock.t +++ b/t/unit_fixture/AJAX/Search/Stock.t @@ -1,132 +1,132 @@ -#Tests SGN::Controller::AJAX::Search::Stock - -use strict; -use warnings; - -use lib 't/lib'; -use SGN::Test::Fixture; -use Test::More; -use Test::WWW::Mechanize; -use SGN::Model::Cvterm; -use Data::Dumper; -use JSON; -local $Data::Dumper::Indent = 0; - -my $f = SGN::Test::Fixture->new(); -my $schema = $f->bcs_schema; - -my $mech = Test::WWW::Mechanize->new; -my $response; - -$mech->post_ok('http://localhost:3010/ajax/search/stocks'); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'recordsTotal' => 2461,'recordsFiltered' => 2461,'data' => [['BLANK','accession',undef,'','',undef],['CASS_6Genotypes_103','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_104','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_105','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_106','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_107','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_201','plot',undef,'','',undef],['CASS_6Genotypes_202','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_203','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_204','plot','Manihot esculenta','','',undef]],'draw' => undef}, 'test stock search 1'); - -my $accession_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'accession', 'stock_type')->cvterm_id(); -my $plot_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'plot', 'stock_type')->cvterm_id(); -my $cross_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'cross', 'stock_type')->cvterm_id(); -my $population_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'population', 'stock_type')->cvterm_id(); - -$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "test", "stock_type"=>$accession_type_id] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'draw' => undef,'data' => [['new_test_crossP001','accession','Solanum lycopersicum','','John Doe',undef],['new_test_crossP002','accession','Solanum lycopersicum','','John Doe',undef],['new_test_crossP003','accession','Solanum lycopersicum','','John Doe',undef],['new_test_crossP004','accession','Solanum lycopersicum','','John Doe',undef],['new_test_crossP005','accession','Solanum lycopersicum','','John Doe',undef],['new_test_crossP006','accession','Solanum lycopersicum','','John Doe',undef],['new_test_crossP007','accession','Solanum lycopersicum','','John Doe',undef],['new_test_crossP008','accession','Solanum lycopersicum','','John Doe',undef],['new_test_crossP009','accession','Solanum lycopersicum','','John Doe',undef],['new_test_crossP010','accession','Solanum lycopersicum','','John Doe',undef]],'recordsFiltered' => 25,'recordsTotal' => 25}, 'test stock search 2'); - -$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "test", "stock_type"=>$plot_type_id] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'recordsTotal' => 937,'recordsFiltered' => 937,'data' => [['test_t1','plot','Solanum lycopersicum','','',undef],['test_t10','plot','Manihot esculenta','','',undef],['test_t100','plot','Solanum lycopersicum','','',undef],['test_t101','plot','Solanum lycopersicum','','',undef],['test_t102','plot','Solanum lycopersicum','','',undef],['test_t103','plot','Solanum lycopersicum','','',undef],['test_t104','plot','Solanum lycopersicum','','',undef],['test_t105','plot','Manihot esculenta','','',undef],['test_t106','plot','Solanum lycopersicum','','',undef],['test_t107','plot','Solanum lycopersicum','','',undef]],'draw' => undef}, 'test stock search 3'); - -$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "test", "stock_type"=>$cross_type_id] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'recordsTotal' => 21,'recordsFiltered' => 21,'data' => [['cross_test1','cross','Solanum lycopersicum','','Jane Doe',undef],['cross_test2','cross','Solanum lycopersicum','','Jane Doe',undef],['cross_test3','cross','Solanum lycopersicum','','Jane Doe',undef],['cross_test4','cross','Solanum lycopersicum','','Jane Doe',undef],['cross_test5','cross','Solanum lycopersicum','','Jane Doe',undef],['cross_test6','cross','Solanum lycopersicum','','Jane Doe',undef],['new_test_cross','cross','Solanum lycopersicum','','John Doe',undef],['TestCross1','cross','Manihot esculenta','','Jane Doe',undef],['TestCross10','cross','Manihot esculenta','','Jane Doe',undef],['TestCross11','cross','Manihot esculenta','','Jane Doe',undef]],'draw' => undef}, 'test stock search 4'); - -$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "test", "stock_type"=>$population_type_id] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'recordsTotal' => 5,'recordsFiltered' => 5,'data' => [['TestPopulation1','population','Manihot esculenta','','',undef],['TestPopulation2','population','Manihot esculenta','','',undef],['TestPopulation3','population','Manihot esculenta','','',undef],['TestPopulation4','population','Manihot esculenta','','',undef],['TestPopulation5','population','Manihot esculenta','','',undef]],'draw' => undef}, 'test stock search 5'); - -$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "test", "stock_type"=>$accession_type_id, "person"=>"Jane,Doe"] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'recordsTotal' => 5,'recordsFiltered' => 5,'data' => [['test5P001','accession','Solanum lycopersicum','','Jane Doe',undef],['test5P002','accession','Solanum lycopersicum','','Jane Doe',undef],['test5P003','accession','Solanum lycopersicum','','Jane Doe',undef],['test5P004','accession','Solanum lycopersicum','','Jane Doe',undef],['test5P005','accession','Solanum lycopersicum','','Jane Doe',undef]],'draw' => undef}, 'test stock search 6'); - -$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "ends_with","any_name" => "001", "stock_type"=>$accession_type_id, "person"=>"Jane, Doe", "trait"=>"fresh root weight"] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'recordsTotal' => 2,'draw' => undef,'data' => [['UG120001','accession','Solanum lycopersicum','','Jane Doe',undef],['UG130001','accession','Solanum lycopersicum','','Jane Doe',undef]],'recordsFiltered' => 2}, "test stock search 7"); - -my $test_bp_id = $schema->resultset("Project::Project")->find({name=>'test'})->project_id; - -$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "g", "stock_type"=>$accession_type_id, "person"=>"Jane, Doe", "breeding_program" => $test_bp_id] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'recordsTotal' => 427,'draw' => undef,'recordsFiltered' => 427,'data' => [['UG120001','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120002','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120003','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120004','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120005','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120006','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120007','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120008','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120009','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120010','accession','Solanum lycopersicum','','Jane Doe',undef]]}, "test 8"); - -$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "t", "stock_type"=>$accession_type_id, "project" => "test_trial"] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'recordsTotal' => 5,'draw' => undef,'recordsFiltered' => 5,'data' => [['test_accession1','accession','Solanum lycopersicum','test_accession1_synonym1','',undef],['test_accession2','accession','Solanum lycopersicum','test_accession2_synonym1,test_accession2_synonym2','',undef],['test_accession3','accession','Solanum lycopersicum','test_accession3_synonym1','',undef],['test_accession4','accession','Solanum lycopersicum','','',undef],['test_accession5','accession','Solanum lycopersicum','','',undef]]}, 'test stock search 9'); - -$mech->post_ok('http://localhost:3010/ajax/search/stocks',["stock_type"=>$accession_type_id, "year" => "2014"] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'draw' => undef,'recordsTotal' => 432,'data' => [['test_accession1','accession','Solanum lycopersicum','test_accession1_synonym1','',undef],['test_accession2','accession','Solanum lycopersicum','test_accession2_synonym1,test_accession2_synonym2','',undef],['test_accession3','accession','Solanum lycopersicum','test_accession3_synonym1','',undef],['test_accession4','accession','Solanum lycopersicum','','',undef],['test_accession5','accession','Solanum lycopersicum','','',undef],['UG120001','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120002','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120003','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120004','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120005','accession','Solanum lycopersicum','','Jane Doe',undef]],'recordsFiltered' => 432}, 'test stock search 10'); - -$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "g", "stock_type"=>$accession_type_id, "breeding_program" => $test_bp_id, "location"=>"test_location"] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'data' => [['UG120001','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120002','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120003','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120004','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120005','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120006','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120007','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120008','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120009','accession','Solanum lycopersicum','','Jane Doe',undef],['UG120010','accession','Solanum lycopersicum','','Jane Doe',undef]],'recordsFiltered' => 427,'recordsTotal' => 427,'draw' => undef}, 'test stock search 11'); - -$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "t", "stock_type"=>$plot_type_id, "project" => "test_trial"] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'recordsFiltered' => 15,'data' => [['test_trial21','plot','Solanum lycopersicum','','',undef],['test_trial210','plot','Solanum lycopersicum','','',undef],['test_trial211','plot','Solanum lycopersicum','','',undef],['test_trial212','plot','Solanum lycopersicum','','',undef],['test_trial213','plot','Solanum lycopersicum','','',undef],['test_trial214','plot','Solanum lycopersicum','','',undef],['test_trial215','plot','Solanum lycopersicum','','',undef],['test_trial22','plot','Solanum lycopersicum','','',undef],['test_trial23','plot','Solanum lycopersicum','','',undef],['test_trial24','plot','Solanum lycopersicum','','',undef]],'draw' => undef,'recordsTotal' => 15}, 'test stock search 12'); - -$mech->post_ok('http://localhost:3010/ajax/search/stocks',["stock_type"=>$plot_type_id, "year" => "2014"] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'recordsFiltered' => 1014,'data' => [['KASESE_TP2013_1000','plot','Solanum lycopersicum','','',undef],['KASESE_TP2013_1001','plot','Solanum lycopersicum','','',undef],['KASESE_TP2013_1002','plot','Solanum lycopersicum','','',undef],['KASESE_TP2013_1003','plot','Solanum lycopersicum','','',undef],['KASESE_TP2013_1004','plot','Solanum lycopersicum','','',undef],['KASESE_TP2013_1005','plot','Solanum lycopersicum','','',undef],['KASESE_TP2013_1006','plot','Solanum lycopersicum','','',undef],['KASESE_TP2013_1007','plot','Solanum lycopersicum','','',undef],['KASESE_TP2013_1008','plot','Solanum lycopersicum','','',undef],['KASESE_TP2013_1009','plot','Solanum lycopersicum','','',undef]],'draw' => undef,'recordsTotal' => 1014}, 'test stock search 13'); - -$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "g", "stock_type"=>$plot_type_id, "breeding_program" => $test_bp_id] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'recordsTotal' => 326,'draw' => undef,'recordsFiltered' => 326,'data' => [['CASS_6Genotypes_103','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_104','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_105','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_106','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_107','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_201','plot',undef,'','',undef],['CASS_6Genotypes_202','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_203','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_204','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_205','plot','Manihot esculenta','','',undef]]}, 'test stock search 14'); - -$mech->post_ok('http://localhost:3010/ajax/search/stocks',["stock_type"=>$plot_type_id, "location"=>"test_location"] ); -$response = decode_json $mech->content; -print STDERR Dumper $response; - -is_deeply($response, {'data' => [['CASS_6Genotypes_103','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_104','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_105','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_106','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_107','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_201','plot',undef,'','',undef],['CASS_6Genotypes_202','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_203','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_204','plot','Manihot esculenta','','',undef],['CASS_6Genotypes_205','plot','Manihot esculenta','','',undef]],'recordsFiltered' => 1954,'draw' => undef,'recordsTotal' => 1954}, 'test stock search 15'); - -#add an organization stockprop to an existing stockprop, then search for stocks with that stockprop. login required to add stockprops -$mech->post_ok('http://localhost:3010/brapi/v1/token', [ "username"=> "janedoe", "password"=> "secretpw", "grant_type"=> "password" ]); -$response = decode_json $mech->content; -#print STDERR Dumper $response; -is($response->{'metadata'}->{'status'}->[2]->{'success'}, 'Login Successfull'); -$mech->post_ok('http://localhost:3010/stock/prop/add',["stock_id"=>"38842", "prop"=>"organization_name_1", "prop_type"=>"organization"] ); -$response = decode_json $mech->content; -#print STDERR Dumper $response; -$mech->post_ok('http://localhost:3010/ajax/search/stocks',["organization"=>"organization_name_1"] ); -$response = decode_json $mech->content; -#print STDERR Dumper $response; - -is_deeply($response, {'recordsFiltered' => 1,'recordsTotal' => 1,'draw' => undef,'data' => [['test_accession3','accession','Solanum lycopersicum','test_accession3_synonym1','','organization_name_1']]}, 'test stock search 16'); - -done_testing(); +#Tests SGN::Controller::AJAX::Search::Stock + +use strict; +use warnings; + +use lib 't/lib'; +use SGN::Test::Fixture; +use Test::More; +use Test::WWW::Mechanize; +use SGN::Model::Cvterm; +use Data::Dumper; +use JSON; +local $Data::Dumper::Indent = 0; + +my $f = SGN::Test::Fixture->new(); +my $schema = $f->bcs_schema; + +my $mech = Test::WWW::Mechanize->new; +my $response; + +$mech->post_ok('http://localhost:3010/ajax/search/stocks'); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'recordsFiltered' => 2461,'recordsTotal' => 2461,'draw' => undef,'data' => [['BLANK','accession',undef,'','',''],['CASS_6Genotypes_103','plot','Manihot esculenta','','',''],['CASS_6Genotypes_104','plot','Manihot esculenta','','',''],['CASS_6Genotypes_105','plot','Manihot esculenta','','',''],['CASS_6Genotypes_106','plot','Manihot esculenta','','',''],['CASS_6Genotypes_107','plot','Manihot esculenta','','',''],['CASS_6Genotypes_201','plot',undef,'','',''],['CASS_6Genotypes_202','plot','Manihot esculenta','','',''],['CASS_6Genotypes_203','plot','Manihot esculenta','','',''],['CASS_6Genotypes_204','plot','Manihot esculenta','','','']]}, 'test stock search 1'); + +my $accession_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'accession', 'stock_type')->cvterm_id(); +my $plot_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'plot', 'stock_type')->cvterm_id(); +my $cross_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'cross', 'stock_type')->cvterm_id(); +my $population_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'population', 'stock_type')->cvterm_id(); + +$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "test", "stock_type"=>$accession_type_id] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'recordsFiltered' => 25,'recordsTotal' => 25,'draw' => undef,'data' => [['new_test_crossP001','accession','Solanum lycopersicum','','John Doe',''],['new_test_crossP002','accession','Solanum lycopersicum','','John Doe',''],['new_test_crossP003','accession','Solanum lycopersicum','','John Doe',''],['new_test_crossP004','accession','Solanum lycopersicum','','John Doe',''],['new_test_crossP005','accession','Solanum lycopersicum','','John Doe',''],['new_test_crossP006','accession','Solanum lycopersicum','','John Doe',''],['new_test_crossP007','accession','Solanum lycopersicum','','John Doe',''],['new_test_crossP008','accession','Solanum lycopersicum','','John Doe',''],['new_test_crossP009','accession','Solanum lycopersicum','','John Doe',''],['new_test_crossP010','accession','Solanum lycopersicum','','John Doe','']]}, 'test stock search 2'); + +$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "test", "stock_type"=>$plot_type_id] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'data' => [['test_t1','plot','Solanum lycopersicum','','',''],['test_t10','plot','Manihot esculenta','','',''],['test_t100','plot','Solanum lycopersicum','','',''],['test_t101','plot','Solanum lycopersicum','','',''],['test_t102','plot','Solanum lycopersicum','','',''],['test_t103','plot','Solanum lycopersicum','','',''],['test_t104','plot','Solanum lycopersicum','','',''],['test_t105','plot','Manihot esculenta','','',''],['test_t106','plot','Solanum lycopersicum','','',''],['test_t107','plot','Solanum lycopersicum','','','']],'draw' => undef,'recordsTotal' => 937,'recordsFiltered' => 937}, 'test stock search 3'); + +$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "test", "stock_type"=>$cross_type_id] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'data' => [['cross_test1','cross','Solanum lycopersicum','','Jane Doe',''],['cross_test2','cross','Solanum lycopersicum','','Jane Doe',''],['cross_test3','cross','Solanum lycopersicum','','Jane Doe',''],['cross_test4','cross','Solanum lycopersicum','','Jane Doe',''],['cross_test5','cross','Solanum lycopersicum','','Jane Doe',''],['cross_test6','cross','Solanum lycopersicum','','Jane Doe',''],['new_test_cross','cross','Solanum lycopersicum','','John Doe',''],['TestCross1','cross','Manihot esculenta','','Jane Doe',''],['TestCross10','cross','Manihot esculenta','','Jane Doe',''],['TestCross11','cross','Manihot esculenta','','Jane Doe','']],'draw' => undef,'recordsTotal' => 21,'recordsFiltered' => 21}, 'test stock search 4'); + +$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "test", "stock_type"=>$population_type_id] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'recordsFiltered' => 5,'recordsTotal' => 5,'data' => [['TestPopulation1','population','Manihot esculenta','','',''],['TestPopulation2','population','Manihot esculenta','','',''],['TestPopulation3','population','Manihot esculenta','','',''],['TestPopulation4','population','Manihot esculenta','','',''],['TestPopulation5','population','Manihot esculenta','','','']],'draw' => undef}, 'test stock search 5'); + +$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "test", "stock_type"=>$accession_type_id, "person"=>"Jane,Doe"] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'recordsFiltered' => 5,'recordsTotal' => 5,'draw' => undef,'data' => [['test5P001','accession','Solanum lycopersicum','','Jane Doe',''],['test5P002','accession','Solanum lycopersicum','','Jane Doe',''],['test5P003','accession','Solanum lycopersicum','','Jane Doe',''],['test5P004','accession','Solanum lycopersicum','','Jane Doe',''],['test5P005','accession','Solanum lycopersicum','','Jane Doe','']]}, 'test stock search 6'); + +$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "ends_with","any_name" => "001", "stock_type"=>$accession_type_id, "person"=>"Jane, Doe", "trait"=>"fresh root weight"] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'data' => [['UG120001','accession','Solanum lycopersicum','','Jane Doe',''],['UG130001','accession','Solanum lycopersicum','','Jane Doe','']],'draw' => undef,'recordsFiltered' => 2,'recordsTotal' => 2}, "test stock search 7"); + +my $test_bp_id = $schema->resultset("Project::Project")->find({name=>'test'})->project_id; + +$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "g", "stock_type"=>$accession_type_id, "person"=>"Jane, Doe", "breeding_program" => $test_bp_id] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'data' => [['UG120001','accession','Solanum lycopersicum','','Jane Doe',''],['UG120002','accession','Solanum lycopersicum','','Jane Doe',''],['UG120003','accession','Solanum lycopersicum','','Jane Doe',''],['UG120004','accession','Solanum lycopersicum','','Jane Doe',''],['UG120005','accession','Solanum lycopersicum','','Jane Doe',''],['UG120006','accession','Solanum lycopersicum','','Jane Doe',''],['UG120007','accession','Solanum lycopersicum','','Jane Doe',''],['UG120008','accession','Solanum lycopersicum','','Jane Doe',''],['UG120009','accession','Solanum lycopersicum','','Jane Doe',''],['UG120010','accession','Solanum lycopersicum','','Jane Doe','']],'draw' => undef,'recordsTotal' => 427,'recordsFiltered' => 427}, "test 8"); + +$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "t", "stock_type"=>$accession_type_id, "project" => "test_trial"] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'draw' => undef,'data' => [['test_accession1','accession','Solanum lycopersicum','test_accession1_synonym1','',''],['test_accession2','accession','Solanum lycopersicum','test_accession2_synonym1,test_accession2_synonym2','',''],['test_accession3','accession','Solanum lycopersicum','test_accession3_synonym1','',''],['test_accession4','accession','Solanum lycopersicum','','',''],['test_accession5','accession','Solanum lycopersicum','','','']],'recordsTotal' => 5,'recordsFiltered' => 5}, 'test stock search 9'); + +$mech->post_ok('http://localhost:3010/ajax/search/stocks',["stock_type"=>$accession_type_id, "year" => "2014"] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'data' => [['test_accession1','accession','Solanum lycopersicum','test_accession1_synonym1','',''],['test_accession2','accession','Solanum lycopersicum','test_accession2_synonym1,test_accession2_synonym2','',''],['test_accession3','accession','Solanum lycopersicum','test_accession3_synonym1','',''],['test_accession4','accession','Solanum lycopersicum','','',''],['test_accession5','accession','Solanum lycopersicum','','',''],['UG120001','accession','Solanum lycopersicum','','Jane Doe',''],['UG120002','accession','Solanum lycopersicum','','Jane Doe',''],['UG120003','accession','Solanum lycopersicum','','Jane Doe',''],['UG120004','accession','Solanum lycopersicum','','Jane Doe',''],['UG120005','accession','Solanum lycopersicum','','Jane Doe','']],'draw' => undef,'recordsFiltered' => 432,'recordsTotal' => 432}, 'test stock search 10'); + +$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "g", "stock_type"=>$accession_type_id, "breeding_program" => $test_bp_id, "location"=>"test_location"] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'recordsFiltered' => 427,'recordsTotal' => 427,'data' => [['UG120001','accession','Solanum lycopersicum','','Jane Doe',''],['UG120002','accession','Solanum lycopersicum','','Jane Doe',''],['UG120003','accession','Solanum lycopersicum','','Jane Doe',''],['UG120004','accession','Solanum lycopersicum','','Jane Doe',''],['UG120005','accession','Solanum lycopersicum','','Jane Doe',''],['UG120006','accession','Solanum lycopersicum','','Jane Doe',''],['UG120007','accession','Solanum lycopersicum','','Jane Doe',''],['UG120008','accession','Solanum lycopersicum','','Jane Doe',''],['UG120009','accession','Solanum lycopersicum','','Jane Doe',''],['UG120010','accession','Solanum lycopersicum','','Jane Doe','']],'draw' => undef}, 'test stock search 11'); + +$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "t", "stock_type"=>$plot_type_id, "project" => "test_trial"] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'recordsFiltered' => 15,'recordsTotal' => 15,'data' => [['test_trial21','plot','Solanum lycopersicum','','',''],['test_trial210','plot','Solanum lycopersicum','','',''],['test_trial211','plot','Solanum lycopersicum','','',''],['test_trial212','plot','Solanum lycopersicum','','',''],['test_trial213','plot','Solanum lycopersicum','','',''],['test_trial214','plot','Solanum lycopersicum','','',''],['test_trial215','plot','Solanum lycopersicum','','',''],['test_trial22','plot','Solanum lycopersicum','','',''],['test_trial23','plot','Solanum lycopersicum','','',''],['test_trial24','plot','Solanum lycopersicum','','','']],'draw' => undef}, 'test stock search 12'); + +$mech->post_ok('http://localhost:3010/ajax/search/stocks',["stock_type"=>$plot_type_id, "year" => "2014"] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'recordsFiltered' => 1014,'recordsTotal' => 1014,'draw' => undef,'data' => [['KASESE_TP2013_1000','plot','Solanum lycopersicum','','',''],['KASESE_TP2013_1001','plot','Solanum lycopersicum','','',''],['KASESE_TP2013_1002','plot','Solanum lycopersicum','','',''],['KASESE_TP2013_1003','plot','Solanum lycopersicum','','',''],['KASESE_TP2013_1004','plot','Solanum lycopersicum','','',''],['KASESE_TP2013_1005','plot','Solanum lycopersicum','','',''],['KASESE_TP2013_1006','plot','Solanum lycopersicum','','',''],['KASESE_TP2013_1007','plot','Solanum lycopersicum','','',''],['KASESE_TP2013_1008','plot','Solanum lycopersicum','','',''],['KASESE_TP2013_1009','plot','Solanum lycopersicum','','','']]}, 'test stock search 13'); + +$mech->post_ok('http://localhost:3010/ajax/search/stocks',["any_name_matchtype" => "contains","any_name" => "g", "stock_type"=>$plot_type_id, "breeding_program" => $test_bp_id] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'recordsTotal' => 326,'recordsFiltered' => 326,'draw' => undef,'data' => [['CASS_6Genotypes_103','plot','Manihot esculenta','','',''],['CASS_6Genotypes_104','plot','Manihot esculenta','','',''],['CASS_6Genotypes_105','plot','Manihot esculenta','','',''],['CASS_6Genotypes_106','plot','Manihot esculenta','','',''],['CASS_6Genotypes_107','plot','Manihot esculenta','','',''],['CASS_6Genotypes_201','plot',undef,'','',''],['CASS_6Genotypes_202','plot','Manihot esculenta','','',''],['CASS_6Genotypes_203','plot','Manihot esculenta','','',''],['CASS_6Genotypes_204','plot','Manihot esculenta','','',''],['CASS_6Genotypes_205','plot','Manihot esculenta','','','']]}, 'test stock search 14'); + +$mech->post_ok('http://localhost:3010/ajax/search/stocks',["stock_type"=>$plot_type_id, "location"=>"test_location"] ); +$response = decode_json $mech->content; +print STDERR Dumper $response; + +is_deeply($response, {'data' => [['CASS_6Genotypes_103','plot','Manihot esculenta','','',''],['CASS_6Genotypes_104','plot','Manihot esculenta','','',''],['CASS_6Genotypes_105','plot','Manihot esculenta','','',''],['CASS_6Genotypes_106','plot','Manihot esculenta','','',''],['CASS_6Genotypes_107','plot','Manihot esculenta','','',''],['CASS_6Genotypes_201','plot',undef,'','',''],['CASS_6Genotypes_202','plot','Manihot esculenta','','',''],['CASS_6Genotypes_203','plot','Manihot esculenta','','',''],['CASS_6Genotypes_204','plot','Manihot esculenta','','',''],['CASS_6Genotypes_205','plot','Manihot esculenta','','','']],'draw' => undef,'recordsFiltered' => 1954,'recordsTotal' => 1954}, 'test stock search 15'); + +#add an organization stockprop to an existing stockprop, then search for stocks with that stockprop. login required to add stockprops +$mech->post_ok('http://localhost:3010/brapi/v1/token', [ "username"=> "janedoe", "password"=> "secretpw", "grant_type"=> "password" ]); +$response = decode_json $mech->content; +#print STDERR Dumper $response; +is($response->{'metadata'}->{'status'}->[2]->{'success'}, 'Login Successfull'); +$mech->post_ok('http://localhost:3010/stock/prop/add',["stock_id"=>"38842", "prop"=>"organization_name_1", "prop_type"=>"organization"] ); +$response = decode_json $mech->content; +#print STDERR Dumper $response; +$mech->post_ok('http://localhost:3010/ajax/search/stocks',["organization"=>"organization_name_1"] ); +$response = decode_json $mech->content; +#print STDERR Dumper $response; + +is_deeply($response, {'recordsFiltered' => 1,'recordsTotal' => 1,'draw' => undef,'data' => [['test_accession3','accession','Solanum lycopersicum','test_accession3_synonym1','','organization_name_1']]}, 'test stock search 16'); + +done_testing(); -- 2.11.4.GIT