Index: openacs-4/packages/acs-lang/tcl/test/lang-catalog-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/test/lang-catalog-procs.tcl,v diff -u -r1.1.2.1 -r1.1.2.2 --- openacs-4/packages/acs-lang/tcl/test/lang-catalog-procs.tcl 8 Feb 2023 12:54:48 -0000 1.1.2.1 +++ openacs-4/packages/acs-lang/tcl/test/lang-catalog-procs.tcl 8 Feb 2023 13:49:00 -0000 1.1.2.2 @@ -9,6 +9,11 @@ -procs { lang::catalog::export lang::catalog::import + lang::catalog::package_delete + lang::message::cache + lang::message::message_exists_p + lang::message::update_description + lang::audit::changed_message } \ test_catalog_import_export { @@ -31,16 +36,110 @@ $catalog_mtime < [file mtime $catalog_path] } + set n_messages [db_string count { + select count(*) from lang_messages + where package_key = 'acs-lang' and locale = 'en_US' + }] + + db_1row get_one_message { + select message_key, message + from lang_messages + where package_key = 'acs-lang' + and locale = 'en_US' + fetch first 1 rows only + } + set key acs-lang.${message_key} + + aa_true "Message key '$message_key' exists" \ + [lang::message::message_exists_p -varname exist_var en_US $key] + aa_equals "Message key '$message_key' was retrieved" $exist_var $message + + set old_description [db_string desc { + select description from lang_message_keys + where message_key = :message_key + and package_key = 'acs-lang' + }] + + aa_log "Update description for '$key'" + lang::message::update_description \ + -package_key acs-lang \ + -message_key $message_key \ + -description {Test Description} + + aa_equals "Description was updated" \ + [db_string desc { + select description from lang_message_keys + where message_key = :message_key + and package_key = 'acs-lang' + }] \ + {Test Description} + + aa_log "Reset description for '$key'" + lang::message::update_description \ + -package_key acs-lang \ + -message_key $key \ + -description $old_description + + aa_log "Store an audit message for '$key'" + lang::audit::changed_message \ + $message \ + acs-lang \ + $message_key \ + en_US \ + {Audit Comment} \ + false \ + [dt_systime] \ + false \ + "no_upgrade" + + db_1row get_audit { + select audit_id, comment_text, overwrite_user + from lang_messages_audit + order by audit_id desc + fetch first 1 rows only + } + aa_equals "The comment text was stored" $comment_text {Audit Comment} + aa_equals "The comment user is us" $overwrite_user [ad_conn user_id] + + aa_log "Cleanup test audit message" + db_dml cleanup {delete from lang_messages_audit where audit_id = :audit_id} + set result [lang::catalog::import \ -package_key acs-lang -locales en_US] aa_equals "All keys for this package and locale have been processed" \ [dict get $result processed] \ - [db_string q { - select count(*) from lang_messages - where package_key = 'acs-lang' and locale = 'en_US' - }] - aa_equals "No keys added" [dict get $result added] 0 + $n_messages + aa_equals "All keys added" [dict get $result added] 0 aa_equals "No keys deleted" [dict get $result deleted] 0 aa_equals "No keys updated" [dict get $result updated] 0 + + aa_log "Delete all message keys and reload them" + lang::catalog::package_delete -package_key acs-lang + + aa_equals "There are no messages for this package anymore" \ + [db_string count { + select count(*) from lang_message_keys + where package_key = 'acs-lang' + }] \ + 0 + + unset -nocomplain exist_var + aa_false "Message key '$message_key' does not exist" \ + [lang::message::message_exists_p -varname exist_var en_US $key] + aa_false "Message key '$message_key' was not retrieved" [info exists exist_var] + + set result [lang::catalog::import \ + -package_key acs-lang -locales en_US] + + aa_equals "All keys for this package and locale have been processed" \ + [dict get $result processed] \ + $n_messages + aa_equals "No keys added" [dict get $result added] $n_messages + aa_equals "No keys deleted" [dict get $result deleted] 0 + aa_equals "No keys updated" [dict get $result updated] 0 + + aa_true "Message key '$message_key' exists" \ + [lang::message::message_exists_p -varname exist_var en_US $key] + aa_equals "Message key '$message_key' was retrieved" $exist_var $message }