diff --git a/Changes b/Changes index 42591341..2f09d4b2 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,14 @@ LIST OF CHANGES +release 91.12.0 + - Change instrument and instrument format pages to only show current + instruments and instrument formats + - Remove superfluous columns in display tables for lists of instruments + and instrument formats + - Remove unused views (templates) for an instrument manufacturer + - Remove manufacturer model and view classes, create manufacturer_name + method in the instrument and instrument_format model classes + release 91.11.0 - a partial reimplementation of the serialization framework for components and compositions in order to speed-up frequently used methods diff --git a/MANIFEST b/MANIFEST index 209d5028..1fe6d9ff 100644 --- a/MANIFEST +++ b/MANIFEST @@ -64,10 +64,6 @@ data/templates/instrument_status_menu.tt2 data/templates/instrument_status_read_xml.tt2 data/templates/instrument_top.tt2 data/templates/instrument_update_statuses.tt2 -data/templates/manufacturer_add.tt2 -data/templates/manufacturer_create.tt2 -data/templates/manufacturer_list.tt2 -data/templates/manufacturer_read.tt2 data/templates/run_add.tt2 data/templates/run_annotation_add_ajax.tt2 data/templates/run_annotation_add_input_form.tt2 @@ -182,7 +178,6 @@ lib/npg/model/instrument_mod_dict.pm lib/npg/model/instrument_status.pm lib/npg/model/instrument_status_annotation.pm lib/npg/model/instrument_status_dict.pm -lib/npg/model/manufacturer.pm lib/npg/model/run.pm lib/npg/model/run_annotation.pm lib/npg/model/run_lane.pm @@ -215,7 +210,6 @@ lib/npg/view/instrument_format.pm lib/npg/view/instrument_mod.pm lib/npg/view/instrument_status.pm lib/npg/view/instrument_status_annotation.pm -lib/npg/view/manufacturer.pm lib/npg/view/run.pm lib/npg/view/run_annotation.pm lib/npg/view/run_lane.pm @@ -360,7 +354,6 @@ t/10-model-instrument_mod_dict.t t/10-model-instrument_status.t t/10-model-instrument_status_annotation.t t/10-model-instrument_status_dict.t -t/10-model-manufacturer.t t/10-model-run.t t/10-model-run_annotation.t t/10-model-run_lane.t diff --git a/data/templates/instrument_format_list.tt2 b/data/templates/instrument_format_list.tt2 index 8315d60c..81793dca 100644 --- a/data/templates/instrument_format_list.tt2 +++ b/data/templates/instrument_format_list.tt2 @@ -1,27 +1,23 @@ - - [% PROCESS instrument_formats_menu.tt2 %] - - - + [% FOREACH instrument_format = model.instrument_formats %] - - - - - - + [% IF instrument_format.iscurrent %] + + + + + + [% END %] [% END %]
Instrument Manufacturer Instrument ModelIs CurrentInstrument CountCurrent Instrument Count
[% instrument_format.manufacturer.name %][% instrument_format.model %][% IF instrument_format.iscurrent %]tick.png[% ELSE %]cross.png[% END %][% instrument_format.instrument_count %]
[% instrument_format.manufacturer_name %][% instrument_format.model %][% instrument_format.current_instruments_count %]
- diff --git a/data/templates/instrument_format_read.tt2 b/data/templates/instrument_format_read.tt2 index ed707b5e..c1549130 100644 --- a/data/templates/instrument_format_read.tt2 +++ b/data/templates/instrument_format_read.tt2 @@ -1,23 +1,17 @@ - - + - - - [% FOREACH instrument = model.instruments %] + [% FOREACH instrument = model.instruments; IF instrument.iscurrent %] - - - [% END %] + [% END; END %]
Instruments for format [% model.manufacturer.name %] [% model.model %]Instruments for format [% model.manufacturer_name %] [% model.model %]
Name Model External NameSerial #Is Current
[% instrument.name %] [% instrument.model %] [% instrument.external_name %][% instrument.serial %][% IF instrument.iscurrent %]tick.png[% ELSE %]cross.png[% END %]
- diff --git a/data/templates/instrument_list_textual.tt2 b/data/templates/instrument_list_textual.tt2 index 34748c10..52a2f0d9 100644 --- a/data/templates/instrument_list_textual.tt2 +++ b/data/templates/instrument_list_textual.tt2 @@ -9,8 +9,6 @@ Model External Name Designation - Serial # - Is Current Current Run Current Status Status Comment @@ -23,8 +21,6 @@ [% instrument.model %] [% instrument.external_name %] [% IF instrument.designations %][% FOREACH designation = instrument.designations %][% designation.description | html %] [% END %][% ELSE %] [% END %] - [% instrument.serial %] - [% IF instrument.iscurrent %]tick.png[% ELSE %]cross.png[% END %] [% PROCESS current_runs_info %] [% instrument.current_instrument_status.instrument_status_dict.description %] [% instrument.current_instrument_status.comment %] @@ -65,4 +61,4 @@ [%- BLOCK run_info -%] [%- status = current_run.current_run_status.description -%] [%- IF status %][% current_run.name %] [% status %][% ELSE; idle; END -%] -[%- END -%] \ No newline at end of file +[%- END -%] diff --git a/data/templates/instrument_read.tt2 b/data/templates/instrument_read.tt2 index f1c2259b..ecd5e2b2 100644 --- a/data/templates/instrument_read.tt2 +++ b/data/templates/instrument_read.tt2 @@ -9,7 +9,7 @@
[% title %]
- + [% IF model.serial %][% END %] [% IF model.designations %][% END %] diff --git a/data/templates/instrument_top.tt2 b/data/templates/instrument_top.tt2 index 4fda2336..d07fcf48 100644 --- a/data/templates/instrument_top.tt2 +++ b/data/templates/instrument_top.tt2 @@ -1,4 +1,4 @@ -[% labels = ['current status', 'formats'] -%] +[% labels = ['current status', 'current formats'] -%] [% addresses = ['instrument/graphical', 'instrument_format'] -%] [% counts = [0, 2] -%]

