Skip to content

Commit

Permalink
added tests for create/retrieve well accepted override and well recom…
Browse files Browse the repository at this point in the history
…bineering results.

fixed bug in retrieve_well_recombineering_results method.
  • Loading branch information
af11-sanger committed Sep 11, 2012
1 parent cc22d21 commit 2d7ec15
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/LIMS2/Model/Plugin/Well.pm
Expand Up @@ -208,13 +208,13 @@ sub retrieve_well_recombineering_results {
# retrieve_well() will validate the parameters
my $well = $self->retrieve_well( $params );

my $rec_results = $well->well_recombineering_results;
my @rec_results = $well->well_recombineering_results;

if ( @{ $rec_results } == 0) {
if ( @rec_results == 0) {
$self->throw( NotFound => { entity_class => 'WellRecombineeringResult', search_params => $params } );
}

return $rec_results;
return \@rec_results;
}

sub pspec_create_well_dna_status {
Expand Down
27 changes: 27 additions & 0 deletions t/50-model-plugin-well.t
Expand Up @@ -14,6 +14,7 @@ use Try::Tiny;
use DateTime;

my $well_data= test_data( 'well.yaml' );

note( "Testing well creation" );

{
Expand Down Expand Up @@ -44,6 +45,13 @@ note( "Testing well creation" );
is $override->accepted, 0, 'override has correct value';
is $override->well->id, $well->id, 'override belongs to correct well';

note( "Testing retrieve well accepted override" );
ok my $well2 = model->retrieve_well($well_data->{well_accepted_override_create}),
'retrieve created well should succeed';
ok my $override2 = model->retrieve_well_accepted_override( {well_id => $well2->id} ),
'retrieve_well_accepted_override should succeed';
is $override2->well->id, $well2->id, 'retrieved override belongs to correct well';

note( "Testing update well accepted override" );
ok my $updated_override = model->update_well_accepted_override( $well_data->{well_accepted_override_update} ),
'update_well_accepted_override should succeed';
Expand Down Expand Up @@ -123,6 +131,25 @@ note( "Testing well creation" );
is $well->id, $new_dna_status->well_id , '.. and dna_status is for right well';
}

{
note("Testing well recombineering result create and retrieve");

ok my $recomb = model->create_well_recombineering_result( $well_data->{well_recombineering_create} ),
'create_well_recombineering_result should succeed';
isa_ok $recomb, 'LIMS2::Model::Schema::Result::WellRecombineeringResult';
is $recomb->result_type_id, 'pcr_u', 'recombineering result type correct';
is $recomb->result, 'pass', 'recombineering result correct';

ok my $rec_results = model->retrieve_well_recombineering_results( $well_data->{well_recombineering_create} ),
'can retrieve recombineering results by name';
isa_ok($rec_results, 'ARRAY');
isa_ok($rec_results->[0], 'LIMS2::Model::Schema::Result::WellRecombineeringResult');

throws_ok{
model->create_well_recombineering_result( $well_data->{well_recombineering_create_bad} )
} qr//;
}

{
note( "Testing delete_well" );

Expand Down
12 changes: 12 additions & 0 deletions t/data/well.yaml
Expand Up @@ -28,3 +28,15 @@ well_accepted_override_update_same:
well_name: B01
created_by: test_user@example.org
accepted: 1
well_recombineering_create:
plate_name: PCS00177_A
well_name: B01
created_by: test_user@example.org
result_type: pcr_u
result: pass
well_recombineering_create_bad:
plate_name: PCS00177_A
well_name: B01
created_by: test_user@example.org
result_type: foo
result: pass

0 comments on commit 2d7ec15

Please sign in to comment.