Added full test data fixture setup

This commit is contained in:
Tom Bloor 2017-09-26 17:49:16 +01:00
parent 65d509943c
commit df90f62b7a
54 changed files with 618 additions and 0 deletions

View File

@ -0,0 +1,210 @@
#! /usr/bin/env perl
use strict;
use warnings;
use DBIx::Class::Fixtures;
use FindBin qw/ $Bin /;
use lib "$Bin/../../../../lib";
use Pear::LocalLoop::Schema;
use DateTime;
my $fixtures = DBIx::Class::Fixtures->new({
config_dir => "$Bin",
});
my $schema = Pear::LocalLoop::Schema->connect('dbi:SQLite::memory:');
$schema->deploy;
$schema->resultset('Leaderboard')->populate([
[ qw/ name type / ],
[ 'Daily Total', 'daily_total' ],
[ 'Daily Count', 'daily_count' ],
[ 'Weekly Total', 'weekly_total' ],
[ 'Weekly Count', 'weekly_count' ],
[ 'Monthly Total', 'monthly_total' ],
[ 'Monthly Count', 'monthly_count' ],
[ 'All Time Total', 'all_time_total' ],
[ 'All Time Count', 'all_time_count' ],
]);
my $entity1 = {
customer => {
full_name => 'Test User1',
display_name => 'Test User1',
postcode => 'LA1 1AA',
year_of_birth => 2006,
latitude => 54.04,
longitude => -2.80,
},
user => {
email => 'test1@example.com',
password => 'abc123',
},
type => "customer",
};
my $entity2 = {
customer => {
full_name => 'Test User2',
display_name => 'Test User2',
postcode => 'LA1 1AB',
year_of_birth => 2006,
latitude => 54.04,
longitude => -2.80,
},
user => {
email => 'test2@example.com',
password => 'abc123',
},
type => "customer",
};
my $entity3 = {
customer => {
full_name => 'Test User3',
display_name => 'Test User3',
postcode => 'LA1 1AD',
year_of_birth => 2006,
latitude => 54.05,
longitude => -2.80,
},
user => {
email => 'test3@example.com',
password => 'abc123',
},
type => "customer",
};
my $entity4 = {
customer => {
full_name => 'Test User4',
display_name => 'Test User4',
postcode => 'LA1 1AE',
year_of_birth => 2006,
latitude => 54.04,
longitude => -2.80,
},
user => {
email => 'test4@example.com',
password => 'abc123',
},
type => "customer",
};
my $org1 = {
organisation => {
name => 'Test Org',
street_name => 'Test Street',
town => 'Lancaster',
postcode => 'LA1 1AF',
latitude => 54.04725,
longitude => -2.79611,
},
user => {
email => 'org1@example.com',
password => 'abc123',
},
type => "organisation",
};
my $org2 = {
organisation => {
name => 'Test Org 2',
street_name => 'Test Street',
town => 'Lancaster',
postcode => 'LA1 1AG',
latitude => 54.04679,
longitude => -2.7963,
},
user => {
email => 'org2@example.com',
password => 'abc123',
},
type => "organisation",
};
my $admin = {
customer => {
full_name => 'Test Admin',
display_name => 'Test Admin',
postcode => 'LA1 1AH',
year_of_birth => 2006,
latitude => 54.05,
longitude => -2.80,
},
user => {
email => 'admin@example.com',
password => 'abc123',
is_admin => \"1",
},
type => "customer",
};
$schema->resultset('Entity')->create( $_ )
for (
$entity1,
$entity2,
$entity3,
$entity4,
$org1,
$org2,
$admin,
);
use Geo::UK::Postcode::CodePointOpen;
my $output_dir = 'etc/code-point-open/codepo_gb';
my $cpo = Geo::UK::Postcode::CodePointOpen->new( path => $output_dir );
my $iter = $cpo->read_iterator(
outcodes => ['LA1'],
include_lat_long => 1,
split_postcode => 1,
);
my $pc_rs = $schema->resultset('GbPostcode');
my $i = 1;
while ( my $pc = $iter->() ) {
$pc_rs->find_or_create(
{
outcode => $pc->{Outcode},
incode => $pc->{Incode},
latitude => $pc->{Latitude},
longitude => $pc->{Longitude},
},
{ key => 'primary' },
);
last if $i++ > 10
}
$iter = $cpo->read_iterator(
outcodes => ['LA2'],
include_lat_long => 1,
split_postcode => 1,
);
$i = 1;
while ( my $pc = $iter->() ) {
$pc_rs->find_or_create(
{
outcode => $pc->{Outcode},
incode => $pc->{Incode},
latitude => $pc->{Latitude},
longitude => $pc->{Longitude},
},
{ key => 'primary' },
);
last if $i++ > 10
}
my $data_set = 'full';
$fixtures->dump({
all => 1,
schema => $schema,
directory => "$Bin/../data/" . $data_set,
});

View File

