ACME-QuoteDB

 view release on metacpan or  search on metacpan

t/04-get_quotes_more.t  view on Meta::CPAN

#!perl -T

# TODO more tests, make add_quote break!
# TODO see bottom of file for more todo's

use strict;
use warnings;

use ACME::QuoteDB;
use ACME::QuoteDB::LoadDB;

#use Test::More 'no_plan';
use Test::More tests => 24;
use File::Basename qw/dirname/;
use Data::Dumper qw/Dumper/;
use Carp qw/croak/;
use File::Spec;
use Readonly;

BEGIN {
    eval "use DBD::SQLite";
    $@ and croak 'DBD::SQLite is a required dependancy';
}


Readonly my $FG_QUOTE => 'Lois: Peter, what did you promise me?' .
"\nPeter: That I wouldn't drink at the stag party." .
"\nLois: And what did you do?" .
"\nPeter: Drank at the stag pa-- ... Whoa. I almost walked into that one.";
  

{
    #make test db writeable
    use ACME::QuoteDB::DB::DBI;
    # yeah, this is supposed to be covered by the build process
    # but is failing sometimes,...
    chmod 0666, ACME::QuoteDB::DB::DBI->get_current_db_path;

    my $q = File::Spec->catfile((dirname(__FILE__),'data'), 
        'simpsons_quotes.csv'
    );
    my $load_db = ACME::QuoteDB::LoadDB->new({
                                file        => $q,
                                file_format => 'csv',
                                create_db   => 1,
                            });

    isa_ok $load_db, 'ACME::QuoteDB::LoadDB';
    $load_db->data_to_db;
    is $load_db->success, 1;
}

my $sq = ACME::QuoteDB->new;

is $sq->get_quote({Rating => '8.7'}),
    "Me fail English? That's unpossible.\n-- Ralph Wiggum";

is( $sq->list_attr_sources, 'The Simpsons');
is( $sq->list_categories, 'Humor');


{
  eval { # quote is mandatory
     $sq->add_quote({
         Quote     => q{},
         AttrName  => 'Peter Griffin',
         Source    => 'Family Guy',
         Rating    => '8.6',
         Category  => 'TV Humor',
     });
  };
  if ($@) {
      if ($@ =~ m/ are mandatory parameters/){ 
         pass 'correct, exception expected'
      }

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.486 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )