_attachments__attachments_url_api (private)

 _attachments__attachments_url_api

Defined in packages/attachments/tcl/test/attachments-procs.tcl

Partial Call Graph (max 5 caller/called nodes):
%3 aa_equals aa_equals (public) aa_false aa_false (public) aa_log aa_log (public) aa_log_result aa_log_result (public) aa_section aa_section (public) _attachments__attachments_url_api _attachments__attachments_url_api _attachments__attachments_url_api->aa_equals _attachments__attachments_url_api->aa_false _attachments__attachments_url_api->aa_log _attachments__attachments_url_api->aa_log_result _attachments__attachments_url_api->aa_section

Testcases:
No testcase defined.
Source code:
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{
    set system_url [acs::test::url]


    aa_section "Attachments URL"

    set attachments_url [attachments::get_attachments_url]
    aa_false "'$attachments_url' is a local URL" [util::external_url_p $attachments_url]
    aa_true "'$attachments_url' is a valid URL" [util_url_valid_p -relative $attachments_url]
    aa_true "'$system_url/$attachments_url' is a valid URL"  [util_url_valid_p $system_url/$attachments_url]


    aa_section "Add Attachment URL"

    set add_attachment_url [attachments::add_attachment_url  -folder_id 1234  -package_id 5678  -object_id 91011  -return_url a&b  -pretty_name c&d  ]
    aa_false "'$add_attachment_url' is a local URL" [util::external_url_p $add_attachment_url]
    aa_true "'$add_attachment_url' is a valid URL" [util_url_valid_p -relative $add_attachment_url]
    aa_true "'$add_attachment_url' starts by '$attachments_url'"  [regexp ^/?${attachments_url}.*$ $add_attachment_url]
    aa_true "'$add_attachment_url' contains '1234'" {
        [string first 1234 $add_attachment_url] >= 0
    }
    #
    # TODO: this fails because package_id is not used into the
    # API. This should be fixed somehow.
    #
    # aa_true "'$add_attachment_url' contains '5678'" {
    #     [string first 5678 $add_attachment_url] >= 0
    # }
    aa_true "'$add_attachment_url' contains '91011'" {
        [string first 91011 $add_attachment_url] >= 0
    }
    aa_true "'$add_attachment_url' contains '[ns_urlencode a&b]'" {
        [string first [ns_urlencode a&b] $add_attachment_url] >= 0
    }
    aa_true "'$add_attachment_url' contains '[ns_urlencode c&d]'" {
        [string first [ns_urlencode c&d] $add_attachment_url] >= 0
    }


    aa_section "Remove Attachment URL"

    set detach_url [attachments::detach_url  -package_id 1234  -object_id 5678  -attachment_id 91011  -return_url c&d]
    aa_false "'$detach_url' is a local URL" [util::external_url_p $detach_url]
    aa_true "'$detach_url' is a valid URL" [util_url_valid_p -relative $detach_url]
    aa_true "'$detach_url' starts by '$attachments_url'"  [regexp ^/?${attachments_url}.*$ $detach_url]
    #
    # TODO: this fails because package_id is not used into the
    # API. This should be fixed somehow.
    #
    # aa_true "'$detach_url' contains '1234'" {
    #     [string first 1234 $detach_url] >= 0
    # }
    aa_true "'$detach_url' contains '5678'" {
        [string first 5678 $detach_url] >= 0
    }
    aa_true "'$detach_url' contains '91011'" {
        [string first 91011 $detach_url] >= 0
    }
    aa_true "'$detach_url' contains '[ns_urlencode c&d]'" {
        [string first [ns_urlencode c&d] $detach_url] >= 0
    }


    aa_section "Go to Attachment URL"

    set go_to_attachment_url [attachments::goto_attachment_url  -package_id 1234  -object_id 5678  -attachment_id 91011]
    aa_false "'$go_to_attachment_url' is a local URL" [util::external_url_p $go_to_attachment_url]
    aa_true "'$go_to_attachment_url' is a valid URL" [util_url_valid_p -relative $go_to_attachment_url]
    aa_true "'$go_to_attachment_url' starts by '$attachments_url'"  [regexp ^/?${attachments_url}.*$ $go_to_attachment_url]
    #
    # TODO: this fails because package_id is not used into the
    # API. This should be fixed somehow.
    #
    # aa_true "'$go_to_attachment_url' contains '1234'" {
    #     [string first 1234 $go_to_attachment_url] >= 0
    # }
    aa_true "'$go_to_attachment_url' contains '5678'" {
        [string first 5678 $go_to_attachment_url] >= 0
    }
    aa_true "'$go_to_attachment_url' contains '91011'" {
        [string first 91011 $go_to_attachment_url] >= 0
    }


    aa_section "Graphics URL"

    set graphic_html [attachments::graphic_url]
    aa_true "Tag contains '[attachments::get_url]'" {
        [string first [attachments::get_url$graphic_html] >= 0
    }
    aa_true "The graphics are in HTML form" [regexp -nocase {^<img.*$} $graphic_html]


    aa_section "Attachment Context-Bar"

    try {
        #
        # attachments::get_root_folder relies on the node from the
        # connection.
        #
        set orig_node_id [ad_conn node_id]
        ad_conn -set node_id [site_node::get_node_id_from_object_id  -object_id [apm_package_id_from_key "acs-automated-testing"]]

        set root_folder_id [attachments::get_root_folder]
        set folder_id [db_string get_any_attachment_folder {
            select coalesce(max(f.folder_id), :root_folder_id)
            from cr_folders f, cr_items i
            where f.folder_id = i.item_id
            and i.parent_id = :root_folder_id
        } -default ""]
        set extra_vars {a 1 b 2 c 3}
        set cbar_list [fs_context_bar_list  -extra_vars $extra_vars  -folder_url "attach"  -file_url "attach"  -root_folder_id $root_folder_id  -final t $folder_id]

        attachments::context_bar  -folder_id $folder_id  -extra_vars $extra_vars  -final t  -multirow attachments_test_multirow
    } finally {
        ad_conn -set node_id $orig_node_id
    }

    aa_true "Multirow 'attachments_test_multirow' was created"  [template::multirow exists attachments_test_multirow]
    aa_equals "Multirow length is expected"  [template::multirow size attachments_test_multirow]  [expr {[llength $cbar_list] + 1}]
}} {
          aa_log "Running testcase body $body_count"
          set ::__aa_test_indent [info level]
          set catch_val [catch $testcase_body msg]
          if {$catch_val != 0 && $catch_val != 2} {
              aa_log_result "fail" "attachments_url_api (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo"
          }
          incr body_count
        }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: