Skip to content

Commit

Permalink
Clean up test data
Browse files Browse the repository at this point in the history
  • Loading branch information
nnichols committed Mar 3, 2024
1 parent e2f5a92 commit 26aa812
Show file tree
Hide file tree
Showing 14 changed files with 264 additions and 233 deletions.
15 changes: 8 additions & 7 deletions src/brewtility/enrich/impl.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
{:no-doc true
:added "2.1"
:implementation-only true}
(:require [brewtility.precision :as precision]
[brewtility.units :as units]
(:require [brewtility.units :as units]
[brewtility.units.color :as color]
[brewtility.units.options :as options]
[brewtility.units.pressure :as pressure]
Expand Down Expand Up @@ -157,7 +156,7 @@
target-units
"`. Allowed values are: "
allowed-values)]
(assoc error-map :units error-msg)))
(assoc error-map :target-units error-msg)))


(defn source-unit-error
Expand Down Expand Up @@ -186,7 +185,7 @@
source-units
"`. Allowed values are: "
allowed-values)]
(assoc error-map :units error-msg)))
(assoc error-map :source-units error-msg)))


(defn systems-of-meaure-error
Expand All @@ -203,7 +202,7 @@
system-of-measure
". Allowed values are:"
options/systems-of-measure)]
(assoc error-map :system-of-measure error-msg)))
(assoc error-map options/system-of-measure error-msg)))


