Index: openacs-4/packages/faq/tcl/test/faq-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/tcl/test/faq-procs.tcl,v diff -u -r1.1.4.2 -r1.1.4.3 --- openacs-4/packages/faq/tcl/test/faq-procs.tcl 24 Sep 2005 01:20:00 -0000 1.1.4.2 +++ openacs-4/packages/faq/tcl/test/faq-procs.tcl 14 Nov 2005 14:22:51 -0000 1.1.4.3 @@ -10,90 +10,147 @@ } { aa_run_with_teardown -test_code { - # Create new Faq - set faq_name [ad_generate_random_string] - set response [faq::twt::new $faq_name] - aa_display_result -response $response -explanation {Webtest for the creation of a new Faq} - } + + tclwebtest::cookies clear + # Login user + array set user_info [twt::user::create -admin] + twt::user::login $user_info(email) $user_info(password) + # Create a new Faq + set faq_name [ad_generate_random_string] + set response [faq::twt::new $faq_name] + aa_display_result -response $response -explanation {Webtest for the creation of a new Faq} + + twt::user::logout + } + } aa_register_case -cats {web smoke} -libraries tclwebtest tclwebtest_delete_faq { - A simple test case to faq package : Test Delete Faq. + A simple test case to faq package : Test Delete Faq. } { aa_run_with_teardown -test_code { - # Create new Faq - set faq_name [ad_generate_random_string] - faq::twt::new $faq_name - set response [faq::twt::delete $faq_name] - aa_display_result -response $response -explanation {Webtest for deleting a Faq} + + tclwebtest::cookies clear + # Login user + array set user_info [twt::user::create -admin] + twt::user::login $user_info(email) $user_info(password) + # Create a new Faq + set faq_name [ad_generate_random_string] + faq::twt::new $faq_name + + # Delete a Faq + set response [faq::twt::delete $faq_name] + aa_display_result -response $response -explanation {Webtest for deleting a Faq} + + twt::user::logout } } aa_register_case -cats {web smoke} -libraries tclwebtest tclwebtest_edit_one_faq { - A simple test case to faq package : Test edit Faq - Fisrt Scenario. + A simple test case to faq package : Test edit Faq - Fisrt Scenario. - } { aa_run_with_teardown -test_code { - # Rename Faq by editing - set faq_name [ad_generate_random_string] - set new_faq_name [ad_generate_random_string] - faq::twt::new $faq_name - set response [faq::twt::edit_one $faq_name $new_faq_name] - aa_display_result -response $response -explanation {Webtest for editing a Faq - First Scenario} + + tclwebtest::cookies clear + # Login user + array set user_info [twt::user::create -admin] + twt::user::login $user_info(email) $user_info(password) + + # Create a new Faq + set faq_name [ad_generate_random_string] + set new_faq_name [ad_generate_random_string] + faq::twt::new $faq_name + + # Rename a Faq by editing + set response [faq::twt::edit_one $faq_name $new_faq_name] + aa_display_result -response $response -explanation {Webtest for editing a Faq - First Scenario} + twt::user::logout } } aa_register_case -cats {web smoke} -libraries tclwebtest tclwebtest_edit_two_faq { - A simple test case to faq package : Test edit Faq - Second Scenario. + A simple test case to faq package : Test edit Faq - Second Scenario. } { aa_run_with_teardown -test_code { - # Rename Faq by editing - set faq_name [ad_generate_random_string] - set new_faq_name [ad_generate_random_string] - faq::twt::new $faq_name - set response [faq::twt::edit_two $faq_name $new_faq_name] - aa_display_result -response $response -explanation {Webtest for editing a Faq - Second Scenario} - } + + tclwebtest::cookies clear + # Login user + array set user_info [twt::user::create -admin] + twt::user::login $user_info(email) $user_info(password) + + # Create a new Faq + set faq_name [ad_generate_random_string] + faq::twt::new $faq_name + + # Rename a Faq by editing + set new_faq_name [ad_generate_random_string] + set response [faq::twt::edit_two $faq_name $new_faq_name] + aa_display_result -response $response -explanation {Webtest for editing a Faq - Second Scenario} + + twt::user::logout + } } aa_register_case -cats {web smoke} -libraries tclwebtest tclwebtest_disable_faq { - A simple test case to faq package : Test Disable Faq. + A simple test case to faq package : Test Disable Faq. } { aa_run_with_teardown -test_code { - # Disable Faq - set faq_name [ad_generate_random_string] - faq::twt::new $faq_name - set option "disable" - set response [faq::twt::disable_enable $faq_name $option] - aa_display_result -response $response -explanation { Webtest for disabling a Faq} - } + + tclwebtest::cookies clear + # Login user + array set user_info [twt::user::create -admin] + twt::user::login $user_info(email) $user_info(password) + + # Create a new Faq + set faq_name [ad_generate_random_string] + faq::twt::new $faq_name + + # Disable a Faq + set option "disable" + set response [faq::twt::disable_enable $faq_name $option] + aa_display_result -response $response -explanation {Webtest for disabling a Faq} + + twt::user::logout + } } aa_register_case -cats {web smoke} -libraries tclwebtest tclwebtest_enable_faq { + + A simple test case to faq package : Test Enable Faq. - A simple test case to faq package : Test Enable Faq. - } { aa_run_with_teardown -test_code { - # Disable Faq - set faq_name [ad_generate_random_string] - faq::twt::new $faq_name - set option "disable" - faq::twt::disable_enable $faq_name $option - set option "enable" - set response [faq::twt::disable_enable $faq_name $option] - aa_display_result -response $response -explanation {Webtest for enabling a Faq} - } + + tclwebtest::cookies clear + # Login user + array set user_info [twt::user::create -admin] + twt::user::login $user_info(email) $user_info(password) + + # Create a new Faq + set faq_name [ad_generate_random_string] + faq::twt::new $faq_name + + # Disable a Faq + set option "disable" + faq::twt::disable_enable $faq_name $option + + # Enable a Faq + set option "enable" + set response [faq::twt::disable_enable $faq_name $option] + aa_display_result -response $response -explanation {Webtest for enabling a Faq} + + twt::user::logout + } } aa_register_case -cats {web smoke} -libraries tclwebtest tclwebtest_new_Q_A_faq { @@ -102,103 +159,173 @@ } { aa_run_with_teardown -test_code { - set faq_name [ad_generate_random_string] - set question [ad_generate_random_string] - set answer [ad_generate_random_string] - faq::twt::new $faq_name - set response [faq::twt::new_Q_A $faq_name $question $answer] - aa_display_result -response $response -explanation {Webtest for creating a New Question in a Faq} - } + tclwebtest::cookies clear + # Login user + array set user_info [twt::user::create -admin] + twt::user::login $user_info(email) $user_info(password) + + # Create a new Faq + set faq_name [ad_generate_random_string] + faq::twt::new $faq_name + + # Create a new Question_Answer + set question [ad_generate_random_string] + set answer [ad_generate_random_string] + set response [faq::twt::new_Q_A $faq_name $question $answer] + aa_display_result -response $response -explanation {Webtest for creating a New Question in a Faq} + + twt::user::logout + } } aa_register_case -cats {web smoke} -libraries tclwebtest tclwebtest_delete_Q_A_faq { - A simple test case to faq package : Delete a Q&A. + A simple test case to faq package : Delete a Q&A. } { aa_run_with_teardown -test_code { - set faq_name [ad_generate_random_string] - set question [ad_generate_random_string] - set answer [ad_generate_random_string] + + tclwebtest::cookies clear + # Login user + array set user_info [twt::user::create -admin] + twt::user::login $user_info(email) $user_info(password) - faq::twt::new $faq_name - faq::twt::new_Q_A $faq_name $question $answer - set response [faq::twt::delete_Q_A $faq_name $answer] - aa_display_result -response $response -explanation {Webtest for deleting a Question in a Faq} - } + # Create a new Faq + set faq_name [ad_generate_random_string] + faq::twt::new $faq_name - + # Create a new Question_Answer + set question [ad_generate_random_string] + set answer [ad_generate_random_string] + faq::twt::new_Q_A $faq_name $question $answer + + # Delete a Question_Answer + set response [faq::twt::delete_Q_A $faq_name $answer] + aa_display_result -response $response -explanation {Webtest for deleting a Question in a Faq} + + twt::user::logout + } } aa_register_case -cats {web smoke} -libraries tclwebtest tclwebtest_edit_Q_A_faq { - A simple test case to faq package : Edit a Q&A. + A simple test case to faq package : Edit a Q&A. } { aa_run_with_teardown -test_code { - set faq_name [ad_generate_random_string] - set question [ad_generate_random_string] - set answer [ad_generate_random_string] - set new_question [ad_generate_random_string] - set new_answer [ad_generate_random_string] + + tclwebtest::cookies clear + # Login user + array set user_info [twt::user::create -admin] + twt::user::login $user_info(email) $user_info(password) - faq::twt::new $faq_name - faq::twt::new_Q_A $faq_name $question $answer - set response [faq::twt::edit_Q_A $faq_name $new_question $new_answer] - aa_display_result -response $response -explanation {Webtest for editing a Question in a Faq} - } + # Create a new Faq + set faq_name [ad_generate_random_string] + faq::twt::new $faq_name + + # Create a new Question_Answer + set question [ad_generate_random_string] + set answer [ad_generate_random_string] + faq::twt::new_Q_A $faq_name $question $answer + + # Edit a Question_Answer + set new_question [ad_generate_random_string] + set new_answer [ad_generate_random_string] + set response [faq::twt::edit_Q_A $faq_name $new_question $new_answer] + aa_display_result -response $response -explanation {Webtest for editing a Question in a Faq} + + twt::user::logout + } } aa_register_case -cats {web smoke} -libraries tclwebtest tclwebtest_insert_after_Q_A_faq { A simple test case to faq package : Insert After a Q&A. } { - aa_run_with_teardown -test_code { - set faq_name [ad_generate_random_string] - set question [ad_generate_random_string] - set answer [ad_generate_random_string] + aa_run_with_teardown -test_code { + + tclwebtest::cookies clear + # Login user + array set user_info [twt::user::create -admin] + twt::user::login $user_info(email) $user_info(password) - faq::twt::new $faq_name - faq::twt::new_Q_A $faq_name $question $answer - set response [faq::twt::insert_after_Q_A $faq_name] - aa_display_result -response $response -explanation {Webtest for inserting a Question after a nother in a Faq} - } + # Create a new Faq + set faq_name [ad_generate_random_string] + faq::twt::new $faq_name + + # Create a new Question_Answer + set question [ad_generate_random_string] + set answer [ad_generate_random_string] + faq::twt::new_Q_A $faq_name $question $answer + + # Insert after a Question_Answer + set response [faq::twt::insert_after_Q_A $faq_name] + aa_display_result -response $response -explanation {Webtest for inserting a Question after a nother in a Faq} + + twt::user::logout + } } aa_register_case -cats {web smoke} -libraries tclwebtest tclwebtest_preview_Q_A_faq { - A simple test case to faq package : Preview a Q&A. + A simple test case to faq package : Preview a Q&A. } { aa_run_with_teardown -test_code { - set faq_name [ad_generate_random_string] - set question [ad_generate_random_string] - set answer [ad_generate_random_string] - faq::twt::new $faq_name - faq::twt::new_Q_A $faq_name $question $answer - set response [faq::twt::preview_Q_A $faq_name] - aa_display_result -response $response -explanation {Webtest for previewing a Question in a Faq} - } + + tclwebtest::cookies clear + # Login user + array set user_info [twt::user::create -admin] + twt::user::login $user_info(email) $user_info(password) + + # Create a new Faq + set faq_name [ad_generate_random_string] + faq::twt::new $faq_name + + # Create a new Question_Answer + set question [ad_generate_random_string] + set answer [ad_generate_random_string] + faq::twt::new_Q_A $faq_name $question $answer + + # Preview a Question_Answer + set response [faq::twt::preview_Q_A $faq_name] + aa_display_result -response $response -explanation {Webtest for previewing a Question in a Faq} + + twt::user::logout + } } aa_register_case -cats {web smoke} -libraries tclwebtest tclwebtest_swap_with_next_Q_A_faq { - A simple test case to faq package : Swap With Next Q&A. + A simple test case to faq package : Swap With Next Q&A. } { aa_run_with_teardown -test_code { - set faq_name [ad_generate_random_string] - set question_1 [ad_generate_random_string] - set answer_1 [ad_generate_random_string] - set question_2 [ad_generate_random_string] - set answer_2 [ad_generate_random_string] - - faq::twt::new $faq_name - faq::twt::new_Q_A $faq_name $question_1 $answer_1 - faq::twt::new_Q_A $faq_name $question_2 $answer_2 - set response [faq::twt::swap_with_next_Q_A $faq_name] - aa_display_result -response $response -explanation {Webtest for swaping a question with a next in a Faq} - } + + tclwebtest::cookies clear + # Login user + array set user_info [twt::user::create -admin] + twt::user::login $user_info(email) $user_info(password) + + set faq_name [ad_generate_random_string] + faq::twt::new $faq_name + + # Create a new Question_Answer + set question_1 [ad_generate_random_string] + set answer_1 [ad_generate_random_string] + faq::twt::new_Q_A $faq_name $question_1 $answer_1 + + # Create a new Question_Answer + set question_2 [ad_generate_random_string] + set answer_2 [ad_generate_random_string] + faq::twt::new_Q_A $faq_name $question_2 $answer_2 + + # Swap with next Question_Answer + set response [faq::twt::swap_with_next_Q_A $faq_name] + aa_display_result -response $response -explanation {Webtest for swaping a question with a next in a Faq} + + twt::user::logout + } } Index: openacs-4/packages/faq/tcl/test/tclwebtest-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/tcl/test/tclwebtest-procs.tcl,v diff -u -r1.1.4.2 -r1.1.4.3 --- openacs-4/packages/faq/tcl/test/tclwebtest-procs.tcl 24 Sep 2005 01:20:00 -0000 1.1.4.2 +++ openacs-4/packages/faq/tcl/test/tclwebtest-procs.tcl 14 Nov 2005 14:22:51 -0000 1.1.4.3 @@ -11,11 +11,6 @@ ad_proc new { faq_name } { set response 0 - tclwebtest::cookies clear - # Login user - array set user_info [twt::user::create -admin] - twt::user::login $user_info(email) $user_info(password) - # The Faq page url set faq_page_url [aa_get_first_url -package_key faq] ::twt::do_request $faq_page_url @@ -43,19 +38,14 @@ } else { aa_error "faq::twt::new failed, bad response url : $response_url" } - twt::user::logout + return $response } ad_proc delete { faq_name} { set response 0 - tclwebtest::cookies clear - # Login user - array set user_info [twt::user::create -admin] - twt::user::login $user_info(email) $user_info(password) - # The Faq page url set faq_page_url [aa_get_first_url -package_key faq] ::twt::do_request $faq_page_url @@ -77,19 +67,14 @@ } else { aa_error "faq::twt::delete failed, bad response url : $response_url" } - twt::user::logout + return $response } ad_proc edit_one { faq_name faq_new_name} { set response 0 - tclwebtest::cookies clear - # Login user - array set user_info [twt::user::create -admin] - twt::user::login $user_info(email) $user_info(password) - db_1row faq_id "select faq_id from faqs where faq_name=:faq_name" # Edit the FAQ and request the FAQ Admin page @@ -118,19 +103,14 @@ } else { aa_error "faq::twt::edit_one failed, bad response url : $response_url" } - twt::user::logout + return $response } ad_proc edit_two { faq_name faq_new_name} { set response 0 - tclwebtest::cookies clear - # Login user - array set user_info [twt::user::create -admin] - twt::user::login $user_info(email) $user_info(password) - # Edit the FAQ and request the FAQ Admin page # The Faq page url set faq_page_url [aa_get_first_url -package_key faq] @@ -162,7 +142,7 @@ } else { aa_error "faq::twt::edit_two failed, bad response url : $response_url" } - twt::user::logout + return $response } @@ -171,11 +151,6 @@ # Option : disable or enable set response 0 - tclwebtest::cookies clear - - # Login user - array set user_info [twt::user::create -admin] - twt::user::login $user_info(email) $user_info(password) db_1row faq_id "select faq_id from faqs where faq_name=:faq_name" @@ -200,19 +175,14 @@ } else { aa_error "faq::twt::$option failed. Bad response url : $response_url " } - twt::user::logout + return $response } ad_proc new_Q_A { faq_name question answer} { set response 0 - tclwebtest::cookies clear - # Login user - array set user_info [twt::user::create -admin] - twt::user::login $user_info(email) $user_info(password) - db_1row faq_id "select faq_id from faqs where faq_name=:faq_name" # The Faq page url @@ -244,19 +214,14 @@ } else { aa_error "faq::twt::new_Q_A failed. Bad response url : $response_url" } - twt::user::logout + return $response } ad_proc edit_Q_A { faq_name new_question new_answer } { set response 0 - tclwebtest::cookies clear - # Login user - array set user_info [twt::user::create -admin] - twt::user::login $user_info(email) $user_info(password) - db_1row faq_id "select faq_id from faqs where faq_name=:faq_name" # The Faq page url @@ -287,19 +252,14 @@ } else { aa_error "faq::twt::edit_Q_A failed. Bad response url : $response_url" } - twt::user::logout + return $response } ad_proc preview_Q_A { faq_name } { set response 0 - tclwebtest::cookies clear - # Login user - array set user_info [twt::user::create -admin] - twt::user::login $user_info(email) $user_info(password) - db_1row faq_id "select faq_id from faqs where faq_name=:faq_name" # The Faq page url @@ -325,19 +285,14 @@ } else { aa_error "faq::twt::preview_Q_A failed. Bad response url : $response_url" } - twt::user::logout + return $response } ad_proc delete_Q_A { faq_name question } { set response 0 - tclwebtest::cookies clear - # Login user - array set user_info [twt::user::create -admin] - twt::user::login $user_info(email) $user_info(password) - db_1row faq_id "select faq_id from faqs where faq_name=:faq_name" # The Faq page url @@ -360,19 +315,14 @@ } else { aa_error "faq::twt::delete_Q_A failed. Bad response url : $response_url" } - twt::user::logout + return $response } ad_proc insert_after_Q_A { faq_name } { set response 0 - tclwebtest::cookies clear - # Login user - array set user_info [twt::user::create -admin] - twt::user::login $user_info(email) $user_info(password) - db_1row faq_id "select faq_id from faqs where faq_name=:faq_name" # The Faq page url @@ -407,18 +357,14 @@ } else { aa_error "faq::twt::insert_after_Q_A failed. Bad response url : $response_url" } - twt::user::logout + return $response } ad_proc swap_with_next_Q_A { faq_name } { - tclwebtest::cookies clear + set response 0 - # Login user - array set user_info [twt::user::create -admin] - twt::user::login $user_info(email) $user_info(password) - db_1row faq_id "select faq_id from faqs where faq_name=:faq_name" # The Faq page url @@ -438,7 +384,7 @@ } else { aa_error "faq::twt::insert_after_Q_A failed. Bad response url : $response_url" } - twt::user::logout + return $response }