• Publicity: Public Only All

content-image-test-procs.tcl

Procedures to test content::image Tcl API

Location:
packages/acs-content-repository/tcl/test/content-image-test-procs.tcl
Created:
2006-01-17
Author:
Hugh Brock
CVS Identification:
$Id: content-image-test-procs.tcl,v 1.9.2.2 2022/11/24 14:45:54 gustafn Exp $

Procedures in this file

Detailed information

[ hide source ] | [ make this the default ]

Content File Source

ad_library {
    Procedures to test content::image Tcl API

    @author Hugh Brock
    @creation-date 2006-01-17
    @cvs-id $Id: content-image-test-procs.tcl,v 1.9.2.2 2022/11/24 14:45:54 gustafn Exp $
}


aa_register_case \
    -cats {api db} \
    -procs {
        content::folder::delete
        content::folder::new
        content::folder::register_content_type
        content::folder::unregister_content_type
        content::item::delete
        content::item::get_content
        content::item::new
        content::revision::new
    } \
    content_image {
    content image test
} {

    aa_run_with_teardown -rollback -test_code {

        # create a cr_folder
        set first_folder_id [db_nextval "acs_object_id_seq"]
        set returned_first_folder_id [content::folder::new \
                                          -folder_id $first_folder_id \
                                          -name "test_folder_${first_folder_id}"]
        aa_true "Folder created" \
            {$first_folder_id == $returned_first_folder_id}

        content::folder::register_content_type \
            -folder_id $first_folder_id \
            -content_type "image" \

        # create a cr_item
        set first_item_id [db_nextval "acs_object_id_seq"]
        set returned_first_item_id [content::item::new \
                                        -name "test_item_one" \
                                        -item_id $first_item_id \
                                        -parent_id $first_folder_id \
                                        -content_type "image" \
                                        -storage_type "file"]

        aa_true "First item created $first_item_id" \
            {$first_item_id == $returned_first_item_id}

        # create an image
        set image_id [db_nextval "acs_object_id_seq"]

        set returned_image_id [content::revision::new \
                                   -revision_id $image_id \
                                   -item_id $first_item_id \
                                   -title "Test Title" \
                                   -description "Test Description"]
        aa_true "Basic Image created revision_id $image_id returned_revision_id $returned_image_id " \
            {$image_id == $returned_image_id}

        ::content::item::get_content -revision_id $returned_image_id -array revision_content
        aa_true "Revision contains correct content" \
            {$revision_content(title) eq "Test Title"
                   && $image_id == $revision_content(revision_id)}

        content::item::delete -item_id $first_item_id

        content::folder::unregister_content_type \
            -folder_id $first_folder_id \
            -content_type "image" \

        content::folder::delete -folder_id $first_folder_id
    }
}

aa_register_case \
    -cats {api db} \
    -procs {
        content::folder::new
        content::folder::register_content_type
        content::item::get_id
        image::new

        package_object_attribute_list
    } \
    image_new {

} {
    aa_run_with_teardown -rollback -test_code {
        # create a cr_folder
        set first_folder_id [db_nextval "acs_object_id_seq"]
        set returned_first_folder_id [content::folder::new \
                                          -folder_id $first_folder_id \
                                          -name "test_folder_${first_folder_id}"]
        aa_true "Folder created" \
            {$first_folder_id == $returned_first_folder_id}

        content::folder::register_content_type \
            -folder_id $first_folder_id \
            -content_type "image"

        set tmp_filename "$::acs::rootdir/packages/acs-content-repository/tcl/test/test-image-1.jpg"
        set image_item_id_orig [db_nextval  "acs_object_id_seq"]
        set image_name [ad_tmpnam "XXXXXX"]
        set image_item_id [image::new \
                               -item_id $image_item_id_orig \
                               -parent_id $first_folder_id \
                               -name $image_name \
                               -tmp_filename $tmp_filename]

        aa_true "Image Created" {$image_item_id_orig eq $image_item_id}
        aa_true "Image CR Item Exists" \
            {$image_item_id eq [content::item::get_id \
                                          -item_path $image_name \
                                          -root_folder_id $first_folder_id]}

    }
}


#
# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: