<commit_before>(ns {{name}}.acceptance
  (:use [{{name}}.web :as web])
  (:use midje.sweet)
  (:use clojure.test)
  (:use [clojure.data.json :as json])
  (:require [clj-http.client :as client])
  (:require [clojure.data.zip.xml :as xml])

  (:import java.util.UUID))

(def host (get (System/getenv) "HOST" "localhost"))
(def port (Integer. (get (System/getenv) "JETTY_PORT" 8080)))
(def base-url (str "http://" host ":" port "/1.x/"))

(defn url+ [& suffix] (apply str base-url suffix))

(defn new-user-id [] (.toString (UUID/randomUUID)))
(defn extract-body [response]
  (json/read-json (:body response)))

(defn read-xml-body [http-response]
  "Reads the XML body from the HTTP response as a tree structure"
  (-> (.getBytes (get http-response :body))
         java.io.ByteArrayInputStream.
         clojure.xml/parse clojure.zip/xml-zip))

(defn put [& urls]
  (last (doall (for [url urls] (client/put url {:throw-exceptions false})))))

(defn ping []
  (client/get (url+ "ping")  {:throw-exceptions false}))

(def started? (atom false))

(defn service-alive []
  (try
    (if-let [resp (ping)]
      true
      false)
    (catch Exception e false)))

(defn start-service []
  (if (not (service-alive))<commit_msg>Changed acceptance tests to use service.url property<commit_after>(ns {{name}}.acceptance
  (:use [{{name}}.web :as web])
  (:use midje.sweet)
  (:use clojure.test)
  (:use [clojure.data.json :as json])
  (:require [clj-http.client :as client])
  (:require [clojure.data.zip.xml :as xml])

  (:import java.util.UUID))

(def host (get (System/getenv) "HOST" "localhost"))
(def port (Integer. (get (System/getenv) "JETTY_PORT" 8080)))
(def base-url (System/getProperty "service.url" (str "http://localhost:" port "/1.x/")))

(defn url+ [& suffix] (apply str base-url suffix))

(defn new-user-id [] (.toString (UUID/randomUUID)))
(defn extract-body [response]
  (json/read-json (:body response)))

(defn read-xml-body [http-response]
  "Reads the XML body from the HTTP response as a tree structure"
  (-> (.getBytes (get http-response :body))
         java.io.ByteArrayInputStream.
         clojure.xml/parse clojure.zip/xml-zip))

(defn put [& urls]
  (last (doall (for [url urls] (client/put url {:throw-exceptions false})))))

(defn ping []
  (client/get (url+ "ping")  {:throw-exceptions false}))

(def started? (atom false))

(defn service-alive []
  (try
    (if-let [resp (ping)]
      true
      false)
    (catch Exception e false)))

(defn start-service []
  (if (not (service-alive))
{'fraction_non_alphanumeric': 0.1837385412514946, 'fraction_numerical': 0.0039856516540454365, 'mean_word_length': 3.753787878787879, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '5701932', 'n_tokens_mistral': 943, 'n_tokens_neox': 910, 'n_words': 252}