diff --git a/data/templates/manufacturer_add.tt2 b/data/templates/manufacturer_add.tt2 deleted file mode 100644 index c856f917..00000000 --- a/data/templates/manufacturer_add.tt2 +++ /dev/null @@ -1,8 +0,0 @@ - -Add a manufacturer - -
- - - - diff --git a/data/templates/manufacturer_create.tt2 b/data/templates/manufacturer_create.tt2 deleted file mode 100644 index 1714d4c4..00000000 --- a/data/templates/manufacturer_create.tt2 +++ /dev/null @@ -1,9 +0,0 @@ - -Saved manufacturer. - -Please click here to continue. - - - diff --git a/data/templates/manufacturer_list.tt2 b/data/templates/manufacturer_list.tt2 deleted file mode 100644 index ed5637fd..00000000 --- a/data/templates/manufacturer_list.tt2 +++ /dev/null @@ -1,19 +0,0 @@ - -

Model[% model.instrument_format.model %] 
Manufacturer[% mname = model.manufacturer.name; mname = mname ? mname : ' '; mname; %]
Manufacturer[% mname = model.manufacturer_name; mname = mname ? mname : ' '; mname; %]
Serial Number[% model.serial %] 
Designations[% FOREACH designation = model.designations %][% designation.description | html %] [% END %]
- - - - - - - -[% FOREACH manufacturer = model.manufacturers %] - - - -[% END %] - -
Manufacturers
Name
[% manufacturer.name %]
- -New Manufacturer - diff --git a/data/templates/manufacturer_read.tt2 b/data/templates/manufacturer_read.tt2 deleted file mode 100644 index 67d72c4d..00000000 --- a/data/templates/manufacturer_read.tt2 +++ /dev/null @@ -1,52 +0,0 @@ - -

