 (ns leela.blackbox.network.zmqserver-test
-  (:use     [clojure.test])
+  (:use     [clojure.test]
+            [clojure.tools.logging :only [trace debug info error]])
   (:require [leela.blackbox.f :as f]
             [leela.blackbox.storage.cassandra :as storage]
             [leela.blackbox.network.zmqserver :as server]))

     (storage/truncate-all ~cluster)
     ~@body))

(deftest test-zmqserver-handle-put-name-msg
  (storage/with-connection [cluster ["127.0.0.1"] "leela"]

    (truncate-n-test cluster "putname returns guid"
      (let [[msg user tree kind name guid] (server/handle-message cluster ["put" "name" "user" "tree" "kind" "foobar"])]
        (is (= "name" msg))
        (is (= "user" user))
        (is (= "tree" tree))

                                        node "21"
                                        node "22"])
        (storage/with-limit 1
          (is (= (server/msg-label ["10"]) (handle-message-macro cluster ["get" "label" "pre" node "1" "2"])))
          (is (= (server/msg-label ["11"]) (handle-message-macro cluster ["get" "label" "pre" node "11" "2"])))
          (is (= (server/msg-label ["12"]) (handle-message-macro cluster ["get" "label" "pre" node "12" "2"]))))))))

(deftest test-zmqserver-handle-label-exact-message
  (let [node (str (f/uuid-1))]
  (storage/with-connection [cluster ["127.0.0.1"] {}]
   (storage/use-attr-schema cluster "leela")
   (storage/use-graph-schema cluster "leela")

      (truncate-n-test cluster "getlabel-exact with no data"
        (is (= (server/msg-label []) (handle-message-macro cluster ["get" "label" "ext" node "foobar"]))))

      (truncate-n-test cluster "getlabel-exact after putlabel"
        (handle-message-macro cluster ["put" "label" node "foobar"])
        (is (= (server/msg-label ["foobar"]) (handle-message-macro cluster ["get" "label" "ext" node "foobar"])))))))

(deftest test-zmqserver-handle-getlink-message
  (let [node-a (str (f/uuid-from-time 1))
