Index: openacs-4/packages/acs-tcl/tcl/test/apm-parameter-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/apm-parameter-test-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-tcl/tcl/test/apm-parameter-test-procs.tcl 14 Aug 2006 14:40:36 -0000 1.1 @@ -0,0 +1,37 @@ +ad_library { + Testing for parameter registration + @author Adrian Catalan (ykro@galileo.edu) + @creation-date 2006-08-10 +} + +aa_register_case -cats {api smoke} parameter_register_test { + Test the registration of a parameter +} { + set parameter_id [db_nextval "acs_object_id_seq"] + set parameter_name "New Parameter [ad_generate_random_string]" + set description "Description for the new parameter" + set package_key "acs-tcl" + set default_value "5" + set datatype "number" + aa_log "Registering a parameter" + apm_parameter_register -parameter_id $parameter_id $parameter_name $description $package_key $default_value $datatype + + set package_id [apm_package_id_from_key $package_key] + aa_true "check apm_parameter_register" [string equal [parameter::get -package_id $package_id -parameter $parameter_name] $default_value] +} + +aa_register_case -cats {api smoke} parameter_unregister_test { + Test the unregister of a parameter +} { + set parameter_id [db_nextval "acs_object_id_seq"] + set parameter_name "New Parameter [ad_generate_random_string]" + set description "Description for the new parameter" + set package_key "acs-tcl" + set default_value "10" + set datatype "number" + aa_log "Registering a parameter" + apm_parameter_register -parameter_id $parameter_id $parameter_name $description $package_key $default_value $datatype + apm_parameter_unregister $parameter_id + set package_id [apm_package_id_from_key $package_key] + aa_true "check apm_parameter_unregister" [string equal [parameter::get -package_id $package_id -parameter $parameter_name] ""] +} \ No newline at end of file Index: openacs-4/packages/acs-tcl/tcl/test/memoizing-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/memoizing-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-tcl/tcl/test/memoizing-procs.tcl 14 Aug 2006 14:40:36 -0000 1.1 @@ -0,0 +1,53 @@ +ad_library { + automated-testing for memoizing procs + + @author Adrian Catalan (ykro@galileo.edu) + @creation-date 2006-07-28 +} + +namespace eval memoizing_procs_test {} + +ad_proc -private memoizing_procs_test::return_name { + {-name:required} +} { + Test proc that returns a string +} { + set response "This is a test for " + append response $name + return $response +} + +ad_proc -private memoizing_procs_test::return_upper_case_text { + {-txt:required} +} { + Test proc that returns a string in upper case +} { + set response $txt + append response " in upper case is " + append response [string toupper $txt] + return $response +} + +aa_register_case -cats {api smoke} ad_proc_cache { + Test cache of a proc executed before +} { + aa_log "caching a proc" + util_memoize {memoizing_procs_test::return_string -name "foobar"} + aa_log "checking if the proc is cached" + set success_p [util_memoize_cached_p {memoizing_procs_test::return_string -name "foobar"}] + + aa_equals "proc was cached succesful" $success_p 1 +} + +aa_register_case -cats {api smoke} ad_proc_flush { + Test flush of a proc cached +} { + aa_log "caching" + util_memoize {memoizing_procs_test::return_string -name "foobar"} + aa_log "checking if the proc is cached" + aa_log "flushing" + util_memoize_flush_regexp {return_upper_case_text} + set success_p [util_memoize_cached_p {memoizing_procs_test::return_upper_case_text -txt "foobar"}] + aa_equals "proc was flushed succesful" $success_p 0 +} +