Skip to content

Commit

Permalink
Merge pull request #3743 from solgenomics/topic/more_test_fixes
Browse files Browse the repository at this point in the history
Fix more tests
  • Loading branch information
isaak authored Sep 27, 2021
2 parents fcd4678 + 58df152 commit 0a335ab
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 98 deletions.
4 changes: 4 additions & 0 deletions sgn_test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ brapi_POST any
brapi_PUT any
brapi_OPTIONS any

# for drone stuff
python_executable /usr/bin/python3.5
python_executable_maskrcnn_env /usr/bin/python3.5

# slurm config
backend Slurm

Expand Down
18 changes: 7 additions & 11 deletions t/unit_fixture/CXGN/Stock/MergeStock.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,39 @@ use CXGN::Stock;

my $f = SGN::Test::Fixture->new();
my $schema = $f->bcs_schema();
my $dbh = $f->dbh();

$dbh->begin_work();
$schema->txn_begin();

eval {
my $this_stock_id = 39041;
my $other_stock_id = 38844;

my $stock = CXGN::Stock->new( { schema => $schema, stock_id => $this_stock_id } );

my $initial_counts = get_counts($this_stock_id);

# try self merge, should fail:
my $error = $stock->merge($this_stock_id);
is($error, "Error: cannot merge stock into itself", "merge stock into itself test");

my $initial_counts_other = get_counts($other_stock_id);

$error = $stock->merge(38844);
is($error, 1, "merge stock should give no error");

# all data should be transferred, so these need to add up
my $combined_counts = get_counts($this_stock_id);

$initial_counts_other->{prop_count}++; # take added synonym into account

foreach my $k (keys %$combined_counts) {
print STDERR "Checking key $k...\n";
is($combined_counts->{$k}, ($initial_counts->{$k} + $initial_counts_other->{$k}), "$k test");
}



}
};

print STDERR "ERROR = $@\n";
$dbh->rollback();
$schema->txn_rollback();

done_testing();

