add missing collateral from previous commit, add more tests for import

This commit is contained in:
Colin Kuskie 2008-06-07 22:35:55 +00:00
parent 0316b74ecd
commit 112da861ca
3 changed files with 83 additions and 4 deletions

View file

@ -33,7 +33,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
my $tests = 36;
my $tests = 41;
plan tests => 1 + $tests;
#----------------------------------------------------------------------------
@ -225,15 +225,15 @@ SKIP: {
#######################################################################
#
# export, part 2
# import, part 2
#
#######################################################################
my $pass = WebGUI::Shop::Products::importProducts(
$pass = WebGUI::Shop::Products::importProducts(
$session,
WebGUI::Test->getTestCollateralPath('productTables/secondProductTable.csv'),
);
ok($pass, 'Products imported');
ok($pass, 'Products imported for the second time');
my $count = $session->db->quickScalar('select count(*) from Product');
is($count, 3, 'three products were imported');
@ -298,6 +298,73 @@ SKIP: {
'collateral set correctly for classical record'
);
#######################################################################
#
# import, part 3
#
#######################################################################
$pass = WebGUI::Shop::Products::importProducts(
$session,
WebGUI::Test->getTestCollateralPath('productTables/thirdProductTable.csv'),
);
ok($pass, 'Products imported for the third time');
my $count = $session->db->quickScalar('select count(*) from Product');
is($count, 3, 'still have 3 products, nothing new added');
my $soda = WebGUI::Asset::Sku->newBySku($session, 'soda');
is($soda->getTitle(), 'Sweet Soda-totally organic', 'Title updated correctly for soda');
$shirt = WebGUI::Asset::Sku->newBySku($session, 't-shirt');
my $shirtCollateral = $shirt->getAllCollateral('variantsJSON');
cmp_deeply(
$shirtCollateral,
[
{
sku => 'red-t-shirt',
shortdesc => 'Red T-Shirt',
price => '5.00',
weight => '1.33',
quantity => '500',
variantId => ignore(),
},
{
sku => 'blue-t-shirt',
shortdesc => 'Blue T-Shirt',
price => '5.25',
weight => '1.33',
quantity => '2000',
variantId => ignore(),
},
],
'collateral updated correctly for shirt'
);
my $record = WebGUI::Asset::Sku->newBySku($session, 'classical-records-1');
my $recordCollateral = $record->getAllCollateral('variantsJSON');
cmp_deeply(
$recordCollateral,
[
{
sku => 'track-16',
shortdesc => 'Track 16',
price => '3.25',
weight => '0.00',
quantity => 50,
variantId => ignore(),
},
{
sku => 'track-9',
shortdesc => 'Track 9',
price => '3.25',
weight => '0.00',
quantity => 55,
variantId => ignore(),
},
],
'collateral added correctly for classical record'
);
}

View file

@ -0,0 +1,7 @@
mastersku,sku,title,shortdescription,price,weight,quantity
##alter existing with two collateral
t-shirt,red-t-shirt,Colored T-Shirts,Red T-Shirt,5.00,1.33,500
##alter existing with one collateral
soda,soda-sweet,Sweet Soda-bottled in Oregon,Sweet Soda,1.00,0.85,500
##add a new one
classical-records-1,track-16,The Marriage of Figaro,Track 16,3.25,0.00,50
1 mastersku,sku,title,shortdescription,price,weight,quantity
2 ##alter existing with two collateral
3 t-shirt,red-t-shirt,Colored T-Shirts,Red T-Shirt,5.00,1.33,500
4 ##alter existing with one collateral
5 soda,soda-sweet,Sweet Soda-bottled in Oregon,Sweet Soda,1.00,0.85,500
6 ##add a new one
7 classical-records-1,track-16,The Marriage of Figaro,Track 16,3.25,0.00,50

View file

@ -0,0 +1,5 @@
mastersku,sku,title,shortdescription,price,weight,quantity
##alter a title
soda,soda-sweet,Sweet Soda-totally organic,Sweet Soda,1.00,0.85,500
##add new collateral to an existing product
classical-records-1,track-9,The Marriage of Figaro,Track 9,3.25,0.00,55
1 mastersku,sku,title,shortdescription,price,weight,quantity
2 ##alter a title
3 soda,soda-sweet,Sweet Soda-totally organic,Sweet Soda,1.00,0.85,500
4 ##add new collateral to an existing product
5 classical-records-1,track-9,The Marriage of Figaro,Track 9,3.25,0.00,55