@ -0,0 +1,65 @@
$VAR1 = {
'has_many' => {
'fetch' => 0
},
'sets' => [
{
'class' => 'OrganisationPayroll',
'quantity' => 'all'
},
{
'quantity' => 'all',
'class' => 'User'
},
{
'quantity' => 'all',
'class' => 'Customer'
},
{
'class' => 'Entity',
'quantity' => 'all'
},
{
'quantity' => 'all',
'class' => 'LeaderboardValue'
},
{
'quantity' => 'all',
'class' => 'Feedback'
},
{
'class' => 'Organisation',
'quantity' => 'all'
},
{
'class' => 'GbPostcode',
'quantity' => 'all'
},
{
'quantity' => 'all',
'class' => 'LeaderboardSet'
},
{
'quantity' => 'all',
'class' => 'AccountToken'
},
{
'quantity' => 'all',
'class' => 'SessionToken'
},
{
'quantity' => 'all',
'class' => 'Transaction'
},
{
'class' => 'Leaderboard',
'quantity' => 'all'
}
],
'belongs_to' => {
'fetch' => 0
},
'might_have' => {
'fetch' => 0
}
};

View File

@ -0,0 +1 @@
1.001039

View File

@ -0,0 +1,10 @@
$HASH1 = {
display_name => 'Test User1',
entity_id => 1,
full_name => 'Test User1',
id => 1,
latitude => 54.04,
longitude => -2.8,
postcode => 'LA1 1AA',
year_of_birth => 2006
};

View File

@ -0,0 +1,10 @@
$HASH1 = {
display_name => 'Test User2',
entity_id => 2,
full_name => 'Test User2',
id => 2,
latitude => 54.04,
longitude => -2.8,
postcode => 'LA1 1AB',
year_of_birth => 2006
};

View File

@ -0,0 +1,10 @@
$HASH1 = {
display_name => 'Test User3',
entity_id => 3,
full_name => 'Test User3',
id => 3,
latitude => 54.05,
longitude => -2.8,
postcode => 'LA1 1AD',
year_of_birth => 2006
};

View File

@ -0,0 +1,10 @@
$HASH1 = {
display_name => 'Test User4',
entity_id => 4,
full_name => 'Test User4',
id => 4,
latitude => 54.04,
longitude => -2.8,
postcode => 'LA1 1AE',
year_of_birth => 2006
};

View File

@ -0,0 +1,10 @@
$HASH1 = {
display_name => 'Test Admin',
entity_id => 7,
full_name => 'Test Admin',
id => 5,
latitude => 54.05,
longitude => -2.8,
postcode => 'LA1 1AH',
year_of_birth => 2006
};

View File

@ -0,0 +1,4 @@
$HASH1 = {
id => 1,
type => 'customer'
};

View File

@ -0,0 +1,4 @@
$HASH1 = {
id => 2,
type => 'customer'
};

View File

@ -0,0 +1,4 @@
$HASH1 = {
id => 3,
type => 'customer'
};

View File

@ -0,0 +1,4 @@
$HASH1 = {
id => 4,
type => 'customer'
};

View File

@ -0,0 +1,4 @@
$HASH1 = {
id => 5,
type => 'organisation'
};

View File

@ -0,0 +1,4 @@
$HASH1 = {
id => 6,
type => 'organisation'
};

View File

@ -0,0 +1,4 @@
$HASH1 = {
id => 7,
type => 'customer'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '1AA',
latitude => 54.04816,
longitude => -2.80382,
outcode => 'LA1'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '1AB',
latitude => 54.04795,
longitude => -2.80423,
outcode => 'LA1'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '1AD',
latitude => 54.05425,
longitude => -2.8071,
outcode => 'LA1'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '1AE',
latitude => 54.04697,
longitude => -2.80403,
outcode => 'LA1'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '1AF',
latitude => 54.04725,
longitude => -2.79611,
outcode => 'LA1'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '1AG',
latitude => 54.04679,
longitude => -2.7963,
outcode => 'LA1'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '1AH',
latitude => 54.05155,
longitude => -2.80299,
outcode => 'LA1'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '1AJ',
latitude => 54.04835,
longitude => -2.80416,
outcode => 'LA1'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '1AL',
latitude => 54.04807,
longitude => -2.80116,
outcode => 'LA1'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '1AN',
latitude => 54.04531,
longitude => -2.80106,
outcode => 'LA1'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '1AP',
latitude => 54.05399,
longitude => -2.80818,
outcode => 'LA1'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '0AA',
latitude => 54.02493,
longitude => -2.80717,
outcode => 'LA2'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '0AB',
latitude => 54.02412,
longitude => -2.81217,
outcode => 'LA2'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '0AD',
latitude => 54.02432,
longitude => -2.80635,
outcode => 'LA2'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '0AE',
latitude => 54.02851,
longitude => -2.82025,
outcode => 'LA2'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '0AG',
latitude => 54.02071,
longitude => -2.81721,
outcode => 'LA2'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '0AH',
latitude => 54.01159,
longitude => -2.81195,
outcode => 'LA2'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '0AJ',
latitude => 54.00774,
longitude => -2.82477,
outcode => 'LA2'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '0AN',
latitude => 53.99747,
longitude => -2.82742,
outcode => 'LA2'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '0AP',
latitude => 54.0107,
longitude => -2.79779,
outcode => 'LA2'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '0AQ',
latitude => 54.02042,
longitude => -2.80675,
outcode => 'LA2'
};

