Commit 0082bb91 authored by Carla Cummins's avatar Carla Cummins Committed by ens-bwalts

Added unit test for peekJob.pl

parent b1e82d7c
......@@ -37,7 +37,7 @@ sub peek {
$job->load_parameters;
my $unsub_params = $job->{'_unsubstituted_param_hash'};
print Dumper $unsub_params;
print Data::Dumper->Dump( [ $unsub_params ], [ qw(*unsubstituted_param_hash) ] );
# my @ordered_params = sort { lc($a) cmp lc($b) } keys %$unsub_params;
# print "{\n";
......
......@@ -46,7 +46,7 @@ use Bio::EnsEMBL::Hive::Scripts::StandaloneJob;
our @ISA = qw(Exporter);
our @EXPORT = ();
our %EXPORT_TAGS = ();
our @EXPORT_OK = qw( standaloneJob init_pipeline runWorker beekeeper generate_graph visualize_jobs db_cmd seed_pipeline get_test_urls get_test_url_or_die run_sql_on_db load_sql_in_db make_new_db_from_sqls make_hive_db safe_drop_database all_source_files);
our @EXPORT_OK = qw( standaloneJob init_pipeline runWorker beekeeper generate_graph visualize_jobs db_cmd seed_pipeline tweak_pipeline peekJob get_test_urls get_test_url_or_die run_sql_on_db load_sql_in_db make_new_db_from_sqls make_hive_db safe_drop_database all_source_files);
our $VERSION = '0.00';
......@@ -345,6 +345,24 @@ sub visualize_jobs {
return _test_ehive_script('visualize_jobs', @_);
}
=head2 peekJob
Arg[1] : String $url. The location of the database
Arg[2] : Arrayref $args. Extra arguments given to peekJob.pl
Arg[3] : String $test_name (optional). The name of the test
Example : peekJob($url, [-job_id => 1], 'Check params for job 1');
Description : Very generic function to run peekJob.pl on the given database with the given arguments
Returntype : None
Exceptions : TAP-style
Caller : general
Status : Stable
=cut
sub peekJob {
return _test_ehive_script('peekJob', @_);
}
=head2 db_cmd
......
#!/usr/bin/env perl
# Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
# Copyright [2016-2019] EMBL-European Bioinformatics Institute
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
use strict;
use warnings;
use Test::More;
use Data::Dumper;
use Test::JSON;
use JSON qw(decode_json);
use Capture::Tiny ':all';
use Bio::EnsEMBL::Hive::Utils::Test qw(init_pipeline runWorker beekeeper get_test_url_or_die run_sql_on_db peekJob);
# eHive needs this to initialize the pipeline (and run db_cmd.pl)
$ENV{'EHIVE_ROOT_DIR'} ||= File::Basename::dirname( File::Basename::dirname( File::Basename::dirname( Cwd::realpath($0) ) ) );
my $pipeline_url = get_test_url_or_die();
# Starting a first set of checks with a "GCPct" pipeline
init_pipeline('Bio::EnsEMBL::Hive::Examples::FailureTest::PipeConfig::FailureTest_conf', $pipeline_url);
my $hive_dba = Bio::EnsEMBL::Hive::DBSQL::DBAdaptor->new( -url => $pipeline_url );
my $stdout = capture_stdout {
peekJob($pipeline_url, ["-job_id" => 1]);
};
$stdout =~ s/\s+//g;
my $exp_stdout = "%unsubstituted_param_hash=('column_names'=>['value'],'inputlist'=>'#expr([0..#job_count#-1])expr#','job_count'=>10);";
is( $stdout, $exp_stdout, 'Correct params reported' );
done_testing();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment