| |
|
1 |
# packages/soap-db/tcl/test/soap-db-procs.tcl |
| |
|
2 |
|
| |
|
3 |
ad_library { |
| |
|
4 |
|
| |
|
5 |
Test cases for DB SOAP |
| |
|
6 |
|
| |
|
7 |
@author Derick Leony (derickleony@galileo.edu) |
| |
|
8 |
@creation-date 2006-02-09 |
| |
|
9 |
@arch-tag: 9d4f6a74-baf3-456a-8abb-9a7481dbece9 |
| |
|
10 |
@cvs-id $Id$ |
| |
|
11 |
} |
| |
|
12 |
|
| |
|
13 |
|
| |
|
14 |
aa_register_case \ |
| |
|
15 |
-cats {smoke api production_safe} \ |
| |
|
16 |
-procs {soap_db::db_string} \ |
| |
|
17 |
soap_db_string \ |
| |
|
18 |
{ |
| |
|
19 |
A simple test that compares date and name gotten with SOAP DB API. |
| |
|
20 |
} { |
| |
|
21 |
|
| |
|
22 |
set date_db [db_string -dbn udb get_date "select sysdate from dual"] |
| |
|
23 |
set carnets [db_list -dbn udb get_carnets "select carnet from caalumnostb"] |
| |
|
24 |
set carnet [lindex $carnets [expr "round(floor(rand() * [llength $carnets]))"]] |
| |
|
25 |
set name_db [db_string -dbn udb get_date "select nombre1||' '||nombre2||' '||apellido1||' '||apellido2 from caalumnostb where carnet = :carnet"] |
| |
|
26 |
|
| |
|
27 |
aa_run_with_teardown \ |
| |
|
28 |
-test_code { |
| |
|
29 |
|
| |
|
30 |
# date test test |
| |
|
31 |
aa_log "Testing date to be $date_db" |
| |
|
32 |
set date_soap [soap_db::db_string -dbn udb get_date "select sysdate from dual"] |
| |
|
33 |
aa_true "Date obtained successfully." [string eq $date_db $date_soap] |
| |
|
34 |
|
| |
|
35 |
aa_log "Testing name of carnet $carnet to be $name_db" |
| |
|
36 |
set name_soap [soap_db::db_string -dbn udb get_date \ |
| |
|
37 |
"select nombre1||' '||nombre2||' '||apellido1||' '||apellido2 from caalumnostb where carnet = '$carnet'"] |
| |
|
38 |
aa_true "Name obtained successfully." [string eq $name_db $name_soap] |
| |
|
39 |
|
| |
|
40 |
} |
| |
|
41 |
} |
| |
|
42 |
|
| |
|
43 |
aa_register_case \ |
| |
|
44 |
-cats {smoke api production_safe} \ |
| |
|
45 |
-procs {soap_db::db_0or1row} \ |
| |
|
46 |
soap_db_0or1row \ |
| |
|
47 |
{ |
| |
|
48 |
A simple test that compares date and name gotten with db_0or1row from SOAP DB API. |
| |
|
49 |
} { |
| |
|
50 |
|
| |
|
51 |
set date_db [db_string -dbn udb get_date "select sysdate from dual"] |
| |
|
52 |
set carnets [db_list -dbn udb get_carnets "select carnet from caalumnostb"] |
| |
|
53 |
set carnet [lindex $carnets [expr "round(floor(rand() * [llength $carnets]))"]] |
| |
|
54 |
db_0or1row -dbn udb get_date "select nombre1 as n1d, nombre2 as n2d, apellido1 as a1d, apellido2 as a2d from caalumnostb where carnet = :carnet" |
| |
|
55 |
set random_string [ad_generate_random_string] |
| |
|
56 |
set unchanged $random_string |
| |
|
57 |
|
| |
|
58 |
aa_run_with_teardown \ |
| |
|
59 |
-test_code { |
| |
|
60 |
|
| |
|
61 |
# date test test |
| |
|
62 |
aa_log "Testing date to be $date_db" |
| |
|
63 |
set date_result [soap_db::db_0or1row -dbn udb get_date "select sysdate as date_soap from dual"] |
| |
|
64 |
aa_true "Date query returned 1." $date_result |
| |
|
65 |
aa_true "Date obtained successfully." [string eq $date_db $date_soap] |
| |
|
66 |
|
| |
|
67 |
aa_log "Testing name of carnet $carnet: $n1d $n2d $a1d $a2d" |
| |
|
68 |
set name_result [soap_db::db_0or1row -dbn udb get_date \ |
| |
|
69 |
"select nombre1 as n1s, nombre2 as n2s, apellido1 as a1s, apellido2 as a2s from caalumnostb where carnet = '$carnet'"] |
| |
|
70 |
aa_true "Name query returned 1" $name_result |
| |
|
71 |
aa_true "nombre1 obtained successfully." [string eq $n1d $n1s] |
| |
|
72 |
aa_true "nombre2 obtained successfully." [string eq $n2d $n2s] |
| |
|
73 |
aa_true "apellido1 obtained successfully." [string eq $a1d $a1s] |
| |
|
74 |
aa_true "apellido2 obtained successfully." [string eq $a2d $a2s] |
| |
|
75 |
|
| |
|
76 |
set no_result [soap_db::db_0or1row -dbn udb get_no_data "select sysdate as nonexsistant, sysdate as unchanged from dual where 1=0"] |
| |
|
77 |
aa_false "No rows query returned 0." $no_result |
| |
|
78 |
aa_false "No rows query didn't create a non existant variable." [info exists nonexistant] |
| |
|
79 |
aa_true "No rows query didn't change initial value of a variable." [string eq $random_string $unchanged] |
| |
|
80 |
|
| |
|
81 |
} |
| |
|
82 |
} |
| |
|
83 |
|
| |
|
84 |
aa_register_case \ |
| |
|
85 |
-cats {smoke api production_safe} \ |
| |
|
86 |
-procs {soap_db::db_multirow} \ |
| |
|
87 |
soap_db_multirow \ |
| |
|
88 |
{ |
| |
|
89 |
A simple test that compares multirows obtained from SOAP DB API. |
| |
|
90 |
} { |
| |
|
91 |
|
| |
|
92 |
set carnets [db_list -dbn udb get_carnets "select carnet from caalumnostb"] |
| |
|
93 |
set carnet [lindex $carnets [expr "round(floor(rand() * [llength $carnets]))"]] |
| |
|
94 |
|
| |
|
95 |
db_multirow -dbn udb -extend {extra} mrd get_carrs "select carrera, pensum from caalumcarrstb where carnet = '$carnet'" { |
| |
|
96 |
set extra "$carrera||$pensum" |
| |
|
97 |
} |
| |
|
98 |
|
| |
|
99 |
aa_run_with_teardown \ |
| |
|
100 |
-test_code { |
| |
|
101 |
|
| |
|
102 |
# get multirow from SOAP DB |
| |
|
103 |
aa_log "Creating multirow." |
| |
|
104 |
soap_db::db_multirow -dbn udb -extend {extra} mrs get_carrs "select carrera, pensum from caalumcarrstb where carnet = '$carnet'" { |
| |
|
105 |
set extra "$carrera||$pensum" |
| |
|
106 |
} |
| |
|
107 |
|
| |
|
108 |
# review multirow values |
| |
|
109 |
aa_true "Multirow rowcount matches." [expr [template::multirow size mrs]==[template::multirow size mrd]] |
| |
|
110 |
aa_true "Multirow columns matches." [string eq [template::multirow columns mrs] [template::multirow columns mrd]] |
| |
|
111 |
|
| |
|
112 |
if {[template::multirow size mrs]} { |
| |
|
113 |
set row 1 |
| |
|
114 |
template::multirow foreach mrs { |
| |
|
115 |
aa_true "Carrera $carrera matches" [string eq $carrera [template::multirow get mrd $row carrera]] |
| |
|
116 |
aa_true "Pensum $pensum matches" [string eq $pensum [template::multirow get mrd $row pensum]] |
| |
|
117 |
aa_true "Extended $extra matches" [string eq $extra [template::multirow get mrd $row extra]] |
| |
|
118 |
incr row |
| |
|
119 |
} |
| |
|
120 |
} else { |
| |
|
121 |
aa_log "Multirow is empty." |
| |
|
122 |
} |
| |
|
123 |
|
| |
|
124 |
} |
| |
|
125 |
} |
| |
|
126 |
|