<commit_before>(ns vignette.util.query-options-test
  (:require [midje.sweet :refer :all]
            [vignette.util.query-options :refer :all]))

(def thumb-map {:wikia "bucket"
                :top-dir "a"
                :middle-dir "ab"
                :original "boat.jpg"
                :revision "12345"
                :thumbnail-mode "thumbnail"
                :width "200"
                :height "300"
                :options {}})

(def thumb-option-map (assoc thumb-map :options {:fill "purple" :lang "zh" :replace true}))

(def status-option-map (assoc thumb-map :options {:status "REJECTED"}))

(facts :create-query-opt
  (create-query-opt #"\w+") => (contains {:regex #"\w+" :side-effects true}))

(facts :request-options
       (extract-query-opts {:query-params {"fill" "blue"
                                           "unused" "foo"
                                           "unused2" "bar"}}) => {:fill "blue"}
       (extract-query-opts {:query-params {"fill" ";rm -rf *;"}}) => {}
       (extract-query-opts {:query-params {"format" "ls -l"}}) => {}
       (extract-query-opts {:query-params {"status" "REJECTED"}}) => {:status "REJECTED"})

(facts :query-opts
       (query-opts thumb-option-map) => {:fill "purple" :lang "zh" :replace true}
       (query-opts thumb-map) => nil)
       (query-opts status-option-map) => {:status "REJECTED"}

(facts :query-opt
       (query-opt thumb-map :foo) => nil
       (query-opt thumb-option-map :fill) => "purple"
       (query-opt thumb-option-map :foo) => nil
       (query-opt status-option-map :status) => "REJECTED"
       (query-opt thumb-option-map :status) => nil)

(facts :query-opts-str
       (query-opts-str thumb-map) => ""
       (query-opts-str thumb-option-map) => "[fill=purple]")

(facts :query-opts->thumb-args
       (query-opts->thumb-args thumb-map) => []
       (query-opts->thumb-args thumb-option-map) => ["--fill" "purple"])<commit_msg>Fixing an old unit test<commit_after>(ns vignette.util.query-options-test
  (:require [midje.sweet :refer :all]
            [vignette.util.query-options :refer :all]))

(def thumb-map {:wikia "bucket"
                :top-dir "a"
                :middle-dir "ab"
                :original "boat.jpg"
                :revision "12345"
                :thumbnail-mode "thumbnail"
                :width "200"
                :height "300"
                :options {}})

(def thumb-option-map (assoc thumb-map :options {:fill "purple" :lang "zh" :replace true}))

(def status-option-map (assoc thumb-map :options {:status "REJECTED"}))

(facts :create-query-opt
  (create-query-opt #"\w+") => (contains {:regex #"\w+" :side-effects true}))

(facts :request-options
       (extract-query-opts {:query-params {"fill" "blue"
                                           "unused" "foo"
                                           "unused2" "bar"}}) => {:fill "blue"}
       (extract-query-opts {:query-params {"fill" ";rm -rf *;"}}) => {}
       (extract-query-opts {:query-params {"format" "ls -l"}}) => {}
       (extract-query-opts {:query-params {"status" "REJECTED"}}) => {:status "REJECTED"})

(facts :query-opts
       (query-opts thumb-option-map) => {:fill "purple" :lang "zh" :replace true}
       (query-opts thumb-map) => nil
       (query-opts status-option-map) => {:status "REJECTED"})

(facts :query-opt
       (query-opt thumb-map :foo) => nil
       (query-opt thumb-option-map :fill) => "purple"
       (query-opt thumb-option-map :foo) => nil
       (query-opt status-option-map :status) => "REJECTED"
       (query-opt thumb-option-map :status) => nil)

(facts :query-opts-str
       (query-opts-str thumb-map) => ""
       (query-opts-str thumb-option-map) => "[fill=purple]")

(facts :query-opts->thumb-args
       (query-opts->thumb-args thumb-map) => []
       (query-opts->thumb-args thumb-option-map) => ["--fill" "purple"])
{'fraction_non_alphanumeric': 0.18646694214876033, 'fraction_numerical': 0.006198347107438017, 'mean_word_length': 2.2248126561199, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3942096', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1234, 'n_words': 277}