(defn precision-error
Expand Down Expand Up @@ -268,14 +267,16 @@
:no-doc true
:see-also ["enrich-displayable-pressure"]}
[measurement-type
{:keys [target-units system-of-measure precision suffix]
{:keys [target-units source-units system-of-measure precision suffix]
:as opts}]
(let [valid-target? (valid-unit-for-measurement-type? measurement-type target-units)
(let [valid-source? (valid-unit-for-measurement-type? measurement-type source-units)
valid-target? (valid-unit-for-measurement-type? measurement-type target-units)
valid-system? (contains? options/systems-of-measure system-of-measure)
valid-precision? (int? precision)
valid-suffix? (contains? options/supported-suffixes suffix)
errors (cond-> {}
(not valid-target?) (target-unit-error measurement-type target-units)
(not valid-source?) (source-unit-error measurement-type source-units)
(not valid-system?) (systems-of-meaure-error measurement-type system-of-measure)
(not valid-precision?) (precision-error measurement-type precision)
(not valid-suffix?) (suffix-error measurement-type suffix))]
Expand Down
30 changes: 16 additions & 14 deletions src/brewtility/enrich/styles.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@
An option map may be passed as an optional second argument to this function to override the default behavior.
Supported keys include:
- `:system-of-measure`: The unit system of measure to convert the min-temperature into. Defaults to `:us`. Acceptable values are:
- `:imperial`: The [British imperial](https://en.wikipedia.org/wiki/Imperial_units) system of measure.
- `:metric`: The [metric system](https://en.wikipedia.org/wiki/Metric_system) of measure.
- `:us`: The [United States Customary Units](https://en.wikipedia.org/wiki/United_States_customary_units) system of measure.
- `:si`: The [International System of Units](https://en.wikipedia.org/wiki/International_System_of_Units) system of measure.
- `:color-system` - The color system to use for the conversion. Default is `:lovibond` for type `:grain`, and `:srm` otherwise. Acceptable values are:
- `:lovibond` - Use the [Lovibond](https://en.wikipedia.org/wiki/Beer_measurement#Colour) system.
- `:srm` - Use the [Standard Reference Method](https://en.wikipedia.org/wiki/Standard_Reference_Method) system.
- `:ebc` - Use the [European Brewing Convention](https://www.lovibond.com/en/PC/Colour-Measurement/Colour-Scales-Standards/EBC-European-Brewing-Convention) system.
- `:rgba` - USe the [RGBa](https://www.w3schools.com/cssref/func_rgba.asp) color system, commonly used in CSS.
- `:precision`: The number of significant decimal places to display. Defaults to 3.
- `:suffix`: The suffix type to append to the min-temperature Defaults to `:short`. Acceptable values are:
Expand All @@ -194,13 +194,14 @@
"enrich-styles"
"enrich-styles-wrapper"]}
([style] (enrich-display-color-min style {}))
([style {:keys [style-display-color-min-target-units
([style {:keys [color-system
style-display-color-min-target-units
style-display-color-min-precision
style-display-color-min-suffix]
:as opts}]
(let [options (merge opts {impl/value-key :color-min
impl/display-key :display-color-min
impl/fine-grain-target-units style-display-color-min-target-units
impl/fine-grain-target-units (or style-display-color-min-target-units color-system)
impl/fine-grain-precision style-display-color-min-precision
impl/fine-grain-suffix style-display-color-min-suffix})]
(impl/enrich-displayable-units options/color style options))))
Expand All @@ -212,11 +213,11 @@
An option map may be passed as an optional second argument to this function to override the default behavior.
Supported keys include:
- `:system-of-measure`: The unit system of measure to convert the min-temperature into. Defaults to `:us`. Acceptable values are:
- `:imperial`: The [British imperial](https://en.wikipedia.org/wiki/Imperial_units) system of measure.
- `:metric`: The [metric system](https://en.wikipedia.org/wiki/Metric_system) of measure.
- `:us`: The [United States Customary Units](https://en.wikipedia.org/wiki/United_States_customary_units) system of measure.
- `:si`: The [International System of Units](https://en.wikipedia.org/wiki/International_System_of_Units) system of measure.
- `:color-system` - The color system to use for the conversion. Default is `:lovibond` for type `:grain`, and `:srm` otherwise. Acceptable values are:
- `:lovibond` - Use the [Lovibond](https://en.wikipedia.org/wiki/Beer_measurement#Colour) system.
- `:srm` - Use the [Standard Reference Method](https://en.wikipedia.org/wiki/Standard_Reference_Method) system.
- `:ebc` - Use the [European Brewing Convention](https://www.lovibond.com/en/PC/Colour-Measurement/Colour-Scales-Standards/EBC-European-Brewing-Convention) system.
- `:rgba` - USe the [RGBa](https://www.w3schools.com/cssref/func_rgba.asp) color system, commonly used in CSS.
- `:precision`: The number of significant decimal places to display. Defaults to 3.
- `:suffix`: The suffix type to append to the min-temperature Defaults to `:short`. Acceptable values are:
Expand All @@ -233,13 +234,14 @@
"enrich-styles"
"enrich-styles-wrapper"]}
([style] (enrich-display-color-max style {}))
([style {:keys [style-display-color-max-target-units
([style {:keys [color-system
style-display-color-max-target-units
style-display-color-max-precision
style-display-color-max-suffix]
:as opts}]
(let [options (merge opts {impl/value-key :color-max
impl/display-key :display-color-max
impl/fine-grain-target-units style-display-color-max-target-units
impl/fine-grain-target-units (or style-display-color-max-target-units color-system)
impl/fine-grain-precision style-display-color-max-precision
impl/fine-grain-suffix style-display-color-max-suffix})]
(impl/enrich-displayable-units options/color style options))))
34 changes: 17 additions & 17 deletions test/brewtility/data/equipment.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@

(def sample-equipment
"A hard-coded sample equipment for static unit tests"
{:batch-size 19.9
:boil-size 26.2
:boil-time 60.5
:calc-boil-volume true
:evap-rate 9.0
:hop-utilization 100.5
:lauter-deadspace 0.8
:name "8 Gal pot with 5 gal Igloo Cooler"
:notes "Popular all grain setup. 5 Gallon Gott or Igloo cooler as mash tun with false bottom, and 7-9 gallon brewpot capable of boiling at least 6 gallons of wort. Primarily used for single infusion mashes."
:top-up-kettle 0.5
:top-up-water 0.5
:trub-chiller-loss 0.8
:tun-specific-heat 0.3
:tun-volume 19.9
:tun-weight 2.5
:version 1})
{equipment.format/batch-size 19.9
equipment.format/boil-size 26.2
equipment.format/boil-time 60.5
equipment.format/calc-boil-volume true
equipment.format/evap-rate 9.0
equipment.format/hop-utilization 100.5
equipment.format/lauter-deadspace 0.8
equipment.format/name "8 Gal pot with 5 gal Igloo Cooler"
equipment.format/notes "Popular all grain setup. 5 Gallon Gott or Igloo cooler as mash tun with false bottom, and 7-9 gallon brewpot capable of boiling at least 6 gallons of wort. Primarily used for single infusion mashes."
equipment.format/top-up-kettle 0.5
equipment.format/top-up-water 0.5
equipment.format/trub-chiller-loss 0.8
equipment.format/tun-specific-heat 0.3
equipment.format/tun-volume 19.9
equipment.format/tun-weight 2.5
equipment.format/version 1})


(def sample-equipment-wrapper
"A hard-coded sample equipment-wrapper for static unit tests"
{:equipment sample-equipment})
{equipment.format/equipment sample-equipment})


(defn generate-equipment
Expand Down
32 changes: 16 additions & 16 deletions test/brewtility/data/fermentables.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@

(def sample-fermentable
"A hard-coded sample fermentable for static unit tests"
{:amount 0.45
:coarse-fine-diff 1.5
:color 500.1
:diastatic-power 0.0
:max-in-batch 10.0
:moisture 5.0
:name "Black Barley"
:notes "Unmalted roasted barley for stouts, porters"
:origin "United States"
:protein 13.2
:supplier "Gnome Brew"
:type "Grain"
:version 1
:yield 78.0})
{fermentables.format/amount 0.45
fermentables.format/coarse-fine-diff 1.5
fermentables.format/color 500.1
fermentables.format/diastatic-power 0.0
fermentables.format/max-in-batch 10.0
fermentables.format/moisture 5.0
fermentables.format/name "Black Barley"
fermentables.format/notes "Unmalted roasted barley for stouts, porters"
fermentables.format/origin "United States"
fermentables.format/protein 13.2
fermentables.format/supplier "Gnome Brew"
fermentables.format/type "Grain"
fermentables.format/version 1
fermentables.format/yield 78.0})


(def sample-fermentable-wrapper
"A hard-coded sample fermentable-wrapper for static unit tests"
{:fermentable sample-fermentable})
{fermentables.format/fermentable sample-fermentable})


(def sample-fermentables
Expand All @@ -38,7 +38,7 @@

(def sample-fermentables-wrapper
"A hard-coded sample fermentables-wrapper for static unit tests"
{:fermentables sample-fermentables})
{fermentables.format/fermentables sample-fermentables})


(defn generate-fermentable
Expand Down
26 changes: 13 additions & 13 deletions test/brewtility/data/hops.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@

(def sample-hop
"A hard-coded sample hop for static unit tests"
{:alpha 5.0
:amount 0.0638
:name "Goldings, East Kent"
:notes "Great all purpose UK hop for ales, stouts, porters"
:time 60.1
:use "Boil"
:version 1})
{hops.format/alpha 5.0
hops.format/amount 0.0638
hops.format/name "Goldings, East Kent"
hops.format/notes "Great all purpose UK hop for ales, stouts, porters"
hops.format/time 60.1
hops.format/use "Boil"
hops.format/version 1})


(def sample-hop-wrapper
"A hard-coded sample hop-wrapper for static unit tests"
{:hop sample-hop})
{hops.format/hop sample-hop})


(def sample-hops
Expand All @@ -64,7 +64,7 @@

(def sample-hops-wrapper
"A hard-coded sample hops-wrapper for static unit tests"
{:hops sample-hops})
{hops.format/hops sample-hops})


(defn generate-hop
Expand Down Expand Up @@ -103,9 +103,9 @@
(testing "Since this library assumes common-beer-format data is utilized, make sure static test data conforms"
(is (spoon.spec/test-valid? ::hops.format/hop sample-hop)
"Static test data should conform to common-beer-format.hop/hop")
(is (spoon.spec/test-valid? ::hops.format/hop (assoc sample-hop :type (random-hop-type)))
(is (spoon.spec/test-valid? ::hops.format/hop (assoc sample-hop hops.format/type (random-hop-type)))
"Static test data should conform to common-beer-format.hop/hop, even with an added optional type")
(is (spoon.spec/test-valid? ::hops.format/hop (assoc sample-hop :form (random-hop-form)))
(is (spoon.spec/test-valid? ::hops.format/hop (assoc sample-hop hops.format/form (random-hop-form)))
"Static test data should conform to common-beer-format.hop/hop, even with an added optional form")
(is (spoon.spec/test-valid? ::hops.format/hop sample-hop)
"Static test data should conform to common-beer-format.hop/hop")
Expand All @@ -119,9 +119,9 @@

(deftest generative-test-data-check
(testing "Since this library assumes common-beer-format data is utilized, make sure generative test data conforms"
(is (spoon.spec/test-valid? ::hops.format/hop (assoc (generate-hop) :type (random-hop-type)))
(is (spoon.spec/test-valid? ::hops.format/hop (assoc (generate-hop) hops.format/type (random-hop-type)))
"Generative test data should conform to common-beer-format.hop/hop, even with an added optional type")
(is (spoon.spec/test-valid? ::hops.format/hop (assoc (generate-hop) :form (random-hop-form)))
(is (spoon.spec/test-valid? ::hops.format/hop (assoc (generate-hop) hops.format/form (random-hop-form)))
"Generative test data should conform to common-beer-format.hop/hop, even with an added optional form")
(is (spoon.spec/test-valid? ::hops.format/hop (generate-hop))
"Generative test data should conform to common-beer-format.hop/hop")
Expand Down
26 changes: 13 additions & 13 deletions test/brewtility/data/mash.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@

(def sample-mash-step
"A hard-coded sample mash step for static unit tests"
{:infuse-amount 10.0
:name "Conversion Step, 68C"
:step-temp 68.0
:step-time 60.0
:type "Infusion"
:version 1})
{mash.format/infuse-amount 10.0
mash.format/name "Conversion Step, 68C"
mash.format/step-temp 68.0
mash.format/step-time 60.0
mash.format/type "Infusion"
mash.format/version 1})


(def sample-mash-step-wrapper
"A hard-coded sample mash-step-wrapper for static unit tests"
{:mash-step sample-mash-step})
{mash.format/mash-step sample-mash-step})


(def sample-mash-steps
Expand All @@ -30,15 +30,15 @@

(def sample-mash-steps-wrapper
"A hard-coded sample mash-steps-wrapper for static unit tests"
{:mash-steps sample-mash-steps})
{mash.format/mash-steps sample-mash-steps})


(def sample-mash
"A hard-coded sample mash for static unit tests"
{:name "Single Step Infusion, 68 C"
:version 1
:grain-temp 22.0
:mash-steps sample-mash-steps})
{mash.format/name "Single Step Infusion, 68 C"
mash.format/version 1
mash.format/grain-temp 22.0
mash.format/mash-steps sample-mash-steps})


(def sample-mash-wrapper
Expand Down Expand Up @@ -75,7 +75,7 @@
{:added "2.0"
:no-doc true}
[]
{:mash-steps (gen/generate (spec/gen ::mash.format/mash-steps))})
{mash.format/mash-steps (gen/generate (spec/gen ::mash.format/mash-steps))})


(defn generate-mash
Expand Down
18 changes: 9 additions & 9 deletions test/brewtility/data/miscs.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@

(def sample-misc
"A hard-coded sample misc for static unit tests"
{:amount 0.010
:name "Irish Moss"
:notes "Used as a clarifying agent during the last few minutes of the boil"
:time 15.1
:type "Fining"
:use "Boil"
:version 1})
{miscs.format/amount 0.010
miscs.format/name "Irish Moss"
miscs.format/notes "Used as a clarifying agent during the last few minutes of the boil"
miscs.format/time 15.1
miscs.format/type "Fining"
miscs.format/use "Boil"
miscs.format/version 1})


(def sample-misc-wrapper
"A hard-coded sample misc-wrapper for static unit tests"
{:misc sample-misc})
{miscs.format/misc sample-misc})


(def sample-miscs
Expand All @@ -31,7 +31,7 @@

(def sample-miscs-wrapper
"A hard-coded sample miscs-wrapper for static unit tests"
{:miscs sample-miscs})
{miscs.format/miscs sample-miscs})


(defn generate-misc
Expand Down
Loading

0 comments on commit 26aa812

Please sign in to comment.