file_storage::test::add_file_to_folder (private)

 file_storage::test::add_file_to_folder -last_request last_request \
    folder_name file_name file_description

Defined in packages/file-storage/tcl/test/webtest-procs.tcl

Adds a file to a folder from the UI.

Switches:
-last_request (required)
Parameters:
folder_name (required)
file_name (required)
file_description (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_file-storage file-storage (test ) file_storage::test::add_file_to_folder file_storage::test::add_file_to_folder test_file-storage->file_storage::test::add_file_to_folder test_fs_add_file_to_folder fs_add_file_to_folder (test ) test_fs_add_file_to_folder->file_storage::test::add_file_to_folder aa_error aa_error (public) file_storage::test::add_file_to_folder->aa_error aa_log aa_log (public) file_storage::test::add_file_to_folder->aa_log aa_true aa_true (public) file_storage::test::add_file_to_folder->aa_true acs::test::follow_link acs::test::follow_link (public) file_storage::test::add_file_to_folder->acs::test::follow_link acs::test::form_get_fields acs::test::form_get_fields (public) file_storage::test::add_file_to_folder->acs::test::form_get_fields

Testcases:
fs_add_file_to_folder, file-storage
Source code:
        set d [acs::test::follow_link -last_request $last_request -label {Add File}]
        #acs::test::reply_has_status_code $d 200
        #
        # "Add File" links to a redirect page file-upload-confirm...
        #
        acs::test::reply_has_status_code $d 302
        set location [::acs::test::get_url_from_location $d]
        set d [acs::test::http -last_request $d $location]

        set response [dict get $d body]
        set form [acs::test::get_form $response {//form[@id='file-add']}]

        # A 'real' simulation would actually upload a file via
        # multipart request, but this is enough for testing.
        set wfd [ad_opentmpfile tmpfile]
        puts $wfd 1234
        close $wfd

        aa_true "add form was returned" {[llength $form] > 2}
        set form_content [::acs::test::form_get_fields $form]
        dict set form_content title $file_name
        dict set form_content description $file_description
        set files [list  [list  file $tmpfile  fieldname upload_file  mime_type text/plain]]
        dict unset form_content upload_file
        set payload [util::http::post_payload  -files $files  -formvars_list $form_content]
        set body [dict get $payload payload]
        set headers [ns_set array [dict get $payload headers]]
        set d [acs::test::http  -last_request $d  -method POST  -body $body  -headers $headers  [dict get $form @action]]
        acs::test::reply_has_status_code $d 302
        set location [::acs::test::get_url_from_location $d]

        if { [string match  "*\?folder*id*" $location] } {
            aa_log "location contains folder*id"
            set list_words [split $file_name /]
            set short_file_name [lindex $list_words end]

            set d [acs::test::http -last_request $d $location]
            acs::test::reply_contains $d $folder_name
        } else {
            aa_error "file_storage::test::add_file_to_folder failed, bad redirect url: '$location'"
        }

        return $d
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: