Skip to content

Commit

Permalink
Merge pull request #327 from saidone75/dev
Browse files Browse the repository at this point in the history
delete-rendition-test
  • Loading branch information
saidone75 authored Jul 2, 2024
2 parents e2b92e7 + 209e3e5 commit 60b1bc3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cral/api/core/renditions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
client/delete
(format "%s/nodes/%s/renditions/%s" (config/get-url 'core) node-id rendition-id)
ticket
nil
{:query-params nil}
opts))

(defn get-rendition-content
Expand Down
23 changes: 23 additions & 0 deletions test/cral/renditions_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,29 @@
;; clean up
(is (= (:status (nodes/delete-node ticket created-node-id {:permanent true})) 204))))

(deftest delete-rendition-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")))))
;; delete rendition
(is (= (:status (renditions/delete-rendition ticket created-node-id "doclib")) 204))
(is (= (get-in (renditions/get-rendition-info ticket created-node-id "doclib") [:body :entry :status]) "NOT_CREATED"))
;; 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
Expand Down

0 comments on commit 60b1bc3

Please sign in to comment.