Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get-rendition-content-test #297

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions test/cral/renditions_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,27 @@
get-rendition-info-response (renditions/get-rendition-info ticket created-node-id "doclib")]
(is (= (:status get-rendition-info-response) 200))
;; clean up
(is (= (:status (nodes/delete-node ticket created-node-id {:permanent true})) 204))))

(deftest get-rendition-content-test
(let [ticket (get-in (auth/create-ticket c/user c/password) [:body :entry])
;; create a node
created-node-id (->> (model/map->CreateNodeBody {:name (str (.toString (UUID/randomUUID)) ".jpg") :node-type cm/type-content})
(nodes/create-node ticket (tu/get-guest-home ticket))
(#(get-in % [:body :entry :id])))
;; update the node content
_ (nodes/update-node-content ticket created-node-id (io/as-file (io/resource content-file)))
;; ask for rendition creation
_ (renditions/create-rendition ticket created-node-id [(model/map->CreateRenditionBody {:id "doclib"})])]
;; wait until rendition is status is "CREATED"
(loop [get-rendition-info-response nil]
(if (= (get-in get-rendition-info-response [:body :entry :status]) "CREATED")
(is (= (:status get-rendition-info-response) 200))
(do
(Thread/sleep 1000)
(recur (renditions/get-rendition-info ticket created-node-id "doclib")))))
(let [get-rendition-content-response (renditions/get-rendition-content ticket created-node-id "doclib")]
(is (= (:status get-rendition-content-response) 200))
(is (bytes? (:body get-rendition-content-response))))
;; clean up
(is (= (:status (nodes/delete-node ticket created-node-id {:permanent true})) 204))))