Skip to content

Commit

Permalink
replace more reaction test constants
Browse files Browse the repository at this point in the history
  • Loading branch information
milt committed Jan 23, 2024
1 parent daa6820 commit a3b9b77
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 36 deletions.
19 changes: 2 additions & 17 deletions src/test/lrsql/lrs_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1032,21 +1032,6 @@
;; Statement Reaction Tests
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(def invalid-template-invalid-path
{"actor" {"mbox" {"$templatePath" ["x" "actor" "mbox"]}}
"verb" {"id" "https://example.com/verbs/completed"}
"object" {"id" "https://example.com/activities/a-and-b"
"objectType" "Activity"}})

(def reaction-statement-result
{"actor" {"mbox" "mailto:[email protected]"},
"verb" {"id" "https://example.com/verbs/completed"},
"object"
{"id" "https://example.com/activities/a-and-b",
"objectType" "Activity"}
"context"
{"extensions" {"https://example.com/foo" nil}}})

(defn- remove-id
[statement]
(dissoc statement "id"))
Expand All @@ -1066,7 +1051,7 @@
(assoc
tc/simple-reaction-ruleset
:template
invalid-template-invalid-path)
tc/invalid-template-invalid-path)
{bad-reaction-id
:result} (adp/-create-reaction
lrs "reaction-bad" bad-ruleset true)]
Expand All @@ -1080,7 +1065,7 @@
(testing "New statement added"
(is (= {:statement-result
{:statements
[reaction-statement-result
[tc/reaction-stmt-result
(remove-id tc/reaction-stmt-b)
(remove-id tc/reaction-stmt-a)]
:more ""}
Expand Down
24 changes: 5 additions & 19 deletions src/test/lrsql/ops/query/reaction_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,7 @@
[{:reaction-id reaction-id
:trigger-id trigger-id
:statement
{"actor" {"mbox" "mailto:[email protected]"},
"verb" {"id" "https://example.com/verbs/completed"},
"object"
{"id" "https://example.com/activities/a-and-b",
"objectType" "Activity"}
"context" {"extensions" {"https://example.com/foo" nil}}}
tc/reaction-stmt-result
;; Authority derived from the trigger statement
:authority (:agent tc/auth-ident)}]}
(qr/query-statement-reactions
Expand Down Expand Up @@ -119,13 +114,9 @@
[{:reaction-id reaction-id
:trigger-id trigger-id
:statement
{"actor" {"mbox" "mailto:[email protected]"},
"verb" {"id" "https://example.com/verbs/completed"},
"object"
{"id" "https://example.com/activities/a-and-b",
"objectType" "Activity"}
"context" {"extensions" {"https://example.com/foo" nil}}
"authority" {"mbox" "mailto:[email protected]"}}
(merge
tc/reaction-stmt-result
{"authority" {"mbox" "mailto:[email protected]"}})
;; Authority derived from the template
:authority {"mbox" "mailto:[email protected]"}}]}
(qr/query-statement-reactions
Expand All @@ -149,12 +140,7 @@
"reaction-bad-template"
(merge
tc/simple-reaction-ruleset
{:template
;; Template with invalid path
{"actor" {"mbox" {"$templatePath" ["x" "actor" "mbox"]}}
"verb" {"id" "https://example.com/verbs/completed"}
"object" {"id" "https://example.com/activities/a-and-b"
"objectType" "Activity"}}})
{:template tc/invalid-template-invalid-path})
true)]
(try
;; Add statements
Expand Down
15 changes: 15 additions & 0 deletions src/test/lrsql/test_constants.clj
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,18 @@
"context" {"extensions"
{"https://example.com/array" ["foo" "bar" "baz"]
"https://example.com/number" 200}}})

(def reaction-stmt-result
{"actor" {"mbox" "mailto:[email protected]"},
"verb" {"id" "https://example.com/verbs/completed"},
"object"
{"id" "https://example.com/activities/a-and-b",
"objectType" "Activity"}
"context"
{"extensions" {"https://example.com/foo" nil}}})

(def invalid-template-invalid-path
{"actor" {"mbox" {"$templatePath" ["x" "actor" "mbox"]}}
"verb" {"id" "https://example.com/verbs/completed"}
"object" {"id" "https://example.com/activities/a-and-b"
"objectType" "Activity"}})

0 comments on commit a3b9b77

Please sign in to comment.