Skip to content

Commit

Permalink
Merge pull request #297 from saidone75/dev
Browse files Browse the repository at this point in the history
get-rendition-content-test
  • Loading branch information
saidone75 authored Jun 10, 2024
2 parents 375d3ec + 961386d commit 6082f02
Showing 1 changed file with 23 additions and 0 deletions.
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))))

0 comments on commit 6082f02

Please sign in to comment.