[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[2989] trunk



Revision: 2989
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2989&view=rev
Author:   einhverfr
Date:     2010-04-19 17:15:32 +0000 (Mon, 19 Apr 2010)

Log Message:
-----------
Alexey's tests committed

Modified Paths:
--------------
    trunk/LedgerSMB/Sysconfig.pm
    trunk/t/63-lwp.t
    trunk/t/data/62-request-data

Modified: trunk/LedgerSMB/Sysconfig.pm
===================================================================
--- trunk/LedgerSMB/Sysconfig.pm	2010-04-15 20:53:06 UTC (rev 2988)
+++ trunk/LedgerSMB/Sysconfig.pm	2010-04-19 17:15:32 UTC (rev 2989)
@@ -179,6 +179,6 @@
 $ENV{PGHOST} = $config{database}{host};
 $ENV{PGPORT} = $config{database}{port};
 our $default_db = $config{database}{default_db};
-our $db_namespace = $config{database}{db_namespace};
+our $db_namespace = $config{database}{db_namespace} || 'public';
 $ENV{PGSSLMODE} = $config{database}{sslmode} if $config{database}{sslmode};
 1;

Modified: trunk/t/63-lwp.t
===================================================================
--- trunk/t/63-lwp.t	2010-04-15 20:53:06 UTC (rev 2988)
+++ trunk/t/63-lwp.t	2010-04-19 17:15:32 UTC (rev 2989)
@@ -31,12 +31,16 @@
 } else {
 	$hostport = "$hostname";
 }
+
+my $cookie = HTTP::Cookies->new;
 $browser->credentials("$hostport", 'LedgerSMB', $ENV{LSMB_USER} => $ENV{LSMB_PASS});
 
-# cookie setup
-my $cookie = HTTP::Cookies->new(
-	"$LedgerSMB::Sysconfig::cookie_name" => "1:1:$db"
-);
+my $login_url = "${host}login.pl?action=authenticate&company=$db";
+my $response = $browser->get($login_url);
+
+ok($response->is_success(), "Login cookie received");
+
+$cookie->extract_cookies($response);
 $browser->cookie_jar($cookie);
 
 for my $test (@$test_request_data){
@@ -44,6 +48,17 @@
 	my $argstr = "";
         my $module = "";
 	for $key (keys %$test){
+		# scan both key and value for _$GLOBAL$.
+		# replace _$GLOBAL$:varname with the value from the %GLOBAL{varname}
+		if ($key =~ /_\$GLOBAL\$:(.*)$/) {
+			my $newkey = $GLOBAL{$1};
+			$test->{$newkey} = $test->{$key};
+			$key = $newkey;
+		}
+		if ($test->{$key} =~ /_\$GLOBAL\$:(.*)$/) {
+			my $val = $GLOBAL{$1};
+			$test->{$key} = $val;
+		}
 		if ($key eq 'module'){
 			$module = $test->{"$key"}
 		}

Modified: trunk/t/data/62-request-data
===================================================================
--- trunk/t/data/62-request-data	2010-04-15 20:53:06 UTC (rev 2988)
+++ trunk/t/data/62-request-data	2010-04-19 17:15:32 UTC (rev 2989)
@@ -56,7 +56,7 @@
 	    "module"            => "vendor.pl",
 	    "action"            => "save",
 	    "pay_to_name"       => "TestEntity",
-	    "entity_id"         => $GLOBAL{"entity_id"},
+	    "entity_id"         => '_$GLOBAL$:entity_id',
 	    "control_code"      => "TestAddVendorObj",
 	    "ar_ap_account_id"  => 10,
 	    "cash_account_id"   => 1,
@@ -335,6 +335,87 @@
 					'eq', '105900.00', 'Printed amount is correct');
 	        },
 	},	
+	# the following 4 tests check that it is possible to remove an empty batch
+	{
+		# access the batch creation screen
+		"_test_id"		=> "AP Voucher Screen",
+		"_codebase"		=> "new",
+		"action"		=> "create_batch",
+		"module"		=> "vouchers.pl",
+		"batch_type"	=> "ap",
+		"company"		=> "test",
+		"_lwp_tests" 	=> sub {
+			my $res = shift;
+			delete $GLOBAL{form_id};
+			delete $GLOBAL{batch_no};
+			# save form_id and batch number for additional requests
+			$GLOBAL{"form_id"} = $1 if ($res->content =~ m/input type=hidden name="form_id" value="(\d+)"/);
+			ok($GLOBAL{form_id}, "Received form ID: ".$GLOBAL{form_id});
+			$GLOBAL{batch_no} = $1 if ($res->content =~ m/input name="batch_number" type="text" value="([A-Z]-\d+)"/);
+
+			return 1;
+		}
+	},
+	{
+		# create an empty batch
+		"_test_id"		=> "Create Empty Batch",
+		"_codebase"		=> "new",
+		"action"		=> "create_vouchers",
+		"module"		=> "vouchers.pl",
+		"batch_type"	=> "ap",
+		"batch_date"	=> '2010-12-30',
+		"batch_number"	=> '_$GLOBAL$:batch_no',
+		"description"	=> "foo",
+		"form_id"	=> '_$GLOBAL$:form_id',
+		"_lwp_tests"	=> sub {
+			my $res = shift;
+			like($res->content, qr/\<title\>Add AP Transaction.*\<\/title\>/, 'Empty batch added');
+			return 1;
+		}	
+	},
+	{
+		# get the list of batches and save the first row of the list in GLOBAL
+		"_test_id"		=> "List Empty Batches",
+		"_codebase"		=> "new",
+		"action"		=> "list_batches",
+		"empty"			=> 1,
+		"class_id"		=> 1,
+		"created_by_eid"	=> 0,
+		"module"		=> "vouchers.pl",
+		"_lwp_tests"	=> sub {
+			my $res = shift;
+			my $batch_no = $GLOBAL{batch_no};
+			my $batch_id;
+
+			delete @GLOBAL{ qw( form_id row_1 )};
+			$GLOBAL{"form_id"} = $1 if ($res->content =~ m/input id="form-id" type="hidden" name="form_id" value="(\d+)"\s+\/\>/);
+			$batch_id = $1 if ($res->content =~ m/\<a href="vouchers.pl\?action=get_batch&amp;batch_id=(\d+)"\>$batch_no\<\/a\>/);			
+			$GLOBAL{"row_1"} = $batch_id if ($res->content =~ m/<input id="batch-${batch_id}" type="checkbox" name="batch_${batch_id}" value="\d"\s+\/\>/);
+			$GLOBAL{batch_id} = "batch_".$batch_id;
+
+			ok(exists $GLOBAL{"row_1"}, 'Received correct batch ID '.$GLOBAL{row_1});
+			return 1;
+		},
+	},
+	{
+		# remove first row of the list of empty batches (obtained from GLOBAL)
+		"_test_id"		=> "Remove Empty Batches",
+		"_codebase"		=> "new",
+		"module"		=> "vouchers.pl",
+		"form_id"		=> '_$GLOBAL$:form_id',
+		"rowcount"		=> 1,
+		"empty"			=> 1,
+		"class_id"		=> 1,
+		"row_1"			=> '_$GLOBAL$:row_1',
+		"action"		=> "list_batches_batch_delete",
+		'_$GLOBAL$:batch_id' => 1,
+		"_lwp_tests"	=> sub {
+			my $res = shift;
+			# check that we are at the 'batch selection' page,
+			like($res->content, qr/\<title\>Batch Selection\<\/title\>/, "Empty batch removed");
+			return 1;
+		}
+	},
 ];
 
 our $api_test_cases = {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.