Skip to content

Commit

Permalink
In rio queue test, also test read after update (#348)
Browse files Browse the repository at this point in the history
* In rio queue test, also test read after update

* Review feedback
  • Loading branch information
mdemare authored Dec 20, 2024
1 parent 814b03f commit 062ee3d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
31 changes: 24 additions & 7 deletions src/nl/surf/eduhub_rio_mapper/cli_commands.clj
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,41 @@

"test-rio"
(let [[client-info _args] (parse-client-info-args args clients)
uuid (UUID/randomUUID)
uuid (UUID/randomUUID)
new-uuid (UUID/randomUUID)

eduspec (-> "../test/fixtures/ooapi/education-specification-template.json"
io/resource
slurp
(json/read-str :key-fn keyword)
(assoc :educationSpecificationId uuid))]

(try
(insert! {:institution-oin (:institution-oin client-info)
:institution-schac-home (:institution-schac-home client-info)
::ooapi/type "education-specification"
::ooapi/id uuid
::ooapi/entity eduspec})
(let [insert-req {:institution-oin (:institution-oin client-info)
:institution-schac-home (:institution-schac-home client-info)
::ooapi/type "education-specification"
::ooapi/id uuid
::ooapi/entity eduspec}
rio-code (-> insert-req insert! :aanleveren_opleidingseenheid_response :opleidingseenheidcode)
link-req (merge insert-req {::ooapi/id new-uuid ::rio/opleidingscode rio-code})]
(link! link-req)
(let [rio-obj (rio.loader/find-rio-object rio-code getter (:institution-oin client-info) "opleidingseenheid")
nieuwe-sleutel (->> rio-obj
:content
(filter #(= :kenmerken (:tag %)))
(map :content)
(map #(reduce (fn [m el] (assoc m (:tag el) (-> el :content first))) {} %))
(filter #(= "eigenOpleidingseenheidSleutel" (:kenmerknaam %)))
first
:kenmerkwaardeTekst)]
(when (not= nieuwe-sleutel (str uuid))
(throw (ex-info "Failed to set eigenOpleidingseenheidSleutel" {:rio-queue-status :down})))))

(println "The RIO Queue is UP")
(catch Exception ex
(when-let [ex-data (ex-data ex)]
(when (= :down (:rio-queue-status ex-data))
(println "The RIO Queue is DOWN")
(println "The RIO Queue is DOWN;" (.getMessage ex))
(System/exit 255)))
(println "An unexpected exception has occurred: " ex)
(System/exit 254))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"Authorized without client when no token provided")

(is (= http-status/forbidden
(:status (handler {:headers {"authorization" (str "Bearer invalid-token")}})))
(:status (handler {:headers {"authorization" "Bearer invalid-token"}})))
"Forbidden with invalid token")

(is (= 2 @count-calls)
Expand Down

0 comments on commit 062ee3d

Please sign in to comment.