Fixed texts now with strict# Please enter the commit message for your changes. Lines starting

This commit is contained in:
piratefinn 2017-04-20 18:15:34 +01:00
parent d732eef5a3
commit 2ea55daf33
5 changed files with 36 additions and 31 deletions

View file

@ -1,3 +1,4 @@
use Mojo::Base -strict;
use Test::More; use Test::More;
use Test::Mojo; use Test::Mojo;
use Mojo::JSON; use Mojo::JSON;
@ -19,7 +20,7 @@ for (split ';', $sqlDeployment){
$dbh->do($_) or die $dbh->errstr; $dbh->do($_) or die $dbh->errstr;
} }
my $sqlDeployment = Mojo::File->new("$FindBin::Bin/../schema.sql")->slurp; $sqlDeployment = Mojo::File->new("$FindBin::Bin/../schema.sql")->slurp;
for (split ';', $sqlDeployment){ for (split ';', $sqlDeployment){
$dbh->do($_) or die $dbh->errstr; $dbh->do($_) or die $dbh->errstr;
} }
@ -53,7 +54,7 @@ $t->post_ok('/api/register' => json => $testJson)
print "test 2 - Create organisation user account (Choco Billy)\n"; print "test 2 - Create organisation user account (Choco Billy)\n";
my $emailBilly = 'choco.billy@chocofarm.org'; my $emailBilly = 'choco.billy@chocofarm.org';
my $passwordBilly = 'Choco'; my $passwordBilly = 'Choco';
my $testJson = { $testJson = {
'usertype' => 'organisation', 'usertype' => 'organisation',
'token' => shift(@accountTokens), 'token' => shift(@accountTokens),
'username' => 'ChocoBillysGreens', 'username' => 'ChocoBillysGreens',
@ -70,7 +71,7 @@ $t->post_ok('/api/register' => json => $testJson)
print "test 3 - Create admin account\n"; print "test 3 - Create admin account\n";
my $emailAdmin = 'admin@foodloop.net'; my $emailAdmin = 'admin@foodloop.net';
my $passwordAdmin = 'ethics'; my $passwordAdmin = 'ethics';
my $testJson = { $testJson = {
'usertype' => 'customer', 'usertype' => 'customer',
'token' => shift(@accountTokens), 'token' => shift(@accountTokens),
'username' => 'admin', 'username' => 'admin',
@ -112,7 +113,7 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions",
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Organisations", undef, ())}[0],1,"1 verified organisation (choco billy)" ; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Organisations", undef, ())}[0],1,"1 verified organisation (choco billy)" ;
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],0,"No verified transactions." ; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],0,"No verified transactions." ;
my $nameToTestTurtle = 'Turtle\'s Paradise'; my $nameToTestTurtle = 'Turtle\'s Paradise';
$json = { my $json = {
transaction_value => 20, transaction_value => 20,
transaction_type => 3, transaction_type => 3,
organisation_name => $nameToTestTurtle, organisation_name => $nameToTestTurtle,
@ -180,7 +181,7 @@ $json = {
postcode => "NW11 7GZ", postcode => "NW11 7GZ",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -200,7 +201,7 @@ $json = {
organisation_id => $newPendingKalmOrgId, organisation_id => $newPendingKalmOrgId,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -220,7 +221,7 @@ $json = {
postcode => "NW1W 7GF", postcode => "NW1W 7GF",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload) $t->post_ok('/api/upload' => form => $upload)
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -241,7 +242,7 @@ $json = {
organisation_id => $newPendingJunonOrgId, organisation_id => $newPendingJunonOrgId,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true) ->json_is('/success', Mojo::JSON->true)
@ -259,7 +260,7 @@ $json = {
organisation_id => $newPendingJunonOrgId, organisation_id => $newPendingJunonOrgId,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true) ->json_is('/success', Mojo::JSON->true)
@ -301,7 +302,7 @@ $t->post_ok('/api/login' => json => $testJson)
$session_key = $t->tx->res->json('/session_key'); $session_key = $t->tx->res->json('/session_key');
print "test 18 - JSON is missing.\n"; print "test 18 - JSON is missing.\n";
$t->post_ok('/api/admin-approve' => json) $t->post_ok('/api/admin-approve' => json => {})
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->json_like('/message', qr/JSON is missing/i); ->json_like('/message', qr/JSON is missing/i);
@ -383,7 +384,7 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Organisations WHERE N
print "test 24 - valid approval (modify some).\n"; print "test 24 - valid approval (modify some).\n";
#TODO if we implement constraints on the input data this will fail #TODO if we implement constraints on the input data this will fail
my $testName = "Change testing junon name"; $testName = "Change testing junon name";
$json = { $json = {
unvalidatedOrganisationId => $newPendingJunonOrgId, unvalidatedOrganisationId => $newPendingJunonOrgId,
name => $testName, name => $testName,

View file

@ -1,3 +1,4 @@
use Mojo::Base -strict;
use Test::More; use Test::More;
use Test::Mojo; use Test::Mojo;
use Mojo::JSON; use Mojo::JSON;
@ -19,7 +20,7 @@ for (split ';', $sqlDeployment){
$dbh->do($_) or die $dbh->errstr; $dbh->do($_) or die $dbh->errstr;
} }
my $sqlDeployment = Mojo::File->new("$FindBin::Bin/../schema.sql")->slurp; $sqlDeployment = Mojo::File->new("$FindBin::Bin/../schema.sql")->slurp;
for (split ';', $sqlDeployment){ for (split ';', $sqlDeployment){
$dbh->do($_) or die $dbh->errstr; $dbh->do($_) or die $dbh->errstr;
} }
@ -53,7 +54,7 @@ $t->post_ok('/api/register' => json => $testJson)
print "test 2 - Create organisation user account (Choco Billy)\n"; print "test 2 - Create organisation user account (Choco Billy)\n";
my $emailBilly = 'choco.billy@chocofarm.org'; my $emailBilly = 'choco.billy@chocofarm.org';
my $passwordBilly = 'Choco'; my $passwordBilly = 'Choco';
my $testJson = { $testJson = {
'usertype' => 'organisation', 'usertype' => 'organisation',
'token' => shift(@accountTokens), 'token' => shift(@accountTokens),
'username' => 'ChocoBillysGreens', 'username' => 'ChocoBillysGreens',
@ -70,7 +71,7 @@ $t->post_ok('/api/register' => json => $testJson)
print "test 3 - Create admin account\n"; print "test 3 - Create admin account\n";
my $emailAdmin = 'admin@foodloop.net'; my $emailAdmin = 'admin@foodloop.net';
my $passwordAdmin = 'ethics'; my $passwordAdmin = 'ethics';
my $testJson = { $testJson = {
'usertype' => 'customer', 'usertype' => 'customer',
'token' => shift(@accountTokens), 'token' => shift(@accountTokens),
'username' => 'admin', 'username' => 'admin',
@ -110,7 +111,7 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions",
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Organisations", undef, ())}[0],1,"1 verified organisation (choco billy)" ; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Organisations", undef, ())}[0],1,"1 verified organisation (choco billy)" ;
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],0,"No verified transactions." ; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],0,"No verified transactions." ;
my $nameToTestTurtle = 'Turtle\'s Paradise'; my $nameToTestTurtle = 'Turtle\'s Paradise';
$json = { my $json = {
transaction_value => 20, transaction_value => 20,
transaction_type => 3, transaction_type => 3,
organisation_name => $nameToTestTurtle, organisation_name => $nameToTestTurtle,
@ -169,7 +170,7 @@ $json = {
postcode => "", postcode => "",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -192,7 +193,7 @@ $json = {
organisation_id => $newPendingTurtleOrgIdPartial, organisation_id => $newPendingTurtleOrgIdPartial,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -213,7 +214,7 @@ $json = {
postcode => "NW9 5EB", postcode => "NW9 5EB",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload) $t->post_ok('/api/upload' => form => $upload)
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -234,7 +235,7 @@ $json = {
organisation_id => $newPendingJunonOrgId, organisation_id => $newPendingJunonOrgId,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -251,7 +252,7 @@ $json = {
organisation_id => $newPendingJunonOrgId, organisation_id => $newPendingJunonOrgId,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -287,7 +288,7 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingOrganisations"
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions", undef, ())}[0],6,"6 unverified transactions." ; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions", undef, ())}[0],6,"6 unverified transactions." ;
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Organisations", undef, ())}[0],1,"1 verified organisation (choco billy)" ; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Organisations", undef, ())}[0],1,"1 verified organisation (choco billy)" ;
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],0,"No verified transactions."; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],0,"No verified transactions.";
my $json = { $json = {
unvalidatedOrganisationId => $newPendingTurtleOrgId, unvalidatedOrganisationId => $newPendingTurtleOrgId,
session_key => $session_key, session_key => $session_key,
}; };
@ -355,7 +356,7 @@ $t->post_ok('/api/login' => json => $testJson)
$session_key = $t->tx->res->json('/session_key'); $session_key = $t->tx->res->json('/session_key');
print "test 22 - JSON is missing.\n"; print "test 22 - JSON is missing.\n";
$t->post_ok('/api/admin-merge' => json) $t->post_ok('/api/admin-merge' => json => {})
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->json_like('/message', qr/JSON is missing/); ->json_like('/message', qr/JSON is missing/);

View file

@ -1,3 +1,4 @@
use Mojo::Base -strict;
use Test::More; use Test::More;
use Test::Mojo; use Test::Mojo;

View file

@ -1,3 +1,4 @@
use Mojo::Base -strict;
use Test::More; use Test::More;
use Test::Mojo; use Test::Mojo;
use Mojo::JSON; use Mojo::JSON;
@ -21,7 +22,7 @@ for (split ';', $sqlDeployment){
$dbh->do($_) or die $dbh->errstr; $dbh->do($_) or die $dbh->errstr;
} }
my $sqlDeployment = Mojo::File->new("$FindBin::Bin/../schema.sql")->slurp; $sqlDeployment = Mojo::File->new("$FindBin::Bin/../schema.sql")->slurp;
for (split ';', $sqlDeployment){ for (split ';', $sqlDeployment){
$dbh->do($_) or die $dbh->errstr; $dbh->do($_) or die $dbh->errstr;
} }
@ -40,19 +41,19 @@ my ($name, $address, $postcode) = ("Avanti Bar & Restaurant","57 Main St, Kirkby
$statement->execute($value, $name, $address, $postcode); $statement->execute($value, $name, $address, $postcode);
$value++; $value++;
my ($name, $address, $postcode) = ("Full House Noodle Bar","21 Common Garden St, Lancaster, Lancashire","LA1 1XD"); ($name, $address, $postcode) = ("Full House Noodle Bar","21 Common Garden St, Lancaster, Lancashire","LA1 1XD");
$statement->execute($value, $name, $address, $postcode); $statement->execute($value, $name, $address, $postcode);
$value++; $value++;
my ($name, $address, $postcode) = ("The Quay's Fishbar","1 Adcliffe Rd, Lancaster","LA1 1SS"); ($name, $address, $postcode) = ("The Quay's Fishbar","1 Adcliffe Rd, Lancaster","LA1 1SS");
$statement->execute($value, $name, $address, $postcode); $statement->execute($value, $name, $address, $postcode);
$value++; $value++;
my ($name, $address, $postcode) = ("Dan's Fishop","56 North Rd, Lancaster","LA1 1LT"); ($name, $address, $postcode) = ("Dan's Fishop","56 North Rd, Lancaster","LA1 1LT");
$statement->execute($value, $name, $address, $postcode); $statement->execute($value, $name, $address, $postcode);
$value++; $value++;
my ($name, $address, $postcode) = ("Hodgeson's Chippy","96 Prospect St, Lancaster","LA1 3BH"); ($name, $address, $postcode) = ("Hodgeson's Chippy","96 Prospect St, Lancaster","LA1 3BH");
$statement->execute($value, $name, $address, $postcode); $statement->execute($value, $name, $address, $postcode);
@ -79,7 +80,7 @@ $t->post_ok('/api/register' => json => $testJson)
print "test 2 - Create organisation user account (Choco Billy)\n"; print "test 2 - Create organisation user account (Choco Billy)\n";
my $emailBilly = 'choco.billy@chocofarm.org'; my $emailBilly = 'choco.billy@chocofarm.org';
my $passwordBilly = 'Choco'; my $passwordBilly = 'Choco';
my $testJson = { $testJson = {
'usertype' => 'organisation', 'usertype' => 'organisation',
'token' => shift(@accountTokens), 'token' => shift(@accountTokens),
'username' => 'ChocoBillysGreens', 'username' => 'ChocoBillysGreens',
@ -131,7 +132,7 @@ print "test 3 - Login - Rufus (cookies, customer)\n";
login_rufus(); login_rufus();
print "test 4 - Added something containing 'fish'\n"; print "test 4 - Added something containing 'fish'\n";
$json = { my $json = {
transaction_value => 10, transaction_value => 10,
transaction_type => 3, transaction_type => 3,
organisation_name => 'Shoreway Fisheries', organisation_name => 'Shoreway Fisheries',
@ -167,7 +168,7 @@ $json = {
postcode => "LA4 5BZ", postcode => "LA4 5BZ",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -182,7 +183,7 @@ $json = {
postcode => "LA1 1ET", postcode => "LA1 1ET",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);

View file

@ -1,3 +1,4 @@
use Mojo::Base -strict;
use Test::More skip_all => 'User History needs reworking'; use Test::More skip_all => 'User History needs reworking';
use Test::Mojo; use Test::Mojo;
use Mojo::JSON qw(encode_json);; use Mojo::JSON qw(encode_json);;