Manufacturer

- - - - - - - - - - - - - - - -[% FOREACH instrument = model.current_instruments %] - - - - - - - -[% END %] - -
Current Instruments
NameModelManufacturer's NameSerial #Is Current
[% instrument.name %][% instrument.model %][% instrument.external_name %][% instrument.serial %][% IF instrument.iscurrent %]tick.png[% ELSE %]cross.png[% END %]
- -
- - - - - - - - - - -[% FOREACH instrument_format = model.instrument_formats %] - - - - -[% END %] - -
Instrument Formats
ModelIs Current
[% instrument_format.model %][% IF instrument_format.iscurrent %]tick.png[% ELSE %]cross.png[% END %]
- diff --git a/lib/npg/controller.pm b/lib/npg/controller.pm index 59b8059e..0cbf3a46 100755 --- a/lib/npg/controller.pm +++ b/lib/npg/controller.pm @@ -7,7 +7,6 @@ use base qw(ClearPress::controller); use npg::decorator; use npg::model::instrument_format; -use npg::model::manufacturer; use npg::model::instrument; use npg::model::instrument_annotation; use npg::model::instrument_status; @@ -24,7 +23,6 @@ use npg::model::run_lane_annotation; use npg::model::instrument_status_annotation; use npg::view::annotation; -use npg::view::manufacturer; use npg::view::instrument_format; use npg::view::instrument_status; use npg::view::instrument_annotation; @@ -111,11 +109,17 @@ npg::controller - NPG tracking controller =head1 AUTHOR -Roger M Pettett +=over + +=item Roger M Pettett + +=item Marina Gourtovaia + +=back =head1 LICENSE AND COPYRIGHT -Copyright (C) 2016 GRL +Copyright (C) 2006,2014,2016,2020,2021 Genome Research Ltd. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/lib/npg/model/instrument.pm b/lib/npg/model/instrument.pm index a58412fb..fee37aa6 100644 --- a/lib/npg/model/instrument.pm +++ b/lib/npg/model/instrument.pm @@ -1,8 +1,5 @@ -######### -# Author: rmp -# Created: 2006-10-31 -# package npg::model::instrument; + use strict; use warnings; use base qw(npg::model); @@ -178,14 +175,9 @@ sub model { return $self->instrument_format->model(); } -sub id_manufacturer { - my $self = shift; - return $self->instrument_format->id_manufacturer(); -} - -sub manufacturer { +sub manufacturer_name { my $self = shift; - return $self->instrument_format->manufacturer(); + return $self->instrument_format->manufacturer_name(); } sub runs { @@ -666,13 +658,9 @@ Has a side-effect of updating an instrument's current instrument_status to 'wash my $sModel = $oInstrument->model(); -=head2 id_manufacturer - id_manufacturer of this machine, via its instrument_format - - my $iIdManufacturer = $oInstrument->id_manufacturer(); - -=head2 manufacturer - npg::model::manufacturer of this machine, via its instrument_format +=head2 manufacturer_name - the name of the manufacturer of this instrument - my $oManufacturer = $oInstrument->manufacturer(); + my $oManufacturer = $oInstrument->manufacturer_name(); =head2 instrument_statuses - arrayref of npg::model::instrument_statuses for this instrument @@ -776,11 +764,17 @@ returns true if the instrument is a MiSeq, false otherwise =head1 AUTHOR -Roger Pettett, Ermp@sanger.ac.ukE +=over + +=item Roger Pettett, Ermp@sanger.ac.ukE + +=item Marina Gourtovaia + +=back =head1 LICENSE AND COPYRIGHT -Copyright (C) 2008 GRL, by Roger Pettett +Copyright (C) 2006,2008,2013,2014,2016,2018,2021 Genome Research Ltd. This file is part of NPG. diff --git a/lib/npg/model/instrument_format.pm b/lib/npg/model/instrument_format.pm index ee551af6..d608e67a 100644 --- a/lib/npg/model/instrument_format.pm +++ b/lib/npg/model/instrument_format.pm @@ -1,20 +1,15 @@ -######### -# Author: rmp -# Created: 2006-10-31 -# package npg::model::instrument_format; + use strict; use warnings; use base qw(npg::model); -use English qw(-no_match_vars); use Carp; +use Try::Tiny; use npg::model::instrument; -use npg::model::manufacturer; our $VERSION = '0'; __PACKAGE__->mk_accessors(fields()); -__PACKAGE__->has_a(q[manufacturer]); __PACKAGE__->has_many(q[instrument]); __PACKAGE__->has_all(); @@ -38,19 +33,24 @@ sub init { my $query = q(SELECT id_instrument_format FROM instrument_format WHERE model = ?); - my $ref = []; - eval { + my $ref = []; + my $err; + try { $ref = $self->util->dbh->selectall_arrayref($query, {}, $self->model()); + } catch { + $err = $_; + }; - } or do { - carp $EVAL_ERROR; + if ($err) { + carp $err; return; - }; + } - if(@{$ref}) { + if (@{$ref}) { $self->{'id_instrument_format'} = $ref->[0]->[0]; } } + return 1; } @@ -92,21 +92,9 @@ sub current_instruments { return $self->{'current_instruments'}; } -sub instrument_count { +sub current_instruments_count { my $self = shift; - my $query = q(SELECT COUNT(*) - FROM instrument - WHERE id_instrument_format = ?); - my $ref = []; - eval { - $ref = $self->util->dbh->selectall_arrayref($query, {}, - $self->id_instrument_format()); - } or do { - carp $EVAL_ERROR; - return; - }; - - return $ref->[0]->[0] || q(0); + return scalar @{$self->current_instruments()}; } sub is_used_sequencer_type { @@ -148,7 +136,32 @@ sub current_instruments_by_format { return $self->{current_instruments_by_format}; } +sub manufacturer_name { + my $self = shift; + + my $name; + my $id_manufacturer = $self->id_manufacturer; + if( $id_manufacturer ) { + my $query = qq(SELECT name + FROM manufacturer + WHERE id_manufacturer = $id_manufacturer); + my $ref; + try { + $ref = $self->util->dbh->selectrow_arrayref($query); + } catch { + carp $_; + }; + + if($ref and @{$ref}) { + $name = $ref->[0]; + } + } + + return $name; +} + 1; + __END__ =head1 NAME @@ -172,9 +185,9 @@ npg::model::instrument_format initialise an object based on model being provided -=head2 manufacturer - npg::model::manufacturer of instruments of this instrument_format +=head2 manufacturer_name - the name of the manufacturer of this instrument format - my $oManufacturer = $oInstrumentformat->manufacturer(); + my $oManufacturer = $oInstrumentformat->manufacturer_name(); =head2 instruments - Arrayref of npg::model::instruments of this instrument_format @@ -192,9 +205,9 @@ initialise an object based on model being provided my $arCurrentInstrumentFormats = $oInstrumentFormat->current_instrument_formats(); -=head2 instrument_count - count of instruments of this instrument_format +=head2 current_instruments_count - count of instruments of this instrument_format - my $iInstrumentCount = $oInstrumentFormat->instrument_count(); + my $iCurrentInstrumentCount = $oInstrumentFormat->current_instrument_count(); =head2 is_used_sequencer_type @@ -228,13 +241,11 @@ Returns a hash ref containing keys of current formats (which have current instru =item npg::model -=item English - =item Carp -=item npg::model::instrument +=item Try::Tiny -=item npg::model::manufacturer +=item npg::model::instrument =back @@ -244,11 +255,19 @@ Returns a hash ref containing keys of current formats (which have current instru =head1 AUTHOR -Roger Pettett, Ermp@sanger.ac.ukE +=over + +=item Roger Pettett, Ermp@sanger.ac.ukE + +=item Marina Gourtovaia + +=item Michael Kubiak + +=back =head1 LICENSE AND COPYRIGHT -Copyright (C) 2008 GRL, by Roger Pettett +Copyright (C) 2006,2008,2013,2014,2016,2018,2021 Genome Research Ltd. This file is part of NPG. diff --git a/lib/npg/model/manufacturer.pm b/lib/npg/model/manufacturer.pm deleted file mode 100644 index 5f0ed6ab..00000000 --- a/lib/npg/model/manufacturer.pm +++ /dev/null @@ -1,182 +0,0 @@ -######### -# Author: rmp -# Created: 2006-10-31 -# -package npg::model::manufacturer; -use strict; -use warnings; -use base qw(npg::model); -use English qw(-no_match_vars); -use Carp; -use npg::model::instrument_format; -use npg::model::instrument; - -our $VERSION = '0'; - -__PACKAGE__->mk_accessors(fields()); -__PACKAGE__->has_many('instrument_format'); -__PACKAGE__->has_all(); - -sub fields { - return qw(id_manufacturer - name); -} - -sub init { - my $self = shift; - - if($self->{'name'} && - !$self->{'id_manufacturer'}) { - my $query = q(SELECT id_manufacturer - FROM manufacturer - WHERE name = ?); - my $ref = []; - eval { - $ref = $self->util->dbh->selectall_arrayref($query, {}, $self->name()); - - } or do { - carp $EVAL_ERROR; - return; - }; - - if(scalar @{$ref}) { - $self->{'id_manufacturer'} = $ref->[0]->[0]; - } - } - return 1; -} - -sub current_instruments { - my $self = shift; - my $pkg = 'npg::model::instrument'; - my $query = qq(SELECT @{[join q(, ), q(ifm.model AS model), - map { "i.$_ AS $_" } $pkg->fields()]} - FROM @{[$pkg->table()]} i, - instrument_format ifm - WHERE i.id_instrument_format = ifm.id_instrument_format - AND ifm.id_manufacturer = ? - AND ifm.iscurrent = 1 - AND i.iscurrent = 1 - ORDER BY i.id_instrument_format DESC); - return $self->gen_getarray($pkg, - $query, - $self->id_manufacturer()); -} - -sub instrument_count { - my $self = shift; - my $query = q(SELECT COUNT(*) - FROM instrument i, - instrument_format ifrm - WHERE ifrm.id_manufacturer = ? - AND ifrm.id_instrument_format = i.id_instrument_format); - my $ref = []; - eval { - $ref = $self->util->dbh->selectall_arrayref($query, {}, - $self->id_manufacturer()); - } or do { - carp $EVAL_ERROR; - return; - }; - - return $ref->[0]->[0]; -} - -1; -__END__ - -=head1 NAME - -npg::model::manufacturer - -=head1 VERSION - -=head1 SYNOPSIS - -=head1 DESCRIPTION - -=head1 SUBROUTINES/METHODS - -=head2 fields - accessors for this table/class - - my @aFields = $oPkg->fields(); - my @aFields = npg::model::->fields(); - -=head2 init - overridden base-class loader - - Allows instantiation by-name rather as well as id_manufacturer, e.g. - my $mfct = npg::model::manufacturer->new({ - 'util' => $util, - 'name' => 'Illumina', - }); - -=head2 manufacturers - arrayref of all npg::model::manufacturers - - my $arManufacturers = $oManufacturer->manufacturers(); - -=head2 instrument_formats - arrayref of npg::model::instrument_formats by this manufacturer - - my $arInstrumentFormats = $oManufacturer->instrument_formats(); - -=head2 current_instruments - arrayref of npg::model::instruments which have iscurrent and whose instrument_formats have iscurrent - - my $arInstruments = $oManufacturer->current_instruments(); - -=head2 instrument_count - A count of all instruments from this manufacturer - - my $iInstrumentCount = $oManufacturer->instrument_count(); - -=head1 DIAGNOSTICS - -=head1 CONFIGURATION AND ENVIRONMENT - -=head1 DEPENDENCIES - -=over - -=item strict - -=item warnings - -=item base - -=item npg::model - -=item English - -=item Carp - -=item npg::model::instrument_format - -=item npg::model::instrument - -=back - -=head1 INCOMPATIBILITIES - -=head1 BUGS AND LIMITATIONS - -=head1 AUTHOR - -Roger Pettett, Ermp@sanger.ac.ukE - -=head1 LICENSE AND COPYRIGHT - -Copyright (C) 2008 GRL, by Roger Pettett - -This file is part of NPG. - -NPG is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see http://www.gnu.org/licenses/ . - -=cut diff --git a/lib/npg/view/manufacturer.pm b/lib/npg/view/manufacturer.pm deleted file mode 100644 index ae648f21..00000000 --- a/lib/npg/view/manufacturer.pm +++ /dev/null @@ -1,63 +0,0 @@ -######### -# Author: rmp -# Created: 2007-03-28 -# -package npg::view::manufacturer; -use base qw(npg::view); -use strict; -use warnings; - -our $VERSION = '0'; - -1; - -__END__ - -=head1 NAME - -npg::view::manufacturer - view handling for manufacturers - -=head1 VERSION - -=head1 SYNOPSIS - -=head1 DESCRIPTION - -=head1 SUBROUTINES/METHODS - -=head1 DIAGNOSTICS - -=head1 CONFIGURATION AND ENVIRONMENT - -=head1 DEPENDENCIES - -npg::view - -=head1 INCOMPATIBILITIES - -=head1 BUGS AND LIMITATIONS - -=head1 AUTHOR - -Roger Pettett, Ermp@sanger.ac.ukE - -=head1 LICENSE AND COPYRIGHT - -Copyright (C) 2008 GRL, by Roger Pettett - -This file is part of NPG. - -NPG is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see http://www.gnu.org/licenses/ . - -=cut diff --git a/t/10-model-instrument.t b/t/10-model-instrument.t index 7572838e..aa72de5e 100644 --- a/t/10-model-instrument.t +++ b/t/10-model-instrument.t @@ -107,6 +107,8 @@ my $util = t::util->new({ fixtures => 1 }); isa_ok($current_instruments, 'ARRAY', '$model->current_instruments()'); is((scalar@{$current_instruments} + 1), scalar@{$instruments}, 'scalar@{$model->current_instruments()} is 1 less than scalar@{$model->instruments()}'); is($model->current_instruments(), $current_instruments, '$model->current_instruments() cached ok'); + is($model->manufacturer_name, undef, + 'manufacturer name is undefined for a model used in list context'); } { @@ -139,8 +141,7 @@ my $util = t::util->new({ fixtures => 1 }); isa_ok($current_run, 'npg::model::run', '$model->current_run()'); is($model->current_run(), $current_run, '$model->current_run() cached ok'); is($model->model(), 'HK', '$model->model() retrieved correctly'); - is($model->id_manufacturer(), 10, '$model->id_manufacturer() retrieved correctly'); - isa_ok($model->manufacturer(), 'npg::model::manufacturer', '$model->id_manufacturer()'); + is($model->manufacturer_name(), 'Illumina', 'correct manufacturer name'); my @desigs; foreach my $i ( @{$model->designations()} ) { diff --git a/t/10-model-instrument_format.t b/t/10-model-instrument_format.t index 1dd86b3f..78e9b14f 100644 --- a/t/10-model-instrument_format.t +++ b/t/10-model-instrument_format.t @@ -1,16 +1,14 @@ use strict; use warnings; use t::util; -use npg::model::instrument; -use Test::More tests => 15; -use Test::Trap; -use Test::Deep; +use Test::More tests => 17; +use Test::Exception; our $IF = 'npg::model::instrument_format'; +use_ok('npg::model::instrument'); use_ok($IF); - my $util = t::util->new({fixtures => 1}); { @@ -28,6 +26,10 @@ my $util = t::util->new({fixtures => 1}); isa_ok($cifs, 'ARRAY'); is((scalar @{$cifs}), 7, 'unprimed cache cif'); is((scalar @{$if->current_instrument_formats()}), 7, 'primed cache cif'); + my $name; + lives_ok {$if->manufacturer_name}, + 'no error calling manufacturer_name on an object used in list context'; + is($name, undef, 'manufacturer name is undefined'); } { @@ -38,6 +40,7 @@ my $util = t::util->new({fixtures => 1}); my $is = $if->instruments(); isa_ok($is, 'ARRAY'); is((scalar @{$is}), 13, 'instruments'); + is($if->manufacturer_name, 'Illumina', 'correct manufacturer name'); } { @@ -56,26 +59,8 @@ my $util = t::util->new({fixtures => 1}); util => $util, id_instrument_format => 4, }); - my $ic = $if->instrument_count(); - is($ic, 13, 'instrument count'); -} - -{ - trap { - my $if = $IF->new({ - util => 'foo', - }); - is($if->instrument_count(), undef, 'database query failure'); - }; -} - -{ - my $if = $IF->new({ - util => $util, - id_instrument_format => 0, - }); - my $ic = $if->instrument_count(); - is($ic, 0, 'zero instrument count'); + my $ic = $if->current_instruments_count(); + is($ic, 12, 'current instrument count'); } diff --git a/t/10-model-manufacturer.t b/t/10-model-manufacturer.t deleted file mode 100644 index cbc7e5be..00000000 --- a/t/10-model-manufacturer.t +++ /dev/null @@ -1,98 +0,0 @@ -use strict; -use warnings; -use Test::More tests => 14; -use t::util; -use Test::Trap; - -use_ok('npg::model::manufacturer'); - -my $util = t::util->new({fixtures=>1}); - -{ - my $m = npg::model::manufacturer->new({util=>$util}); - isa_ok($m, 'npg::model::manufacturer'); -} - -{ - trap { - my $m = npg::model::manufacturer->new({ - util => 'foo', - name => 'fail!', - }); - is($m->init(), undef, 'database query failure'); - }; -} - -{ - my $m = npg::model::manufacturer->new({ - util => $util, - name => 'not present', - }); - is($m->id_manufacturer(), undef, 'no lookup by name'); -} - -{ - my $m = npg::model::manufacturer->new({ - util => $util, - name => 'Applied Biosystems', - }); - is($m->id_manufacturer(), 20, 'load by name'); -} - - -{ - my $m = npg::model::manufacturer->new({ - util => $util, - id_manufacturer => 10, - }); - is($m->name(), 'Illumina', 'load by id'); -} - -{ - my $m = npg::model::manufacturer->new({ - util => $util, - id_manufacturer => 10, - }); - my $ci = $m->current_instruments(); - isa_ok($ci, 'ARRAY'); - is((scalar @{$ci}), 19, 'current instrument size'); -} - -{ - my $m = npg::model::manufacturer->new({ - util => $util, - id_manufacturer => 10, - }); - is($m->instrument_count(), 20, 'instrument count'); -} - -{ - trap { - my $m = npg::model::manufacturer->new({ - util => 'bla', - id_manufacturer => 10, - }); - is($m->instrument_count(), undef, 'database query failure'); - }; -} - -{ - my $m = npg::model::manufacturer->new({ - util => $util, - id_manufacturer => 10, - }); - my $is = $m->instrument_formats(); - isa_ok($is, 'ARRAY'); - is((scalar @{$is}), 6, 'instrument_formats'); -} - -{ - my $m = npg::model::manufacturer->new({ - util => $util, - id_manufacturer => 10, - }); - my $ms = $m->manufacturers(); - isa_ok($ms, 'ARRAY'); - is((scalar @{$ms}), 3, 'manufacturers'); -} -