Index: openacs-4/etc/install/dotlrn-basic-setup.test =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/dotlrn-basic-setup.test,v diff -u -N -r1.6 -r1.7 --- openacs-4/etc/install/dotlrn-basic-setup.test 21 Oct 2003 15:06:36 -0000 1.6 +++ openacs-4/etc/install/dotlrn-basic-setup.test 23 Oct 2003 12:35:21 -0000 1.7 @@ -49,16 +49,21 @@ ::twt::log_section "Add news items - one per class" ::twt::news::add_item_to_classes $server_url + ::twt::log_section "Customize layout of the MySpace page as a student" + ::twt::user::login [::twt::user::get_random_users student 1] + ::twt::new_portal::test::customize_layout + ::twt::user::login_site_wide_admin + # Test Execution END } result] } { global errorInfo # Output error stack trace and HTML response body - puts stderr $result - puts stderr "*** Tcl TRACE ***" - puts stderr $errorInfo - puts "The response body is: [response body]" + ::twt::log $result + ::twt::log "*** Tcl TRACE ***" + ::twt::log $errorInfo + ::twt::log "The response body is: [response body]" error "Test failed: $result" } Index: openacs-4/etc/install/dotlrn-links-check.test =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/Attic/dotlrn-links-check.test,v diff -u -N -r1.1 -r1.2 --- openacs-4/etc/install/dotlrn-links-check.test 4 Sep 2003 16:51:26 -0000 1.1 +++ openacs-4/etc/install/dotlrn-links-check.test 23 Oct 2003 12:35:21 -0000 1.2 @@ -7,22 +7,22 @@ # Login the site wide admin login_site_wide_admin - puts "crawling links starting from /dotlrn" + ::twt::log "crawling links starting from /dotlrn" lappend __url_history "${server_url}/dotlrn" crawl_links - puts "crawling links starting from /dotlrn/admin" + ::twt::log "crawling links starting from /dotlrn/admin" lappend __url_history "${server_url}/dotlrn/admin" crawl_links # Test Execution END } result] } { global errorInfo - puts stderr $result - puts stderr "*** Tcl TRACE ***" - puts stderr $errorInfo + ::twt::log stderr $result + ::twt::log stderr "*** Tcl TRACE ***" + ::twt::log stderr $errorInfo - puts "The response body is: [response body]" + ::twt::log "The response body is: [response body]" error "Test failed: $result" } Index: openacs-4/etc/install/tcl-api-test.test =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/tcl-api-test.test,v diff -u -N -r1.4 -r1.5 --- openacs-4/etc/install/tcl-api-test.test 15 Oct 2003 10:08:43 -0000 1.4 +++ openacs-4/etc/install/tcl-api-test.test 23 Oct 2003 12:35:21 -0000 1.5 @@ -12,17 +12,17 @@ # Grep for packages with failed tests if { [regexp -nocase {fail} [response body]] } { - puts "$alert_keyword - There are failed tests at $server_url" + ::twt::log "$alert_keyword - There are failed tests at $server_url" } # Test Execution END } result] } { global errorInfo - puts stderr $result - puts stderr "*** Tcl TRACE ***" - puts stderr $errorInfo + ::twt::log $result + ::twt::log "*** Tcl TRACE ***" + ::twt::log $errorInfo - puts "The response body is: [response body]" + ::twt::log "The response body is: [response body]" error "Test failed: $result" } Index: openacs-4/etc/install/tcl/acs-lang-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/tcl/acs-lang-procs.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/etc/install/tcl/acs-lang-procs.tcl 22 Oct 2003 13:16:00 -0000 1.3 +++ openacs-4/etc/install/tcl/acs-lang-procs.tcl 23 Oct 2003 12:35:01 -0000 1.4 @@ -13,18 +13,18 @@ loads all message catalogs for those locales. } { if { [empty_string_p $locales] } { - set locales [::twt::oacs_eval {db_list all_locales {select locale from ad_locales}}] + set locales [::twt::oacs::eval {db_list all_locales {select locale from ad_locales}}] } # First enable all locales - ::twt::oacs_eval " + ::twt::oacs::eval " foreach locale {$locales} { lang::system::locale_set_enabled -locale \$locale -enabled_p t } " # Load all catalog files for enabled locales - ::twt::oacs_eval lang::catalog::import + ::twt::oacs::eval lang::catalog::import } ad_proc ::twt::acs_lang::set_locale { locale } { @@ -44,6 +44,6 @@ call to be converted into text. } { if { [regexp {#[a-zA-Z0-9_.-]+\.[a-zA-Z0-9_.-]+#} [response body] message_key] } { - ::twt::log_warning "Found \"$message_key\" on page [response url] and might be a message key that needs a lang::util::localize call" + ::twt::log_alert "Found \"$message_key\" on page [response url] and might be a message key that needs a lang::util::localize call" } } Index: openacs-4/etc/install/tcl/config-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/tcl/config-procs.tcl,v diff -u -N -r1.2 -r1.3 --- openacs-4/etc/install/tcl/config-procs.tcl 21 Oct 2003 15:06:15 -0000 1.2 +++ openacs-4/etc/install/tcl/config-procs.tcl 23 Oct 2003 12:35:01 -0000 1.3 @@ -47,6 +47,9 @@ set __dotlrn_users_data_file users-data.csv } +global __alert_keyword +set __alert_keyword $alert_keyword + ad_proc ::twt::config::server_url { } { global __server_url @@ -70,3 +73,9 @@ return $__serverroot } + +ad_proc ::twt::config::alert_keyword { } { + global __alert_keyword + + return $__alert_keyword +} Index: openacs-4/etc/install/tcl/dotlrn-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/tcl/dotlrn-procs.tcl,v diff -u -N -r1.6 -r1.7 --- openacs-4/etc/install/tcl/dotlrn-procs.tcl 22 Oct 2003 13:16:00 -0000 1.6 +++ openacs-4/etc/install/tcl/dotlrn-procs.tcl 23 Oct 2003 12:35:01 -0000 1.7 @@ -6,6 +6,7 @@ # @author Peter Marklund namespace eval ::twt::dotlrn {} +namespace eval ::twt::dotlrn::test {} ad_proc ::twt::dotlrn::add_term { server_url term_name start_month start_year end_month end_year } { @@ -208,3 +209,29 @@ form find ~a "user-new-2" form submit } + +################### +# +# Namespace ::twt::dotlrn::test - no demo data setup, pure testing +# +################### + +ad_proc ::twt::dotlrn::test::manage_my_memberships {} { + return [::twt::oacs::eval { + db_string select_non_member_classes + }] +} + +ad_proc ::twt::dotlrn::test::manage_my_memberships {} { + Test that user can manage (join/drop) his own class and community memberships. +} { + ::twt::do_request "/dotlrn/manage-memberships" + + # Join a class + link follow ~u "^register?community_id=$community_id" + + # Request membership for a class + + # Drop a class + +} Index: openacs-4/etc/install/tcl/new-portal-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/tcl/new-portal-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/etc/install/tcl/new-portal-procs.tcl 23 Oct 2003 12:35:01 -0000 1.1 @@ -0,0 +1,55 @@ +# Procs to support testing OpenACS with Tclwebtest. +# +# Procs for testing the acs-lang (I18N) package +# +# @author Peter Marklund + +namespace eval ::twt::new_portal {} +namespace eval ::twt::new_portal::test {} + +ad_proc ::twt::new_portal::test::customize_layout {} { + Test customizing the layout of the MySpace page. +} { + # Visit the customize layout page + ::twt::do_request "/dotlrn/configure" + + # Revert to default layout to have a clean starting point + form find ~n op_revert + form submit + + # Remove an element + link follow ~u {configure-2.*op_hide=1} + + # Move element in different directions + link follow ~u {configure-2.*op_swap=1.*direction=up} + link follow ~u {configure-2.*op_swap=1.*direction=down} + link follow ~u {configure-2.*op_move=1.*direction=right} + + # Move element to different page + form find ~n op_move_to_page + form submit + + # Rename a page + form find ~n op_rename_page + set test_page_name "__test_page_name" + field fill $test_page_name ~n pretty_name + form submit + + # Assert that the test page name is there + ::twt::assert "page rename was successful" [regexp "$test_page_name" [response body]] + + # Add a page + form find ~n op_add_page + form submit + + # Revert back to default layout + form find ~n op_revert + form submit + + # Assert that the test page name is gone + ::twt::assert "test page name gone after revert" [expr ![regexp "$test_page_name" [response body]]] + + # Assert three pages + set page_count [regexp -all {]+?name="op_rename_page"} [response body]] + ::twt::assert_equals "customize page has three pages after revert" $page_count "3" +} Index: openacs-4/etc/install/tcl/oacs-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/tcl/oacs-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/etc/install/tcl/oacs-procs.tcl 23 Oct 2003 12:35:01 -0000 1.1 @@ -0,0 +1,64 @@ +# Procs to support testing OpenACS with Tclwebtest. +# +# Procs used to access the Tcl API on the OpenACS server. +# +# @author Peter Marklund + +namespace eval ::twt::oacs {} + +ad_proc ::twt::oacs::eval { tcl_command } { + Execute an OpenACS Tcl API command and return the result. + + @param tcl_command A list where the first item is the the + proc name and the remaining ones are proc arguments +} { + ::twt::do_request "/eval-command?[::http::formatQuery tcl_command $tcl_command]" + + return [response body] +} + +ad_proc ::twt::oacs::user_id_from_email { email } { + return [::twt::oacs::eval " + db_string user_id_from_email { + select party_id from parties where email = '$email' + } + "] +} + +ad_proc ::twt::oacs::get_classes_to_join { email } { + Return a list of ids for classes that the user with + given email can join. +} { + set user_id [user_id_from_email $email] + + return [::twt::oacs::eval " + db_list can_join_community_ids { + select community_id + from dotlrn_class_instances_full + where dotlrn_class_instances_full.join_policy <> 'closed' + and not exists (select 1 + from dotlrn_member_rels_full + where dotlrn_member_rels_full.user_id = '$user_id' + and dotlrn_member_rels_full.community_id = dotlrn_class_instances_full.class_instance_id) + + } + "] +} + +ad_proc ::twt::oacs::get_clubs_to_join { email } { + Return a list of ids for clubs that the user with + given email can join. +} { + set user_id [user_id_from_email $email] + + return [::twt::oacs::eval " + db_list can_join_club_ids { + select f.community_id + from dotlrn_clubs_full f + where f.join_policy <> 'closed' + and f.club_id not in (select dotlrn_member_rels_full.community_id as club_id + from dotlrn_member_rels_full + where dotlrn_member_rels_full.user_id = '$user_id') + } + "] +} Index: openacs-4/etc/install/tcl/test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/tcl/test-procs.tcl,v diff -u -N -r1.4 -r1.5 --- openacs-4/etc/install/tcl/test-procs.tcl 21 Oct 2003 15:06:15 -0000 1.4 +++ openacs-4/etc/install/tcl/test-procs.tcl 23 Oct 2003 12:35:01 -0000 1.5 @@ -9,12 +9,9 @@ set script_dir [file dirname [info script]] -source $script_dir/config-procs.tcl -source $script_dir/twt-procs.tcl -source $script_dir/user-procs.tcl -source $script_dir/admin-procs.tcl -source $script_dir/acs-lang-procs.tcl -source $script_dir/dotlrn-procs.tcl -source $script_dir/class-procs.tcl -source $script_dir/forums-procs.tcl -source $script_dir/news-procs.tcl +# Source all *-procs.tcl files in this directory +foreach path [glob ${script_dir}/*-procs.tcl] { + if { ![regexp {test-procs\.tcl$} $path] } { + source $path + } +} Index: openacs-4/etc/install/tcl/twt-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/tcl/twt-procs.tcl,v diff -u -N -r1.6 -r1.7 --- openacs-4/etc/install/tcl/twt-procs.tcl 22 Oct 2003 13:16:00 -0000 1.6 +++ openacs-4/etc/install/tcl/twt-procs.tcl 23 Oct 2003 12:35:01 -0000 1.7 @@ -22,11 +22,25 @@ puts "${script_name}: $message" } -ad_proc ::twt::log_warning { message } { +ad_proc ::twt::log_alert { message } { set script_name [file tail [info script]] - puts "${script_name}: WARNING - $message" + puts "" + puts "${script_name}: [::twt::config::alert_keyword] - $message" + puts "" } +ad_proc ::twt::assert { explanation expression } { + if { !$expression } { + ::twt::log_alert "Assertion \"$explanation\" failed" + } +} + +ad_proc ::twt::assert_equals { explanation actual_value expected_value } { + if { ![string equal $actual_value $expected_value] } { + ::twt::log_alert "Assertion \"$explanation\" failed: actual_value=\"$actual_value\", expected_value=\"$expected_value\"" + } +} + ad_proc ::twt::do_request { page_url } { Takes a a url and invokes tclwebtest::do_request. Will retry the request a number of times if it fails because of a socket @@ -92,17 +106,6 @@ return $urls_list } -ad_proc ::twt::oacs_eval { tcl_command } { - Execute an OpenACS Tcl API command and return the result. - - @param tcl_command A list where the first item is the the - proc name and the remaining ones are proc arguments -} { - ::twt::do_request "/eval-command?[::http::formatQuery tcl_command $tcl_command]" - - return [response body] -} - ad_proc ::twt::get_random_items_from_list { list number } { Given a list and the lenght of the list to return, return a list with a random subset of items from the input list. @@ -181,13 +184,11 @@ global __server_url set absolute_url [tclwebtest::absolute_link $start_url] if { [string first $__server_url $absolute_url] == -1 } { - #puts "not following link to external url $absolute_url" return } # Also return if this is the logout link if { [regexp {/register/logout} $start_url match] } { - #puts "not following logout link" return } @@ -204,13 +205,10 @@ # Don't revisit URL:s we have already tested # Don't follow relative anchors on pages - can't get them to work with TclWebtest if { [lsearch -exact $__url_history $url] == -1 && [string range $url 0 0] != "#" } { - #puts "$start_url following url $url" - lappend __url_history $url crawl_links } else { - #puts "$start_url skipping url $url as visited before" } } } Index: openacs-4/etc/install/tcl/user-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/install/tcl/user-procs.tcl,v diff -u -N -r1.7 -r1.8 --- openacs-4/etc/install/tcl/user-procs.tcl 22 Oct 2003 13:16:00 -0000 1.7 +++ openacs-4/etc/install/tcl/user-procs.tcl 23 Oct 2003 12:35:01 -0000 1.8 @@ -163,8 +163,6 @@ ad_proc ::twt::user::set_passwords { server_url } { foreach user_email [get_users] { - #puts "setting guest password for user $user_email" - # User admin page ::twt::do_request "/dotlrn/admin/users"