 
 (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))))))
+    (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 (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 general-fixture
  "Needed for all tests."
  [f]
  (reset! app-state {})
  (a/>!! code-chan (:code final-state-map)) 
  (a/>!! interaction-chan (:token-response final-state-map))
  (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))}
    (f)))

(use-fixtures :each general-fixture)
 
(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))


(deftest test-request-access-and-refresh-tokens
  (testing "Build url and retrieve tokens."
    (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)
    (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."
