Merge pull request #5205 from solgenomics/topic/generic_trial_upload
[sgn.git] / t / legacy / integration / gem.t
blob7ebbbf7a86da7a6fcc11f5ced1f37b6b1f7c1acb
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
5 use lib 't/lib';
6 use SGN::Test qw/validate_urls/;
8 use Test::More tests => 33;
9 use SGN::Test::WWW::Mechanize;
10 use CXGN::GEM::Schema;
12 my $base_url = $ENV{SGN_TEST_SERVER};
13 my $mech = SGN::Test::WWW::Mechanize->new;
15 $mech->with_test_level( local => sub {
17 ## First take variables for the test from the database ##
19 my @schema_list = ('gem', 'biosource', 'metadata', 'public');
20 my $schema_list = join(',', @schema_list);
21 my $set_path = "SET search_path TO $schema_list";
23 my $dbh = $mech->context()->dbc()->dbh();
25 my $schema = CXGN::GEM::Schema->connect( sub { $dbh },
26 {on_connect_do => $set_path} );
28 ## WWW. DETAIL PAGES ###
30 ## TEMPLATE ##
31 ## Take a template, an experiment name and a platform name
33 my ($template_row) = $schema->resultset('GeTemplate')
34 ->search( undef,
36 order_by => {-asc => 'template_id'},
37 rows => 1,
41 if (defined $template_row) {
43 my $template_id = $template_row->get_column('template_id');
44 my $template_name = $template_row->get_column('template_name');
46 $mech->get_ok("$base_url/gem/template.pl?id=$template_id");
47 $mech->content_like(qr/Expression Template: $template_name/);
48 $mech->content_unlike( qr/ERROR PAGE/ );
50 $mech->get_ok("$base_url/gem/template.pl?name=$template_name");
51 $mech->content_like(qr/Expression Template: $template_name/);
52 $mech->content_unlike( qr/ERROR PAGE/ );
55 ## EXPERIMENT ##
57 my ($experiment_row) = $schema->resultset('GeExperiment')
58 ->search( undef,
60 order_by => {-asc => 'experiment_id'},
61 rows => 1,
65 if (defined $experiment_row) {
67 my $experiment_id = $experiment_row->get_column('experiment_id');
68 my $experiment_name = $experiment_row->get_column('experiment_name');
70 $mech->get_ok("$base_url/gem/experiment.pl?id=$experiment_id");
71 $mech->content_unlike( qr/ERROR PAGE/ );
72 $mech->content_like( qr/Expression Experiment: $experiment_name/ );
74 $mech->get_ok("$base_url/gem/experiment.pl?name=$experiment_name");
75 $mech->content_unlike( qr/ERROR PAGE/ );
76 $mech->content_like( qr/Expression Experiment: $experiment_name/ );
78 $mech->get_ok("$base_url/gem/experiment.pl?name=foob");
79 $mech->content_unlike( qr/ERROR PAGE/ );
80 $mech->content_like( qr/No experiment data for the specified parameters/);
83 ## PLATFORM ##
85 my ($platform_row) = $schema->resultset('GePlatform')
86 ->search( undef,
88 order_by => {-asc => 'platform_id'},
89 rows => 1,
93 if (defined $platform_row) {
95 my $platform_id = $platform_row->get_column('platform_id');
96 my $platform_name = $platform_row->get_column('platform_name');
98 $mech->get_ok("$base_url/gem/platform.pl?name=$platform_name");
99 $mech->content_like(qr/Expression Platform: $platform_name/);
100 $mech->content_unlike( qr/ERROR PAGE/ );
102 $mech->get_ok("$base_url/gem/platform.pl?id=$platform_id");
103 $mech->content_like(qr/Expression Platform: $platform_name/);
104 $mech->content_unlike( qr/ERROR PAGE/ );
107 ## EXPERIMENTAL DESIGN ##
109 my ($experimental_design_row) = $schema->resultset('GeExperimentalDesign')
110 ->search( undef,
112 order_by => {-asc => 'experimental_design_id'},
113 rows => 1,
117 if (defined $experimental_design_row) {
119 my $expdesign_id = $experimental_design_row->get_column('experimental_design_id');
120 my $expdesign_name = $experimental_design_row->get_column('experimental_design_name');
122 $mech->get_ok("$base_url/gem/experimental_design.pl?id=$expdesign_id");
123 $mech->content_like(qr/Expression Experimental Design:\s+$expdesign_name/);
124 $mech->content_unlike( qr/ERROR PAGE/ );
126 $mech->get_ok("$base_url/gem/experimental_design.pl?name=$expdesign_name");
127 $mech->content_like(qr/Expression Experimental Design:\s+$expdesign_name/);
128 $mech->content_unlike( qr/ERROR PAGE/ );
131 ## TARGET ##
133 my ($target_row) = $schema->resultset('GeTarget')
134 ->search( undef,
136 order_by => {-asc => 'target_id'},
137 rows => 1,
141 if (defined $target_row) {
143 my $target_id = $target_row->get_column('target_id');
144 my $target_name = $target_row->get_column('target_name');
146 $mech->get_ok("$base_url/gem/target.pl?name=$target_name");
147 $mech->content_like(qr/Expression Target: $target_name/);
148 $mech->content_unlike( qr/ERROR PAGE/ );
150 $mech->get_ok("$base_url/gem/target.pl?id=$target_id");
151 $mech->content_like(qr/Expression Target: $target_name/);
152 $mech->content_unlike( qr/ERROR PAGE/ );