 
 (deftest test-request-access-and-refresh-tokens
   (testing "Build url and retrieve tokens."
-      (is (= final-state-map (update-in (request-access-and-refresh-tokens (dissoc final-state-map [:access_token :refresh_token :expires_in])) [:token-response :request-time] (fn [x] 0))))))
-
-(deftest test-request-access-to-data
-  (testing "Build auth url and fetch code."
-       (is (= final-state-map) (update-in  (request-access-to-data (dissoc final-state-map :code)) [:token-response :request-time] (fn [x] 0)))))
-
-(deftest test-init
+    (with-fake-routes
+      {(:token-url final-state-map) (fn [request] (:token-response final-state-map))
+       (:auth-url final-state-map) (fn [request] (parse-code test-code-http-response))}
+      (is (= final-state-map (update-in (request-access-and-refresh-tokens (dissoc final-state-map [:access_token :refresh_token :expires_in])) [:token-response :request-time] (fn [x] 0)))))))
+
+(comment
+  (deftest test-request-access-to-data
+    (testing "Build auth url and fetch code."
+      (with-fake-routes
+        {(:token-url final-state-map) (fn [request] (:token-response final-state-map))
+         (:auth-url final-state-map) (fn [request] (parse-code test-code-http-response))}
+        (is (= final-state-map) (update-in  (request-access-to-data (dissoc final-state-map :code)) [:token-response :request-time] (fn [x] 0))))))) 
+
+(comment (deftest test-init
   (testing "Test init function setting parameters and retrieving code and tokens."
     (reset! app-state middle-state-map)
-      (is (= final-state-map (update-in (init) [:token-response :request-time] (fn [x] 0))))))
+    (with-fake-routes
+      {(:token-url final-state-map) (fn [request] (:token-response final-state-map))
+       (:auth-url final-state-map) (fn [request] (parse-code test-code-http-response))}
+      (is (= final-state-map (update-in (init) [:token-response :request-time] (fn [x] 0))))))))
 
 (deftest test-set-oauth-params
   (testing "Test setting oauth-params."


(deftest test-get-tokens
  (testing "Test retrieving tokens through http requests."
    (is (= final-state-map (update-in (get-tokens (dissoc final-state-map [:access_token :refresh_token :expires_in])) [:token-response :request-time] (fn [x] 0))))))

(deftest test-token-url
  (testing "Create token-url."

   :auth-url (str "https://www.example.com/authorize/?" test-custom-param-query-param-string) 
   }) 

(defn drain!
  [ch]
  (a/go-loop []
           (if (some? (a/poll! ch))
             (recur))))

(defn reset-channels
  []
  "Reset our interaction and code channels to be able to start fresh."
  (drain! code-chan)
  (drain! interaction-chan))

(defn put-values-on-channels
  []
  "Put a value on each channel."
     (a/>!! code-chan (:code final-state-map)) 
     )

(defn reset
  "Reset the state of our app."
  [f]
  (reset! app-state {})
  (f))

(use-fixtures :each reset)

(deftest test-generate-query-param-string
  (testing "Testing generation of query param string with and without :other key"
    (is (= (query-param-string final-state-map) test-custom-param-query-param-string))
