<commit_before>#!/usr/bin/env perl

use strict;
use warnings;

use Test::More qw(no_plan); #no_plan required for skip usage

use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::Test::TestUtils;
use Bio::EnsEMBL::Utils::Scalar            qw( check_ref );
use Bio::EnsEMBL::Funcgen::Utils::EFGUtils qw( are_valid );
use Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor;

# switch on the debug prints
our $verbose = 0;
my $skip = 0;
my $okay = 0;

warn "Annotated_SetFeatureAdaptor.t tests are incomplete and needs updating to use MultiTestDB\n";


ok(1, 'Startup test');#?

#my $multi = Bio::EnsEMBL::Test::MultiTestDB->new();
#my $db    = $multi->get_DBAdaptor( 'funcgen' );


my $db = Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor->new
  (
   #-user    => 'XXX',
   #-host    => 'XXX',
   -species => 'homo_sapiens',
   -dbname  => 'homo_sapiens_funcgen_73_37'
  );


#debug( 'Test database instantiated' ); #Less verbose, but only get test names in line and in debug mode
ok( $db, 'DBAdaptor creation');# More verbose, but we get failed test name summary at end


#todo Change this to InputSet_Set_BaseAdaptor?

SKIP : {
  
  if(! $db){
    skip 'Failed to create DBAdaptor, skipping all tests', 0;
  }

  my $iset_a = $db->get_InputSetAdaptor;
  ok($iset_a, 'Got InputSetAdaptor');
 

  #TODO update skip counts

  SKIP: {
    if(! defined $iset_a){
      skip 'Failed to get_InputSetAdaptor', 0;  
    }
  
    #Get all isets via fetch_all and cache, then we can test numbers returned from
    #fetch methods without knowing the contents of the DB apiori
    #This is still not perfect, but provides some level of rigour
    #until we have a known test DB
    my ($table, $table_syn) = @{$iset_a->_main_table};
    
    ok((($table eq 'input_set') &&
        ($table_syn eq 'inp')),
      'BaseAdaptor::_main_table gives correct name and synonym');
    
    my $dbIDs = $iset_a->_list_dbIDs;
    ok(check_ref($dbIDs, 'ARRAY'), 'BaseAdaptor::_list_dbIDs gives Arrayref');
       
    my $isets = $iset_a->fetch_all;
    eval { are_valid('Bio::EnsEMBL::Funcgen::InputSet', $isets) };
    my $failed = ($@) ? 1 : 0;
    ok( ((! $failed) &&
          scalar(@$isets) == scalar(@$dbIDs)),
       'BaseAdaptor::fetch_all InputSets matches number from _list_dbIDs');
    <commit_msg>comments<commit_after>#!/usr/bin/env perl

use strict;
use warnings;

use Test::More qw(no_plan); #no_plan required for skip usage

use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::Test::TestUtils;
use Bio::EnsEMBL::Utils::Scalar            qw( check_ref );
use Bio::EnsEMBL::Funcgen::Utils::EFGUtils qw( are_valid );
use Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor;

# switch on the debug prints
our $verbose = 0;
my $skip = 0;
my $okay = 0;

warn "Annotated_SetFeatureAdaptor.t tests are incomplete and needs updating to use MultiTestDB\n";


ok(1, 'Startup test');#?

#my $multi = Bio::EnsEMBL::Test::MultiTestDB->new();
#my $db    = $multi->get_DBAdaptor( 'funcgen' );


my $db = Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor->new
  (
   -user    => 'XXX',
   -host    => 'XXX',
   -species => 'homo_sapiens',
   -dbname  => 'homo_sapiens_funcgen_73_37'
  );


#debug( 'Test database instantiated' ); #Less verbose, but only get test names in line and in debug mode
ok( $db, 'DBAdaptor creation');# More verbose, but we get failed test name summary at end


SKIP : {
  
  if(! $db){
    skip 'Failed to create DBAdaptor, skipping all tests', 0;
  }

  my $iset_a = $db->get_InputSetAdaptor;
  ok($iset_a, 'Got InputSetAdaptor');
 

  #TODO update skip counts
  #Add test for optional status arg to fetch_all_by_Feature/CellType

  SKIP: {
    if(! defined $iset_a){
      skip 'Failed to get_InputSetAdaptor', 0;  
    }
  
    #Get all isets via fetch_all and cache, then we can test numbers returned from
    #fetch methods without knowing the contents of the DB apiori
    #This is still not perfect, but provides some level of rigour
    #until we have a known test DB
    my ($table, $table_syn) = @{$iset_a->_main_table};
    
    ok((($table eq 'input_set') &&
        ($table_syn eq 'inp')),
      'BaseAdaptor::_main_table gives correct name and synonym');
    
    my $dbIDs = $iset_a->_list_dbIDs;
    ok(check_ref($dbIDs, 'ARRAY'), 'BaseAdaptor::_list_dbIDs gives Arrayref');
       
    my $isets = $iset_a->fetch_all;
    eval { are_valid('Bio::EnsEMBL::Funcgen::InputSet', $isets) };
    my $failed = ($@) ? 1 : 0;
    ok( ((! $failed) &&
          scalar(@$isets) == scalar(@$dbIDs)),
       'BaseAdaptor::fetch_all InputSets matches number from _list_dbIDs');
    
{'fraction_non_alphanumeric': 0.14116094986807387, 'fraction_numerical': 0.005277044854881266, 'mean_word_length': 3.7484342379958244, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6943062', 'n_tokens_mistral': 1715, 'n_tokens_neox': 1648, 'n_words': 459}