Skip to content

Commit

Permalink
Update tests and changelog for wildcard support
Browse files Browse the repository at this point in the history
  • Loading branch information
wardle committed May 1, 2024
1 parent 03c6c3f commit 4c9c3e6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

# v1.0.??? (not yet released)

* Return ATC matching to same approach as before switch to SQLite and support '*' and '?' for wildcards

# v1.0.200 - 2024-04-27

* Automated tests using GitHub Actions on every commit to main branch and weekly with every release of dm+d in the UK
Expand Down
12 changes: 6 additions & 6 deletions test/src/com/eldrix/dmd/live_test.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
(ns com.eldrix.dmd.live-test
(:require [clojure.set :as set]
[clojure.spec.alpha :as s]
(:require [clojure.java.io :as io]
[clojure.spec.test.alpha :as stest]
[clojure.test :as t :refer [deftest testing is use-fixtures]]
[com.eldrix.dmd.core :as dmd]
[clojure.test :as t]))
[clojure.test :as t :refer [deftest is use-fixtures]]
[com.eldrix.dmd.core :as dmd]))

(stest/instrument)

Expand All @@ -16,7 +14,9 @@
(or (System/getenv "TRUD_API_KEY_FILE") "api-key.txt"))

(defn live-test-fixture [f]
(dmd/install-release (trud-api-key-filename) "cache" "latest-dmd.db")
(if (.exists (io/file "latest-dmd.db"))
(println "WARNING: skipping test of install-release as using existing latest-dmd.db. Delete this file if required.")
(dmd/install-release (trud-api-key-filename) "cache" "latest-dmd.db"))
(binding [*db* (dmd/open-store "latest-dmd.db")]
(f)
(dmd/close *db*)))
Expand Down
7 changes: 6 additions & 1 deletion test/src/com/eldrix/dmd/store_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@
(is (= "C03EB01" (dmd/atc-for-product st 34186711000001102))) ;; test from VTM
(is (= "C03EB01" (dmd/atc-for-product st 37365811000001102))) ;; test from AMP
(is (= "C03EB01" (dmd/atc-for-product st 37365911000001107))) ;; test from AMPP
(is (= #{318136009} (set (dmd/vpids-from-atc st "C03*"))))
(is (empty? (dmd/vpids-from-atc st "C03")) "Must use an explicit wildcard for ATC matching; no longer does prefix search without asking")
(is (= #{318136009}
(set (dmd/vpids-from-atc st "C03*"))
(set (dmd/vpids-from-atc st "C03EB01"))
(set (dmd/vpids-from-atc st "C0?EB01"))
(set (dmd/vpids-from-atc st "C03EB0?"))))
(is (= ["mg" "mg"] (map #(get-in % [:VMP__VIRTUAL_PRODUCT_INGREDIENT/STRNT_NMRTR_UOM :UNIT_OF_MEASURE/DESC]) (:VMP/VIRTUAL_PRODUCT_INGREDIENTS co-amilofruse-vmp-2))))
(is (= #{318136009 318135008} (set (map :VMP/VPID (dmd/vmps-for-product st 34186711000001102)))))
(is (= 34186711000001102 (:VTM/VTMID (first (dmd/vtms-for-product st 318135008)))))
Expand Down

0 comments on commit 4c9c3e6

Please sign in to comment.