<commit_before>(ns navigator-test
  (:require [clojure.test :refer :all]
            [datomic.api :as d]
            [navigator.test-config :as nt-config]
            [navigator.testslib :as n-tl]
            [datomic-schematode.core :as schematode]))

(use-fixtures :once nt-config/testing-fixture)

(deftest assert-comp
  (testing "raw assertion"
    (is (n-tl/ensure-tx (schematode/tx
                         (:db-conn nt-config/system)
                         :enforce
                         [{:db/id (d/tempid :db.part/user)
                           :comp/id-sk "i am a shared key"
                           :comp/name "COMP there it is"}]))))
  (testing "create-competency"
    (is (n-tl/ensure-tx (navigator/create-competency
                         (:db-conn nt-config/system)
                         "I will keep typing"
                         "v1"
                         :comp.status/active
                         :comp/id-sk "yeep"))))
  (testing "create duplicate competency"
    (is (n-tl/should-throw @(navigator/create-competency
                             (:db-conn nt-config/system)
                             "I will keep typing"
                             "v1"
                             :comp.status/active
                             :comp/id-sk "jeep")))))

(comment
  (map #(keys (deref %))
       (ds-core/load-schema! (d/connect config/db-url) [[:u {:attrs [[:a :string]]}]]))
  '((:db-before :db-after :tx-data :tempids) (:db-before :db-after :tx-data :tempids)))

(comment
  (def test-schemas
    [[:user {:attrs [[:username :string :db.unique/identity]
                     [:pwd :string "<PASSWORD>"]
                     [:email :string :indexed]
                     [:dob :string :indexed]
                     [:lastname :string :indexed]
                     [:status :enum [:pending :active :inactive :cancelled]]
                     [:group :ref :many]]
             :part :app
             :dbfns [(ds-constraints/unique :user :lastname :dob)]}]
     [:group {:attrs [[:name :string]
                      [:permission :string :many]]
              ;; testing without :part
              }]])

  (deftest expand-fields-test
    (testing "expand-fields"<commit_msg>add superficial test of navigator/update-competency<commit_after>(ns navigator-test
  (:require [clojure.test :refer :all]
            [datomic.api :as d]
            [navigator.test-config :as nt-config]
            [navigator.testslib :as n-tl]
            [datomic-schematode.core :as schematode]))

(use-fixtures :once nt-config/testing-fixture)

(deftest create-comps
  (testing "raw assertion"
    (is (n-tl/ensure-tx (schematode/tx
                         (:db-conn nt-config/system)
                         :enforce
                         [{:db/id (d/tempid :db.part/user)
                           :comp/id-sk "i am a shared key"
                           :comp/name "COMP there it is"}]))))
  (testing "create-competency"
    (is (n-tl/ensure-tx (navigator/create-competency
                         (:db-conn nt-config/system)
                         "I will keep typing"
                         "v1"
                         :comp.status/active
                         :comp/id-sk "yeep"))))
  (testing "create duplicate competency"
    (is (n-tl/should-throw @(navigator/create-competency
                             (:db-conn nt-config/system)
                             "I will keep typing"
                             "v1"
                             :comp.status/active
                             :comp/id-sk "jeep")))))

(deftest update-comps
  (is (n-tl/ensure-tx (navigator/create-competency
                       (:db-conn nt-config/system)
                       "can I update?"
                       "v1"
                       :comp.status/active
                       :comp/id-sk "yeep")))
  (is (n-tl/ensure-tx (navigator/update-competency
                       (:db-conn nt-config/system)
                       {:comp/name "can I update?"
                        :comp/version "v1"
                        :comp/status :comp.status/active
                        :db/id [:comp/id-sk "yeep"]}))))

(comment
  (map #(keys (deref %))
       (ds-core/load-schema! (d/connect config/db-url) [[:u {:attrs [[:a :string]]}]]))
  '((:db-before :db-after :tx-data :tempids) (:db-before :db-after :tx-data :tempids)))

(comment
  (def test-schemas
    [[:user {:attrs [[:username :string :db.unique/identity]
                     [:pwd :string "<PASSWORD>"]
                     [:email :string :indexed]
                     [:dob :string :indexed]
                     [:lastname :string :indexed]
                     [:status :enum [:pending :active :inactive :cancelled]]
                     [:group :ref :many]]
             :part :app
             :dbfns [(ds-constraints/unique :user :lastname :dob)]}]
     [:group {:attrs [[:name :string]
                      [:permission :string :many]]
              ;; testing without :part
              }]])

  (deftest expand-fields-test
    (testing "expand-fields"
{'fraction_non_alphanumeric': 0.1363904743160795, 'fraction_numerical': 0.001180869907498524, 'mean_word_length': 1.3593314763231197, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6309380', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1453, 'n_words': 327}