first api version implemented

This commit is contained in:
Christian Mueller
2014-01-05 22:34:42 +01:00
parent dfb3a1c934
commit f39ae0a593
8 changed files with 157 additions and 53 deletions
+18 -15
View File
@@ -1,5 +1,8 @@
(ns NoteHub.test.api
(:use [NoteHub.api] [clojure.test]))
(:require
[NoteHub.storage :as storage])
(:use [NoteHub.api]
[clojure.test]))
(def note "Hello world, this is a test note!")
(def note2 "Another test note")
@@ -9,37 +12,37 @@
(defmacro isnt [arg] `(is (not ~arg)))
(defn register-publisher-fixture [f]
(def psk (register-publisher pid))
(def psk (storage/register-publisher pid))
(f)
(revoke-publisher pid))
(storage/revoke-publisher pid))
#_
(deftest api
(testing "API"
(testing "publisher registration"
(let [psk2 (register-publisher pid2)]
(is (valid-publisher? pid))
(is (valid-publisher? pid2))
(is (revoke-publisher pid2))
(isnt (revoke-publisher "anyPID"))
(isnt (valid-publisher? "any_PID"))
(isnt (valid-publisher? pid2))))
(testing "note publishing & retrieval"
(let [psk2 (storage/register-publisher pid2)]
(is (storage/valid-publisher? pid))
(is (storage/valid-publisher? pid2))
(is (storage/revoke-publisher pid2))
(isnt (storage/revoke-publisher "anyPID"))
(isnt (storage/valid-publisher? "any_PID"))
(isnt (storage/valid-publisher? pid2))))
#_ (testing "note publishing & retrieval"
(let [post-response (post-note note pid (get-signature pid psk note))
get-response (get-note (:noteID post-response))]
(is (:success (:status post-response)))
(is (:success (:status get-response)))
(is (= note (:note get-response)))
; TODO: test all response fields!!!!
(is (= (:longURL post-response) (:longURL get-response)))
(is (= (:shortURL post-response) (:shortURL get-response))))
(isnt (:success (:status (post-note note pid (get-signature pid psk note)))))
(isnt (:success (:status (post-note note pid (get-signature pid "random_psk" note)))))
(is (:success (:status (post-note note pid (get-signature pid psk note)))))
(let [psk2 (register-publisher "randomPID")]
(let [psk2 (storage/register-publisher "randomPID")]
(is (:success (:status (post-note note "randomPID" (get-signature pid psk2 note)))))
(is (revoke-publisher pid2))
(is (storage/revoke-publisher pid2))
(isnt (:success (:status (post-note note "randomPID" (get-signature pid psk2 note)))))))
(testing "note update"
#_ (testing "note update"
(let [post-response (post-note note pid (get-signature pid psk note) "passwd")
note-id (:noteID post-response)
get-response (get-note note-id)
+1
View File
@@ -1,5 +1,6 @@
(ns NoteHub.test.storage
(:use [NoteHub.storage]
[NoteHub.api :only [build-key]]
[NoteHub.views.pages]
[clojure.test]))
+1
View File
@@ -1,5 +1,6 @@
(ns NoteHub.test.views.pages
(:use [NoteHub.views.pages]
[NoteHub.api :only [build-key get-date]]
[noir.util.test]
[NoteHub.views.common :only [url]]
[NoteHub.storage]