Expand Down
8 changes: 4 additions & 4 deletions t/unit_fixture/CXGN/Uploading/Storebrapiobservations.t
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ is_deeply($response, {
'metadata' => {
'status' => [
{
'messageType' => '400',
'messageType' => 'ERROR',
'message' => 'You must login and have permission to access this BrAPI call.'
}
],
Expand Down Expand Up @@ -129,7 +129,7 @@ is_deeply($response, {
'observationTimeStamp' => '2015-06-16T00:53:26Z',
'germplasmName' => 'test_accession3',
'observationUnitName' => 'test_trial210',
'uploadedBy' => 41,
'uploadedBy' => 'collector1',
'collector' => 'collector1',
'germplasmDbId' => 38842,
'observationUnitDbId' => 38866,
Expand All @@ -143,7 +143,7 @@ is_deeply($response, {
'observationTimeStamp' => '2015-06-16T00:53:26Z',
'germplasmName' => 'test_accession4',
'observationUnitName' => 'test_trial214',
'uploadedBy' => 41,
'uploadedBy' => 'collector1',
'collector' => 'collector1',
'germplasmDbId' => 38843,
'observationUnitDbId' => 38870,
Expand Down Expand Up @@ -179,7 +179,7 @@ is_deeply($response, {
},
{
'messageType' => 'INFO',
'message' => 'All values in your file are now saved in the database!'
'message' => 'All values in your file have been successfully processed!<br><br>2 new values stored<br>0 previously stored values skipped<br>0 previously stored values overwritten<br><br>'
}
],
'pagination' => {
Expand Down
173 changes: 91 additions & 82 deletions t/unit_fixture/CXGN/Uploading/ValidateAllDroneImageryFunctions.t
Original file line number Diff line number Diff line change
Expand Up @@ -531,95 +531,104 @@ print STDERR Dumper $message_hash_remove_image;
ok($message_hash_remove_image->{status});

#Testing upload of bulk imaging events
my $bulk_loading_csv = $f->config->{basepath}."/t/data/imagebreed/bulk_loading/BTI_rig_images.xls";
my $bulk_loading_image_zip = $f->config->{basepath}."/t/data/imagebreed/bulk_loading/BTI_rig_images.zip";
$ua = LWP::UserAgent->new;
$ua->timeout(3600);
my $response_raster = $ua->post(
'http://localhost:3010/drone_imagery/upload_drone_imagery_bulk',
Content_Type => 'form-data',
Content => [
"sgn_session_id"=>$sgn_session_id,
upload_drone_imagery_bulk_images_zipfile => [ $bulk_loading_image_zip, basename($bulk_loading_image_zip) ],
upload_drone_imagery_bulk_imaging_events => [ $bulk_loading_csv, basename($bulk_loading_csv) ],
]
);

ok($response_raster->is_success);
my $message_raster = $response_raster->decoded_content;
print STDERR Dumper $message_raster;
ok($message_raster =~ /Successfully uploaded!/);

my $file_previous_geotiff_image_zip = "/home/production/public/static_content/imagebreed/RiceExampleRGBandDSMOrthophotosGeoTIFFs.zip";
my $file_previous_geojson_zip = "/home/production/public/static_content/imagebreed/RiceExampleGeoJSONs.zip";
my $file_previous_imaging_events = "/home/production/public/static_content/imagebreed/RiceExampleRGBandDSMGeoJSONImagingEvent.xls";

$ua = LWP::UserAgent->new;
$ua->timeout(3600);
my $response_raster = $ua->post(
'http://localhost:3010/drone_imagery/upload_drone_imagery_bulk_previous',
Content_Type => 'form-data',
Content => [
"sgn_session_id"=>$sgn_session_id,
upload_drone_imagery_bulk_images_zipfile_previous => [ $file_previous_geotiff_image_zip, basename($file_previous_geotiff_image_zip) ],
upload_drone_imagery_bulk_geojson_zipfile_previous => [ $file_previous_geojson_zip, basename($file_previous_geojson_zip) ],
upload_drone_imagery_bulk_imaging_events_previous => [ $file_previous_imaging_events, basename($file_previous_imaging_events) ],
]
);
my $bulk_loading_csv = $f->config->{basepath}."/t/data/imagebreed/bulk_loading/BTI_rig_images.xls";
my $bulk_loading_image_zip = $f->config->{basepath}."/t/data/imagebreed/bulk_loading/BTI_rig_images.zip";

ok($response_raster->is_success);
my $message_raster = $response_raster->decoded_content;
print STDERR Dumper $message_raster;
ok($message_raster =~ /Successfully uploaded!/);

my $rasterblue = $f->config->{basepath}."/t/data/imagebreed/RasterBlue.png";
my $rastergreen = $f->config->{basepath}."/t/data/imagebreed/RasterGreen.png";
my $rasterred= $f->config->{basepath}."/t/data/imagebreed/RasterRed.png";
my $rasternir = $f->config->{basepath}."/t/data/imagebreed/RasterNIR.png";
my $rasterrededge = $f->config->{basepath}."/t/data/imagebreed/RasterRedEdge.png";
$ua = LWP::UserAgent->new;
$ua->timeout(3600);
my $response_raster = $ua->post(
'http://localhost:3010/drone_imagery/upload_drone_imagery',
Content_Type => 'form-data',
Content => [
"sgn_session_id"=>$sgn_session_id,
"drone_run_field_trial_id"=>$field_trial_id,
"drone_run_name"=>"NewStitchedMicasense5BandDroneRunProjectTESTING",
"drone_run_type"=>"Aerial Medium to High Res",
"drone_run_date"=>"2019/02/01 13:14:15",
"drone_run_description"=>"test new drone run",
"drone_image_upload_camera_info"=>"micasense_5",
"drone_run_imaging_vehicle_id"=>$new_vehicle_id,
"drone_run_imaging_vehicle_battery_name"=>"blue",
"drone_image_upload_drone_run_band_stitching"=>"no",
"drone_run_band_number"=>5,
"drone_run_band_name_1"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_Blue",
"drone_run_band_description_1"=>"raster blue",
"drone_run_band_type_1"=>"Blue (450-520nm)",
drone_run_band_stitched_ortho_image_1 => [ $rasterblue, basename($rasterblue) ],
"drone_run_band_name_2"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_Green",
"drone_run_band_description_2"=>"raster green",
"drone_run_band_type_2"=>"Green (515-600nm)",
drone_run_band_stitched_ortho_image_2 => [ $rastergreen, basename($rastergreen) ],
"drone_run_band_name_3"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_Red",
"drone_run_band_description_3"=>"raster red",
"drone_run_band_type_3"=>"Red (600-690nm)",
drone_run_band_stitched_ortho_image_3 => [ $rasterred, basename($rasterred) ],
"drone_run_band_name_4"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_NIR",
"drone_run_band_description_4"=>"raster NIR",
"drone_run_band_type_4"=>"NIR (780-3000nm)",
drone_run_band_stitched_ortho_image_4 => [ $rasternir, basename($rasternir) ],
"drone_run_band_name_5"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_RedEdge",
"drone_run_band_description_5"=>"raster rededge",
"drone_run_band_type_5"=>"Red Edge (690-750nm)",
drone_run_band_stitched_ortho_image_5 => [ $rasterrededge, basename($rasterrededge) ],
]
);
SKIP: {
skip 'Some required files not available for these tests', 6, unless ( (-e $file_previous_geotiff_image_zip) && (-e $file_previous_geojson_zip) && (-e $file_previous_imaging_events) && (-e $bulk_loading_csv) && (-e $bulk_loading_image_zip));

ok($response_raster->is_success);
my $message_raster = $response_raster->decoded_content;
print STDERR Dumper $message_raster;
ok($message_raster =~ /Successfully uploaded!/);

$ua = LWP::UserAgent->new;
$ua->timeout(3600);
my $response_raster = $ua->post(
'http://localhost:3010/drone_imagery/upload_drone_imagery_bulk',
Content_Type => 'form-data',
Content => [
"sgn_session_id"=>$sgn_session_id,
upload_drone_imagery_bulk_images_zipfile => [ $bulk_loading_image_zip, basename($bulk_loading_image_zip) ],
upload_drone_imagery_bulk_imaging_events => [ $bulk_loading_csv, basename($bulk_loading_csv) ],
]
);

ok($response_raster->is_success);
my $message_raster = $response_raster->decoded_content;
print STDERR Dumper $message_raster;
ok($message_raster =~ /Successfully uploaded!/);


$ua = LWP::UserAgent->new;
$ua->timeout(3600);
my $response_raster = $ua->post(
'http://localhost:3010/drone_imagery/upload_drone_imagery_bulk_previous',
Content_Type => 'form-data',
Content => [
"sgn_session_id"=>$sgn_session_id,
upload_drone_imagery_bulk_images_zipfile_previous => [ $file_previous_geotiff_image_zip, basename($file_previous_geotiff_image_zip) ],
upload_drone_imagery_bulk_geojson_zipfile_previous => [ $file_previous_geojson_zip, basename($file_previous_geojson_zip) ],
upload_drone_imagery_bulk_imaging_events_previous => [ $file_previous_imaging_events, basename($file_previous_imaging_events) ],
]
);

ok($response_raster->is_success);
my $message_raster = $response_raster->decoded_content;
print STDERR Dumper $message_raster;
ok($message_raster =~ /Successfully uploaded!/);

my $rasterblue = $f->config->{basepath}."/t/data/imagebreed/RasterBlue.png";
my $rastergreen = $f->config->{basepath}."/t/data/imagebreed/RasterGreen.png";
my $rasterred= $f->config->{basepath}."/t/data/imagebreed/RasterRed.png";
my $rasternir = $f->config->{basepath}."/t/data/imagebreed/RasterNIR.png";
my $rasterrededge = $f->config->{basepath}."/t/data/imagebreed/RasterRedEdge.png";
$ua = LWP::UserAgent->new;
$ua->timeout(3600);
my $response_raster = $ua->post(
'http://localhost:3010/drone_imagery/upload_drone_imagery',
Content_Type => 'form-data',
Content => [
"sgn_session_id"=>$sgn_session_id,
"drone_run_field_trial_id"=>$field_trial_id,
"drone_run_name"=>"NewStitchedMicasense5BandDroneRunProjectTESTING",
"drone_run_type"=>"Aerial Medium to High Res",
"drone_run_date"=>"2019/02/01 13:14:15",
"drone_run_description"=>"test new drone run",
"drone_image_upload_camera_info"=>"micasense_5",
"drone_run_imaging_vehicle_id"=>$new_vehicle_id,
"drone_run_imaging_vehicle_battery_name"=>"blue",
"drone_image_upload_drone_run_band_stitching"=>"no",
"drone_run_band_number"=>5,
"drone_run_band_name_1"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_Blue",
"drone_run_band_description_1"=>"raster blue",
"drone_run_band_type_1"=>"Blue (450-520nm)",
drone_run_band_stitched_ortho_image_1 => [ $rasterblue, basename($rasterblue) ],
"drone_run_band_name_2"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_Green",
"drone_run_band_description_2"=>"raster green",
"drone_run_band_type_2"=>"Green (515-600nm)",
drone_run_band_stitched_ortho_image_2 => [ $rastergreen, basename($rastergreen) ],
"drone_run_band_name_3"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_Red",
"drone_run_band_description_3"=>"raster red",
"drone_run_band_type_3"=>"Red (600-690nm)",
drone_run_band_stitched_ortho_image_3 => [ $rasterred, basename($rasterred) ],
"drone_run_band_name_4"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_NIR",
"drone_run_band_description_4"=>"raster NIR",
"drone_run_band_type_4"=>"NIR (780-3000nm)",
drone_run_band_stitched_ortho_image_4 => [ $rasternir, basename($rasternir) ],
"drone_run_band_name_5"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_RedEdge",
"drone_run_band_description_5"=>"raster rededge",
"drone_run_band_type_5"=>"Red Edge (690-750nm)",
drone_run_band_stitched_ortho_image_5 => [ $rasterrededge, basename($rasterrededge) ],
]
);

ok($response_raster->is_success);
my $message_raster = $response_raster->decoded_content;
print STDERR Dumper $message_raster;
ok($message_raster =~ /Successfully uploaded!/);
};

done_testing();
2 changes: 1 addition & 1 deletion t/unit_fixture/CXGN/Uploading/ValidateNIRS.t
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ my $message_hash = decode_json $message;
print STDERR Dumper $message_hash;
ok($message_hash->{figure});
is(scalar(@{$message_hash->{success}}), 8);
is($message_hash->{success}->[6], 'All values in your file are now saved in the database!');
like($message_hash->{success}->[6], qr/All values in your file have been successfully processed!/, "return message test");
my $nirs_protocol_id = $message_hash->{nd_protocol_id};

my $ds = CXGN::Dataset->new( people_schema => $f->people_schema(), schema => $f->bcs_schema());
Expand Down
3 changes: 3 additions & 0 deletions t/unit_fixture/CXGN/VerifyDeletion/TrialDeletion.t
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ print STDERR Dumper $response;
is_deeply($response, {'success' => 1});

$mech->get_ok('http://localhost:3010/ajax/breeders/trial/'.$project_id.'/delete/layout');

sleep(30); # deletion script takes time... (?)

$response = decode_json $mech->content;
print STDERR Dumper $response;
is_deeply($response, {'message' => 'Successfully deleted trial data.','success' => 1}, 'test trial layout + entry deletion');
Expand Down

0 comments on commit 0a335ab

Please sign in to comment.