Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
Updated report_suite_id to not use a value in SiteCatalystConfig.pm. …
Browse files Browse the repository at this point in the history
…Updated tests to use a report_suite_id that is saved to or read from a temp file, rather than use a value from SiteCatalystConfig.pm when a value is not specified
  • Loading branch information
jpinkham committed Jun 9, 2013
1 parent a9f25ea commit b5b13cb
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 40 deletions.
16 changes: 1 addition & 15 deletions lib/Business/SiteCatalyst/Company.pm
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ sub get_report_suites
=head2 get_tracking_server()
Returns the tracking server and namespace for the specified report suite.
If report suite is not specified, 'report_suite_id' in SiteCatalystConfig
(if one exists) will be used.
my $tracking_server = $company->get_tracking_server();
my $tracking_server = $company->get_tracking_server(
Expand All @@ -239,21 +237,9 @@ sub get_tracking_server
{
my ( $self, %args ) = @_;

# If report suite was not specified as an argument, try to use value from config
if ( !defined $args{'report_suite_id'} || $args{'report_suite_id'} eq '' )
{
require SiteCatalystConfig;
my $config = SiteCatalystConfig->new();

if ( defined( $config ) && $config->{'report_suite_id'} ne '' )
{
$args{'report_suite_id'} = $config->{'report_suite_id'};
}
else
{
croak "Argument 'report_suite_id' is required because 'report_suite_id' is not specified in SiteCatalystConfig.pm"
if !defined( $args{'report_suite_id'} ) || ( $args{'report_suite_id'} eq '' );
}
croak "Argument 'report_suite_id' is required";
}

my $site_catalyst = $self->get_site_catalyst();
Expand Down
9 changes: 1 addition & 8 deletions t/01-local_config.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use Business::SiteCatalyst::Report;
eval 'use SiteCatalystConfig';
$@
? plan( skip_all => 'Local connection information for Adobe SiteCatalyst required to run tests.' )
: plan( tests => 3 );
: plan( tests => 2 );

my $config = SiteCatalystConfig->new();

Expand All @@ -27,10 +27,3 @@ like(
'The shared_secret is defined.',
);

like(
$config->{'report_suite_id'},
qr/\w/,
'The report_suite_id is defined.',
);


22 changes: 20 additions & 2 deletions t/Company/30-get_report_suites.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use Business::SiteCatalyst;
eval 'use SiteCatalystConfig';
$@
? plan( skip_all => 'Local connection information for Adobe SiteCatalyst required to run tests.' )
: plan( tests => 4 );
: plan( tests => 6 );

my $config = SiteCatalystConfig->new();

Expand All @@ -25,7 +25,7 @@ ok(
);

ok(
defined(
defined(
my $company = $site_catalyst->instantiate_company()
),
'Instantiate a new Business::SiteCatalyst::Company.',
Expand All @@ -44,3 +44,21 @@ ok(
'Retrieve response.',
) || diag( explain( $response ) );


if ( scalar( $response ) > 0 )
{

# Store first item, if anything was returned, into file for use in other tests
ok(
open( FILE, '>', 'business-sitecatalyst-report-report_suite_id.tmp'),
'Open temp file to store first report suite id for use in other tests'
);

print FILE $response->[0]->{'rsid'};

ok(
close FILE,
'Close temp file'
);

}
38 changes: 27 additions & 11 deletions t/Company/40-get_tracking_server.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use Business::SiteCatalyst;
eval 'use SiteCatalystConfig';
$@
? plan( skip_all => 'Local connection information for Adobe SiteCatalyst required to run tests.' )
: plan( tests => 6 );
: plan( tests => 8 );

my $config = SiteCatalystConfig->new();

Expand All @@ -32,27 +32,43 @@ ok(
);

my $response;

throws_ok(
sub
{
$response = $company->get_tracking_server( report_suite_id => '' );
},
qr/Argument 'report_suite_id' is required/,
'Request tracking server - empty "report_suite_id"'
);

ok(
defined(
$response = $company->get_tracking_server( report_suite => $config->{'report_suite_id'} )
),
'Request tracking server - report suite specified.',
open( FILE, 'business-sitecatalyst-report-report_suite_id.tmp'),
'Open temp file to read report suite id'
);

my $report_suite_id;

ok(
Data::Validate::Type::is_string( $response, allow_empty => 0 ),
'Retrieve tracking server - report suite specified.',
) || diag( explain( $response ) );
$report_suite_id = do { local $/; <FILE> },
'Read in report suite id'
);

ok(
close FILE,
'Close temp file'
);


ok(
defined(
$response = $company->get_tracking_server()
$response = $company->get_tracking_server( report_suite_id => $report_suite_id )
),
'Request tracking server - report suite not specified.',
'Request tracking server - report_suite_id specified.',
);

ok(
Data::Validate::Type::is_string( $response, allow_empty => 0 ),
'Retrieve tracking server - report suite not specified.',
'Retrieve tracking server - report_suite_id specified.',
) || diag( explain( $response ) );

27 changes: 23 additions & 4 deletions t/Report/20-queue.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use Business::SiteCatalyst;
eval 'use SiteCatalystConfig';
$@
? plan( skip_all => 'Local connection information for Adobe SiteCatalyst required to run tests.' )
: plan( tests => 8 );
: plan( tests => 11 );

my $config = SiteCatalystConfig->new();

Expand All @@ -25,11 +25,30 @@ ok(
);

ok(
defined(
open( FILE, 'business-sitecatalyst-report-report_suite_id.tmp'),
'Open temp file to read report suite id'
);

my $report_suite_id;

ok(
$report_suite_id = do { local $/; <FILE> },
'Read in report suite id'
);

ok(
close FILE,
'Close temp file'
);



ok(
defined(
my $report = $site_catalyst->instantiate_report(
type => 'Ranked',
report_suite_id => $config->{'report_suite_id'}
)
report_suite_id => $report_suite_id
)
),
'Instantiate a new Business::SiteCatalyst::Report.',
);
Expand Down

0 comments on commit b5b13cb

Please sign in to comment.