diff options
Diffstat (limited to 'test/clj')
-rw-r--r-- | test/clj/queue_api/test/db/core_test.clj | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/test/clj/queue_api/test/db/core_test.clj b/test/clj/queue_api/test/db/core_test.clj index 7abdd56..c1ecc6d 100644 --- a/test/clj/queue_api/test/db/core_test.clj +++ b/test/clj/queue_api/test/db/core_test.clj @@ -28,6 +28,16 @@ :job/type "bills-question" :job/status :unassigned :job/date (time/date-time 2018 2 18 1 0 3) + :job/urgent false} + {:job/id "aa327540-4e24-47f4-9e9c-81cdd5195934" + :job/type "bills-question" + :job/status :unassigned + :job/date (time/date-time 2018 2 18 1 0 6) + :job/urgent true} + {:job/id "3cdc52fe-b538-40a6-a9d7-92fa840c2c4b" + :job/type "purchases-question" + :job/status :unassigned + :job/date (time/date-time 2018 2 18 1 0 8) :job/urgent true} ;;Agent that will be linked to jobs {:agent/id "644be0ce-035d-48cb-867e-8e6de2714a8d" @@ -38,11 +48,17 @@ {:job/id "1e0d939d-494b-48d2-9247-b5ae207a519a" :job/status :completed :job/agent [:agent/id "644be0ce-035d-48cb-867e-8e6de2714a8d"]} + {:job/id "aa327540-4e24-47f4-9e9c-81cdd5195934" + :job/status :completed + :job/agent [:agent/id "644be0ce-035d-48cb-867e-8e6de2714a8d"]} + {:job/id "3cdc52fe-b538-40a6-a9d7-92fa840c2c4b" + :job/status :completed + :job/agent [:agent/id "644be0ce-035d-48cb-867e-8e6de2714a8d"]} ;;Change job status to processing and link agent {:job/id "b201d085-91b5-4a13-9a74-7861426e9996" :job/status :processing :job/agent [:agent/id "644be0ce-035d-48cb-867e-8e6de2714a8d"]} - ;;Link jog with job that it is processing + ;;Link agent with job that it is being processed {:agent/id "644be0ce-035d-48cb-867e-8e6de2714a8d" :agent/job [:job/id "b201d085-91b5-4a13-9a74-7861426e9996"]}]) @@ -77,14 +93,18 @@ (= left right) #{["51ab0771-f1e4-4268-868f-9029a58f6612"] ["96cf6f11-591d-4cde-9ab0-56e371acb6d2"]} (q-status :unassigned) - #{["1e0d939d-494b-48d2-9247-b5ae207a519a"]} (q-status :completed) + #{["1e0d939d-494b-48d2-9247-b5ae207a519a"] + ["aa327540-4e24-47f4-9e9c-81cdd5195934"] + ["3cdc52fe-b538-40a6-a9d7-92fa840c2c4b"]} (q-status :completed) #{["b201d085-91b5-4a13-9a74-7861426e9996"]} (q-status :processing) #{} (q-status :nil)))) (deftest sum-queue-test (testing "test get summary of current state of the queue" - (is (= {:completed ["1e0d939d-494b-48d2-9247-b5ae207a519a"] - :processing ["b201d085-91b5-4a13-9a74-7861426e9996"] + (is (= {:completed ["1e0d939d-494b-48d2-9247-b5ae207a519a" + "aa327540-4e24-47f4-9e9c-81cdd5195934" + "3cdc52fe-b538-40a6-a9d7-92fa840c2c4b"], + :processing ["b201d085-91b5-4a13-9a74-7861426e9996"], :unassigned ["96cf6f11-591d-4cde-9ab0-56e371acb6d2" "51ab0771-f1e4-4268-868f-9029a58f6612"]} (sum-queue))))) @@ -96,14 +116,26 @@ (q-job false :unassigned "rewards-question"))) (is (= [(d/entity @conn [:job/id "b201d085-91b5-4a13-9a74-7861426e9996"])] (q-job true :processing "purchases-question"))) - (is (= [(d/entity @conn [:job/id "1e0d939d-494b-48d2-9247-b5ae207a519a"])] + (is (= [(d/entity @conn [:job/id "aa327540-4e24-47f4-9e9c-81cdd5195934"])] (q-job true :completed "bills-question"))) - (is (= [] (q-job false :completed "rewards-question"))))) + (is (= [] (q-job false :completed "rewards-question"))) + (is (= [(d/entity @conn [:job/id "1e0d939d-494b-48d2-9247-b5ae207a519a"])] + (q-job false :completed "rewards-question" "bills-question"))) + (is (= [(d/entity @conn [:job/id "1e0d939d-494b-48d2-9247-b5ae207a519a"])] + (q-job false :completed ["rewards-question" "bills-question"]))))) (deftest agent-jobs-test (testing "Test fetch relation agent job" - (is (= [(d/entity @conn [:job/id "1e0d939d-494b-48d2-9247-b5ae207a519a"])] + (is (= [(d/entity @conn [:job/id "1e0d939d-494b-48d2-9247-b5ae207a519a"]) + (d/entity @conn [:job/id "aa327540-4e24-47f4-9e9c-81cdd5195934"]) + (d/entity @conn [:job/id "3cdc52fe-b538-40a6-a9d7-92fa840c2c4b"])] (agent-jobs "644be0ce-035d-48cb-867e-8e6de2714a8d" :completed))) (is (= [(d/entity @conn [:job/id "b201d085-91b5-4a13-9a74-7861426e9996"])] (agent-jobs "644be0ce-035d-48cb-867e-8e6de2714a8d" :processing))) - (is (= [] (agent-jobs "644be0ce-035d-48cb-867e-8e6de2714a8d" :unassigned)))))
\ No newline at end of file + (is (= [] (agent-jobs "644be0ce-035d-48cb-867e-8e6de2714a8d" :unassigned))))) + +(deftest sum-agent-test + (testing "Test sum-agent" + (is (= [{:type "bills-question", :jobs 2} {:type "purchases-question", :jobs 1}] + (sum-agent "644be0ce-035d-48cb-867e-8e6de2714a8d"))) + (is (= [] (sum-agent "00000000-0000-0000-0000-000000000000")))))
\ No newline at end of file |