Amazon-MWS

 view release on metacpan or  search on metacpan

t/job-selection.t  view on Meta::CPAN

#!perl

use utf8;
use strict;
use warnings;
use Amazon::MWS::Uploader;
use Data::Dumper;
use Test::More;
use DateTime;
use DBI;

binmode STDOUT, ':utf8';
binmode STDERR, ':utf8';

my $feed_dir = 't/feeds';

if (-d 'schemas') {
    plan tests => 12;
}
else {
    plan skip_all => q{Missing "schemas" directory with the xsd from Amazon, skipping feeds tests};
}



unless (-d $feed_dir) {
    mkdir $feed_dir or die "Cannot create $feed_dir $!";
}

my %constructor = (
                   merchant_id => '__MERCHANT_ID__',
                   shop_id => 'shoppe',
                   access_key_id => '12341234',
                   secret_key => '123412341234',
                   marketplace_id => '123412341234',
                   endpoint => 'https://mws-eu.amazonservices.com',
                   feed_dir => $feed_dir,
                   schema_dir => 'schemas',
                   db_dsn => 'dbi:SQLite:dbname=t/test.db',
                   db_username => '',
                   db_password => '',
                  );



my $uploader = Amazon::MWS::Uploader->new(%constructor);
ok ($uploader->dbh);
my $create_table =<<'SQL';
CREATE TABLE amazon_mws_jobs (
      amws_job_id VARCHAR(64) NOT NULL,
      shop_id VARCHAR(64) NOT NULL,
      task VARCHAR(64) NOT NULL,
      -- if complete one or those has to be set.
      aborted BOOLEAN NOT NULL DEFAULT FALSE,
      success BOOLEAN NOT NULL DEFAULT FALSE,
      last_updated TIMESTAMP,
      job_started_epoch INTEGER,
      status VARCHAR(255),
      PRIMARY KEY (amws_job_id, shop_id)
); 
SQL
my $create_p_table = <<'SQL';
CREATE TABLE amazon_mws_products (
       -- don't enforce the sku format
       sku VARCHAR(255) NOT NULL,
       shop_id VARCHAR(64) NOT NULL,
       -- given that we just test for equality, don't enforce a type.
       -- So an epoch will do just fine, as it would be a random date,
       -- as long as the script sends consistent data



( run in 0.556 second using v1.01-cache-2.11-cpan-d8267643d1d )