Work on ADL issue #3, auxlists.
This commit is contained in:
parent
387c15b8a1
commit
d0d3c24e5c
7 changed files with 189 additions and 91 deletions
|
|
@ -52,7 +52,10 @@
|
|||
(is (= expected actual) "No exception thrown"))
|
||||
(let [expected {:error "java.lang.ArithmeticException: Divide by zero"}
|
||||
actual (do-or-return-reason (/ 1 0))]
|
||||
(is (= expected actual) "Exception thrown"))))
|
||||
(is (= expected actual) "Exception thrown"))
|
||||
(let [expected {:error "Hello: java.lang.ArithmeticException: Divide by zero"}
|
||||
actual (do-or-return-reason (/ 1 0) "Hello")]
|
||||
(is (= expected actual) "Exception thrown, with intro"))))
|
||||
|
||||
|
||||
;; These work in REPL, but break in tests. Why?
|
||||
|
|
|
|||
16
test/adl_support/forms_support_test.clj
Normal file
16
test/adl_support/forms_support_test.clj
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
(ns adl-support.forms-support-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[adl-support.forms-support :refer :all]))
|
||||
|
||||
|
||||
(deftest auxlist-data-name-test
|
||||
(testing "auxlist-data-name"
|
||||
(let [auxlist {:tag :auxlist,
|
||||
:attrs {:property "dwellings"},
|
||||
:content [{:tag :field,
|
||||
:attrs {:name "sub-address"},
|
||||
:content nil}]}
|
||||
expected "auxlist-dwellings"
|
||||
actual (auxlist-data-name auxlist)]
|
||||
(is (= expected actual) "Just checking..."))))
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
(ns adl-support.core-test
|
||||
(ns adl-support.rest-support-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[adl-support.rest_support :refer :all]))
|
||||
[adl-support.rest-support :refer :all]))
|
||||
|
||||
|
||||
(deftest if-valid-user-tests
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
actual (valid-user-or-forbid "hello" {:session {:user {:id 4}}})]
|
||||
(is (= expected actual) "User in session"))
|
||||
(let [expected 403
|
||||
actual (:status (valid-user-or-forbid "hello" {:session {:user {:id 4}}}))]
|
||||
actual (:status (valid-user-or-forbid "hello" {:session {}}))]
|
||||
(is (= expected actual) "No user in session"))))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
(ns adl-support.utils-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[adl-support.core :refer [*warn*]]
|
||||
[adl-support.utils :refer :all]))
|
||||
|
||||
;; Yes, there's MASSES in utils which ought to be tested. I'll add more tests over time.
|
||||
|
|
@ -304,3 +305,69 @@
|
|||
with appropriate property with prompt in current locale"))
|
||||
))
|
||||
|
||||
|
||||
(deftest list-related-query-name-tests
|
||||
(testing "list-related-query-name"
|
||||
(let [e1 {:tag :entity,
|
||||
:attrs {:volatility "6", :magnitude "1", :name "genders", :table "genders"},
|
||||
:content [{:tag :documentation,
|
||||
:content ["All genders which may be assigned to\n electors."]}
|
||||
{:tag :key, :attrs nil,
|
||||
:content [{:tag :property,
|
||||
:attrs {:distinct "all", :size "32", :type "string", :name "id"},
|
||||
:content [{:tag :prompt,
|
||||
:attrs {:locale "en_GB.UTF-8",
|
||||
:prompt "Gender"},
|
||||
:content nil}]}]}
|
||||
{:tag :list, :attrs {:name "Genders", :properties "all"}}
|
||||
{:tag :form, :attrs {:name "Gender", :properties "all"}}]}
|
||||
e2 {:tag :entity,
|
||||
:attrs {:volatility "6", :magnitude "1", :name "electors", :table "electors"},
|
||||
:content [{:tag :documentation,
|
||||
:attrs nil,
|
||||
:content
|
||||
["All electors known to the system; electors are
|
||||
people believed to be entitled to vote in the current
|
||||
campaign."]}
|
||||
{:tag :key,
|
||||
:attrs nil,
|
||||
:content
|
||||
[{:tag :property,
|
||||
:attrs
|
||||
{:distinct "system",
|
||||
:immutable "true",
|
||||
:column "id",
|
||||
:name "id",
|
||||
:type "integer",
|
||||
:required "true"},
|
||||
:content
|
||||
[{:tag :generator, :attrs {:action "native"}, :content nil}]}]}
|
||||
{:tag :property,
|
||||
:attrs
|
||||
{:distinct "user",
|
||||
:column "name",
|
||||
:name "name",
|
||||
:type "string",
|
||||
:required "true",
|
||||
:size "64"},
|
||||
:content
|
||||
[{:tag :prompt,
|
||||
:attrs {:locale "en_GB.UTF-8", :prompt "Name"},
|
||||
:content nil}]}
|
||||
{:tag :property,
|
||||
:attrs
|
||||
{:default "Unknown",
|
||||
:farkey "id",
|
||||
:entity "genders",
|
||||
:column "gender",
|
||||
:type "entity",
|
||||
:name "gender"},
|
||||
:content
|
||||
[{:tag :prompt,
|
||||
:attrs {:locale "en_GB.UTF-8", :prompt "Gender"},
|
||||
:content nil}]}]}
|
||||
expected "list-electors-by-gender"
|
||||
actual (list-related-query-name e1 e2)]
|
||||
(is (= expected actual) "just checking..."))))
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue