generated dataset + testcase for complete offer schema

This commit is contained in:
Johannes Lötzsch 2022-03-09 15:33:50 +01:00
parent 01e0db2004
commit d07b57670c
3 changed files with 180 additions and 14 deletions

View File

@ -1,10 +1,160 @@
({:accessible false, :note ""}
{:accessible false, :note "y"}
{:accessible true, :note "74"}
{:accessible nil, :note "B0"}
{:accessible false, :note "20D"}
{:accessible false, :note ""}
{:accessible false, :note "R5nb"}
{:accessible true, :note "hkUGJ8"}
{:accessible true, :note "01pd"}
{:accessible false, :note ""})
({:beds 0,
:place_street "",
:contact_email nil,
:contact_name_full "",
:time_duration_str "",
:note "",
:place_street_number "",
:place_city "",
:contact_phone nil,
:place_zip "",
:time_from_str "",
:place_country "",
:animals_present false,
:languages (),
:accessible false,
:animals_allowed false}
{:beds nil,
:place_street "g",
:contact_email "8",
:contact_name_full "",
:time_duration_str "5",
:note "F",
:place_street_number "",
:place_city "",
:contact_phone nil,
:place_zip "",
:time_from_str "",
:place_country nil,
:animals_present true,
:languages (),
:accessible nil,
:animals_allowed false}
{:beds 1,
:place_street "p8",
:contact_email "i",
:contact_name_full nil,
:time_duration_str "D0",
:note "0",
:place_street_number "",
:place_city nil,
:contact_phone "Q",
:place_zip "RD",
:time_from_str "q",
:place_country nil,
:animals_present true,
:languages (),
:accessible nil,
:animals_allowed true}
{:beds 0,
:place_street "w4",
:contact_email "5",
:contact_name_full nil,
:time_duration_str "6GW",
:note nil,
:place_street_number "",
:place_city "1bh",
:contact_phone nil,
:place_zip "PG4",
:time_from_str "8az",
:place_country "I7",
:animals_present false,
:languages ("x" "ni"),
:accessible false,
:animals_allowed nil}
{:beds 2,
:place_street nil,
:contact_email nil,
:contact_name_full "",
:time_duration_str "wES5",
:note "",
:place_street_number "z7g",
:place_city "x",
:contact_phone "w8l",
:place_zip "1E",
:time_from_str "6",
:place_country "8",
:animals_present nil,
:languages (),
:accessible true,
:animals_allowed true}
{:beds 1,
:place_street "4N2",
:contact_email "u1",
:contact_name_full "BmUzV",
:time_duration_str "P0E5",
:note "Ue7F1",
:place_street_number "9Ms7",
:place_city "6",
:contact_phone "OI",
:place_zip "1",
:time_from_str "hS192",
:place_country "",
:animals_present false,
:languages ("DX" "E" "G3wuv"),
:accessible false,
:animals_allowed false}
{:beds 0,
:place_street "T",
:contact_email "W1wL",
:contact_name_full "51p9",
:time_duration_str "",
:note nil,
:place_street_number "yPkLR",
:place_city "cj1A2",
:contact_phone "r",
:place_zip "cJ9z7",
:time_from_str "",
:place_country "5",
:animals_present true,
:languages nil,
:accessible false,
:animals_allowed true}
{:beds nil,
:place_street "0IDd",
:contact_email "2511JLD",
:contact_name_full "JQw21",
:time_duration_str "kP1S8pE",
:note "P3",
:place_street_number nil,
:place_city "4ML4yG",
:contact_phone "7uQ3Px",
:place_zip "kp5IS",
:time_from_str "Y5lSe",
:place_country nil,
:animals_present true,
:languages (),
:accessible false,
:animals_allowed false}
{:beds 4,
:place_street "Wy",
:contact_email "35e6Rnj",
:contact_name_full "",
:time_duration_str "rh9n6q4",
:note "89Rxzv",
:place_street_number "",
:place_city "u6k41v",
:contact_phone "354VW",
:place_zip "DI19",
:time_from_str "Z0QGzI8",
:place_country nil,
:animals_present true,
:languages nil,
:accessible true,
:animals_allowed false}
{:beds 27,
:place_street "wIbUsu",
:contact_email "x0Vl9",
:contact_name_full "48",
:time_duration_str "33",
:note "Z",
:place_street_number "VB3",
:place_city "f",
:contact_phone "sQdB",
:place_zip "cid1",
:time_from_str "KSAFC",
:place_country "toTz5B",
:animals_present false,
:languages ("vMR0zyECr"),
:accessible false,
:animals_allowed false})

View File

@ -39,7 +39,7 @@
:contact_phone "Telefonnummer"
:contact_email "E-Mail"
:note "Nachricht"})
(def mapping_identity {:accessible :accessible
#_(def mapping_identity {:accessible :accessible
:note :note})
(defn unify
@ -102,6 +102,7 @@
(if (:import-file env)
(unify (clojure.edn/read-string (slurp (:import-file env)))
mapping_lifeline_wpforms)
(gen/sample (s/gen ::offer))))))
(clojure.edn/read-string (slurp "./data/sample-data/example.edn")) ;; till conflict between `specialist-server.type` and `with-gen` is fixed
#_(gen/sample (s/gen ::offer))))))
(s/def ::get_offers (t/resolver #'get_offers))

View File

@ -17,8 +17,23 @@
(deftest correct-login
(let [offers (get_offers {:auth {:mail mail :password password}})]
(is (= 10 (count offers))) ;; 10 is the default sample size of gen/sample
(is (= {:accessible true, :note "hkUGJ8"}
(nth offers 0))))) ;; picked one of the random generated datasets that contains not so many trivial values
(is (= {:beds 27
:place_street "wIbUsu"
:contact_email "x0Vl9"
:contact_name_full "48"
:time_duration_str "33"
:note "Z"
:place_street_number "VB3"
:place_city "f"
:contact_phone "sQdB"
:place_zip "cid1"
:time_from_str "KSAFC"
:place_country "toTz5B"
:animals_present false
:languages '("vMR0zyECr")
:accessible false
:animals_allowed false}
(last offers))))) ;; the later random generated datasets contain less trivial values
(deftest wrong-login
(let [offers (get_offers {:auth {:mail mail :password "wrong"}})]