<commit_before>(ns stonecutter.test.handler
  (:require [midje.sweet :refer :all]
            [ring.mock.request :as mock]
            [stonecutter.handler :refer [app splitter]]
            [stonecutter.db.storage :as storage]))

(def stores-m (storage/create-in-memory-stores))

(fact "registration url returns a 200 response"
      (-> (mock/request :get "/register") ((app stores-m)) :status) => 200)

(fact "sign-in url returns a 200 response"
      (-> (mock/request :get "/sign-in") ((app stores-m)) :status) => 200)

(fact "sign-out url returns a 302 response"
      (-> (mock/request :get "/sign-out") ((app stores-m)) :status) => 302)

(fact "unknown url returns a 404 response"
      (-> (mock/request :get "/unknown-url") ((app stores-m)) :status) => 404)

(fact "can be split requests between html site and api"
      (let [site-handler (fn [r] :site)
            api-handler (fn [r] :api)
            handler (splitter site-handler api-handler)]

        (-> (mock/request :get "/blah") handler) => :site
        (-> (mock/request :get "/api/blah") handler) => :api))<commit_msg>DM | Fix build<commit_after>(ns stonecutter.test.handler
  (:require [midje.sweet :refer :all]
            [ring.mock.request :as mock]
            [stonecutter.handler :as h]
            [stonecutter.db.storage :as storage]))

(def stores-m (storage/create-in-memory-stores))

(def app (h/create-app {:secure "false"} stores-m :dev-mode? false))

(fact "registration url returns a 200 response"
      (-> (mock/request :get "/register") app  :status) => 200)

(fact "sign-in url returns a 200 response"
      (-> (mock/request :get "/sign-in") app :status) => 200)

(fact "sign-out url returns a 302 response"
      (-> (mock/request :get "/sign-out") app :status) => 302)

(fact "unknown url returns a 404 response"
      (-> (mock/request :get "/unknown-url") app :status) => 404)

(fact "can be split requests between html site and api"
      (let [site-handler (fn [r] :site)
            api-handler (fn [r] :api)
            handler (h/splitter site-handler api-handler)]

        (-> (mock/request :get "/blah") handler) => :site
        (-> (mock/request :get "/api/blah") handler) => :api))
{'fraction_non_alphanumeric': 0.17107664233576642, 'fraction_numerical': 0.021897810218978103, 'mean_word_length': 2.8609154929577465, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2116867', 'n_tokens_mistral': 759, 'n_tokens_neox': 704, 'n_words': 220}