View File

@ -0,0 +1,6 @@
$HASH1 = {
incode => '0AR',
latitude => 53.99469,
longitude => -2.84932,
outcode => 'LA2'
};

View File

@ -0,0 +1,5 @@
$HASH1 = {
id => 1,
name => 'Daily Total',
type => 'daily_total'
};

View File

@ -0,0 +1,5 @@
$HASH1 = {
id => 2,
name => 'Daily Count',
type => 'daily_count'
};

View File

@ -0,0 +1,5 @@
$HASH1 = {
id => 3,
name => 'Weekly Total',
type => 'weekly_total'
};

View File

@ -0,0 +1,5 @@
$HASH1 = {
id => 4,
name => 'Weekly Count',
type => 'weekly_count'
};

View File

@ -0,0 +1,5 @@
$HASH1 = {
id => 5,
name => 'Monthly Total',
type => 'monthly_total'
};

View File

@ -0,0 +1,5 @@
$HASH1 = {
id => 6,
name => 'Monthly Count',
type => 'monthly_count'
};

View File

@ -0,0 +1,5 @@
$HASH1 = {
id => 7,
name => 'All Time Total',
type => 'all_time_total'
};

View File

@ -0,0 +1,5 @@
$HASH1 = {
id => 8,
name => 'All Time Count',
type => 'all_time_count'
};

View File

@ -0,0 +1,18 @@
$HASH1 = {
country => undef,
entity_id
=> 5,
id => 1,
latitude => 54.04725,
longitude
=> -2.79611,
name => 'Test Org',
pending => 0,
postcode => 'LA1 1AF',
sector => undef,
street_name
=> 'Test Street',
submitted_by_id
=> undef,
town => 'Lancaster'
};

View File

@ -0,0 +1,18 @@
$HASH1 = {
country => undef,
entity_id
=> 6,
id => 2,
latitude => 54.04679,
longitude
=> -2.7963,
name => 'Test Org 2',
pending => 0,
postcode => 'LA1 1AG',
sector => undef,
street_name
=> 'Test Street',
submitted_by_id
=> undef,
town => 'Lancaster'
};

View File

@ -0,0 +1,8 @@
$HASH1 = {
email => 'test1@example.com',
entity_id => 1,
id => 1,
is_admin => 0,
join_date => '2017-09-26 16:46:07',
password => '$2a$08$6CPa/BnjeTVEiYKxIyc2VeDn.5Feer6vSUZ1GnR7mMK.NOLulxeK6'
};

View File

@ -0,0 +1,8 @@
$HASH1 = {
email => 'test2@example.com',
entity_id => 2,
id => 2,
is_admin => 0,
join_date => '2017-09-26 16:46:07',
password => '$2a$08$vYQVGmZ3JHnRhHG63l/o2Op/iCvzE0C16lNGeuOoMuY5NOvFbKABC'
};

View File

@ -0,0 +1,8 @@
$HASH1 = {
email => 'test3@example.com',
entity_id => 3,
id => 3,
is_admin => 0,
join_date => '2017-09-26 16:46:07',
password => '$2a$08$TwGM55wGoR3RiiurPVhIYem4i4dm84ADWK1NHjDELApXSw2n9lloe'
};

View File

@ -0,0 +1,8 @@
$HASH1 = {
email => 'test4@example.com',
entity_id => 4,
id => 4,
is_admin => 0,
join_date => '2017-09-26 16:46:07',
password => '$2a$08$2dp0fMs/CWTQglOEOTCSduyXWrknO7XrfUmmUty1Uoy9ljCv6rR8e'
};

View File

@ -0,0 +1,8 @@
$HASH1 = {
email => 'org1@example.com',
entity_id => 5,
id => 5,
is_admin => 0,
join_date => '2017-09-26 16:46:07',
password => '$2a$08$f1OC7odxIXTtPN5EfXFdrO5/7QqzwVbqLpN6UOiV0nPW4tvETQEE2'
};

View File

@ -0,0 +1,8 @@
$HASH1 = {
email => 'org2@example.com',
entity_id => 6,
id => 6,
is_admin => 0,
join_date => '2017-09-26 16:46:07',
password => '$2a$08$PwazoBpY7oXR5lXgNL4Mv.givt1J6vuclDtxltJKlBHJL1xkOjXMy'
};

View File

@ -0,0 +1,8 @@
$HASH1 = {
email => 'admin@example.com',
entity_id => 7,
id => 7,
is_admin => 1,
join_date => '2017-09-26 16:46:07',
password => '$2a$08$PKmst2sVN6N1Qrp9i98GYuWW.mwVrOAktQYCP.ibu7eLDYVP3yja2'
};