<commit_before>(ns morpheus.tests.modeling
  (:require [midje.sweet :refer :all]
            [morpheus.tests.server :refer [with-server]]
            [morpheus.models.vertex.core :refer :all]
            [morpheus.models.edge.core :refer :all]
            [cluster-connector.utils.for-debug :refer [$ spy]]))

(facts
  "Creating Veterx and Edges"
  (with-server
    (fact "Create Veterx Schema"
          (new-vertex-group :movie {:body :defined :key-field :name
                                    :fields [[:name :text]
                                             [:year :short]
                                             [:directed-by :obj]]}) => anything
          (new-vertex-group :people {:body :dynamic :key-field :name}) => anything)
    (fact "Create Edge Schema"
          (new-edge-group :acted-in {:type :directed :body :dynamic}) => anything
          (new-edge-group :spouse {:type :indirected :body :simple}) => anything)
    (fact "New Veterxs"
          (new-vertex :people {:name "<NAME>"        :age 78}) => anything
          (new-vertex :movie {:name "<NAME>"         :year 2005}) => anything
          (new-vertex :movie {:name "The Dark Knight"       :year 2008}) => anything
          (new-vertex :movie {:name "The Dark Knight Rises" :year 2012}) => anything
          (new-vertex :movie {:name "Oblivion"              :year 2010}) => anything
          (new-vertex :people {:name "<NAME>"}) => anything)
    (fact "Check Veterxs"
          (get-vertex-by-key :people "<NAME>") => (contains {:name "<NAME>" :age 78})
          (get-vertex-by-key :movie "Batman Begins") => (contains {:name "<NAME>"  :year 2005})
          (get-vertex-by-key :movie "Oblivion") => (contains {:name "Oblivion" :year 2010}))
    (fact "Create Edges"
          (let [morgan-freeman (get-vertex-by-key :people "<NAME>")
                batman-begins  (get-vertex-by-key :movie "B<NAME>s")
                dark-knight    (get-vertex-by-key :movie "The Dark Knight")
                oblivion       (get-vertex-by-key :movie "Oblivion")
                jeanette-adair-bradshaw (get-vertex-by-key :people "<NAME>")]
            (create-edge morgan-freeman :acted-in batman-begins {:as "<NAME>"}) => anything
            (create-edge morgan-freeman :acted-in dark-knight {:as "<NAME>"}) => anything
            (create-edge morgan-freeman :acted-in oblivion {:as "<NAME>"}) => anything
            (create-edge morgan-freeman :spouse jeanette-adair-bradshaw) => anything))
    (fact "Read Edges"
          (let [morgan-freeman (get-vertex-by-key :people "<NAME>")
                batman-begins  (get-vertex-by-key :movie "<NAME>s")]
            (neighbours morgan-freeman) => (contains [(contains {:*ep* (contains {:name :spouse, :type :indirected}), :*direction* :*neighbours*})
                                                      (contains {:*ep* (contains {:name :acted-in, :type :directed}), :*direction* :*outbounds*})]
                                                     :gaps-ok :in-any-order)
            (neighbours morgan-freeman) => #(= 4 (count %))
            (neighbours morgan-freeman :directions :*outbounds*) => (just [(contains {:*ep* (contains {:name :acted-in, :type :directed}) :*direction* :*outbounds*})
                                                                           (contains {:*ep* (contains {:name :acted-in, :type :directed}),  :*direction* :*outbounds*})
                                                                           (contains {:*ep* (contains {:name :acted-in, :type :directed}),  :*direction* :*outbounds*})])
            (neighbours morgan-freeman :relationships :spouse) => (just [(contains {:*ep* (contains {:name :spouse, :type :indirected}),  :*direction* :*neighbours*})])
            (neighbours batman-begins) => (just [(contains {:*ep* (contains {:name :acted-in :type :directed}) :*direction* :*inbounds*})])))
    (fact "Update Defined Vertex"
          (update-vertex (get-vertex-by-key :movie "Oblivion")
                         'clojure.core/assoc :year 2013) => anything)
    (fact "Check Updated Defined Vertex"
          (get-vertex-by-key :movie "Oblivion") => (contains {:name "Oblivion" :year 2013}))
    (fact "Update Dynamic Vertex"
          (update-vertex (get-vertex-by-key :people "<NAME>")
                         'clojure.core/assoc :said "Every time I show up and explain something, I earn a freckle.") => anything)
    (fact "Check Updated Dynamic Vertex"
          (get-vertex-by-key :people "<NAME>") => (contains {:said "Every time I show up and explain something, I earn a freckle."})
          (neighbours (get-vertex-by-key :people "<NAME>")) => #(= 4 (count %)))
    (fact "Reset Vertex"
          (reset-vertex (get-vertex-by-key :movie "Batman Begins") {:name "<NAME>" :year 2005 :directed-by "<NAME>"}) => anything
          (neighbours (get-vertex-by-key :movie "Batman Begins")) => #(= 1 (count %))
          (get-vertex-by-key :movie "Batman Begins") => (contains {:name "<NAME>" :year 2005 :directed-by "<NAME>"}))
    (fact "Delete Vertex"
          (delete-vertex (get-vertex-by-key :people "<NAME>")) => anything
          (delete-vertex (get-vertex-by-key :movie "Oblivion")) => anything)
    (fact "Check Deleted Vertex"
          (let [morgan-freeman (get-vertex-by-key :people "<NAME>")]
            (get-vertex-by-key :people "<NAME>") => nil?
            (get-vertex-by-key :movie "Oblivion") => nil?
            (neighbours morgan-freeman) => #(= 2 (count %))))))<commit_msg>one more edge in tast case<commit_after>(ns morpheus.tests.modeling
  (:require [midje.sweet :refer :all]
            [morpheus.tests.server :refer [with-server]]
            [morpheus.models.vertex.core :refer :all]
            [morpheus.models.edge.core :refer :all]
            [cluster-connector.utils.for-debug :refer [$ spy]]))

(facts
  "CRUD for Veterxies and Edges"
  (with-server
    (fact "Create Veterx Schema"
          (new-vertex-group :movie {:body :defined :key-field :name
                                    :fields [[:name :text]
                                             [:year :short]
                                             [:directed-by :obj]]}) => anything
          (new-vertex-group :people {:body :dynamic :key-field :name}) => anything)
    (fact "Create Edge Schema"
          (new-edge-group :acted-in {:type :directed :body :dynamic}) => anything
          (new-edge-group :spouse {:type :indirected :body :simple}) => anything)
    (fact "New Veterxs"
          (new-vertex :people {:name "<NAME>"        :age 78}) => anything
          (new-vertex :movie {:name "<NAME>"         :year 2005}) => anything
          (new-vertex :movie {:name "The Dark Knight"       :year 2008}) => anything
          (new-vertex :movie {:name "The Dark Knight Rises" :year 2012}) => anything
          (new-vertex :movie {:name "Oblivion"              :year 2010}) => anything
          (new-vertex :people {:name "<NAME>"}) => anything)
    (fact "Check Veterxs"
          (get-vertex-by-key :people "<NAME>") => (contains {:name "<NAME>" :age 78})
          (get-vertex-by-key :movie "Batman Begins") => (contains {:name "Batman Begins"  :year 2005})
          (get-vertex-by-key :movie "Oblivion") => (contains {:name "Oblivion" :year 2010}))
    (fact "Create Edges"
          (let [morgan-freeman (get-vertex-by-key :people "<NAME>")
                batman-begins  (get-vertex-by-key :movie "Batman Begins")
                dark-knight    (get-vertex-by-key :movie "The Dark Knight")
                oblivion       (get-vertex-by-key :movie "Oblivion")
                dark-knight-rises (get-vertex-by-key :name "The Dark Knight Rises")
                jeanette-adair-bradshaw (get-vertex-by-key :people "<NAME>")]
            (create-edge morgan-freeman :acted-in batman-begins {:as "<NAME>"}) => anything
            (create-edge morgan-freeman :acted-in dark-knight {:as "<NAME>"}) => anything
            (create-edge morgan-freeman :acted-in oblivion {:as "<NAME>"}) => anything
            (create-edge morgan-freeman :acted-in dark-knight-rises {:as "<NAME>"}) => anything
            (create-edge morgan-freeman :spouse jeanette-adair-bradshaw) => anything))
    (fact "Read Edges"
          (let [morgan-freeman (get-vertex-by-key :people "<NAME>")
                batman-begins  (get-vertex-by-key :movie "Batman Begins")]
            (neighbours morgan-freeman) => (contains [(contains {:*ep* (contains {:name :spouse, :type :indirected}), :*direction* :*neighbours*})
                                                      (contains {:*ep* (contains {:name :acted-in, :type :directed}), :*direction* :*outbounds*})]
                                                     :gaps-ok :in-any-order)
            (neighbours morgan-freeman) => #(= 5 (count %))
            (neighbours morgan-freeman :directions :*outbounds*) => (just [(contains {:*ep* (contains {:name :acted-in, :type :directed}) :*direction* :*outbounds*})
                                                                           (contains {:*ep* (contains {:name :acted-in, :type :directed}),  :*direction* :*outbounds*})
                                                                           (contains {:*ep* (contains {:name :acted-in, :type :directed}),  :*direction* :*outbounds*})
                                                                           (contains {:*ep* (contains {:name :acted-in, :type :directed}),  :*direction* :*outbounds*})])
            (neighbours morgan-freeman :relationships :spouse) => (just [(contains {:*ep* (contains {:name :spouse, :type :indirected}),  :*direction* :*neighbours*})])
            (neighbours batman-begins) => (just [(contains {:*ep* (contains {:name :acted-in :type :directed}) :*direction* :*inbounds*})])))
    (fact "Update Defined Vertex"
          (update-vertex (get-vertex-by-key :movie "Oblivion")
                         'clojure.core/assoc :year 2013) => anything)
    (fact "Check Updated Defined Vertex"
          (get-vertex-by-key :movie "Oblivion") => (contains {:name "Oblivion" :year 2013}))
    (fact "Update Dynamic Vertex"
          (update-vertex (get-vertex-by-key :people "<NAME>")
                         'clojure.core/assoc :said "Every time I show up and explain something, I earn a freckle.") => anything)
    (fact "Check Updated Dynamic Vertex"
          (get-vertex-by-key :people "<NAME>") => (contains {:said "Every time I show up and explain something, I earn a freckle."})
          (neighbours (get-vertex-by-key :people "<NAME>")) => #(= 5 (count %)))
    (fact "Reset Vertex"
          (reset-vertex (get-vertex-by-key :movie "Batman Begins") {:name "<NAME>" :year 2005 :directed-by "<NAME>"}) => anything
          (neighbours (get-vertex-by-key :movie "Batman Begins")) => #(= 1 (count %))
          (get-vertex-by-key :movie "Batman Begins") => (contains {:name "<NAME>" :year 2005 :directed-by "<NAME>"}))
    (fact "Delete Vertex"
          (delete-vertex (get-vertex-by-key :people "<NAME>")) => anything
          (delete-vertex (get-vertex-by-key :movie "Oblivion")) => anything)
    (fact "Check Deleted Vertex"
          (let [morgan-freeman (get-vertex-by-key :people "<NAME>")]
            (get-vertex-by-key :people "<NAME>") => nil?
            (get-vertex-by-key :movie "Oblivion") => nil?
            (neighbours morgan-freeman) => #(= 3 (count %))))))
{'fraction_non_alphanumeric': 0.16654935773359142, 'fraction_numerical': 0.008446243181418265, 'mean_word_length': 2.193874683899972, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 120, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 33, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7536194', 'n_tokens_mistral': 3666, 'n_tokens_neox': 3352, 'n_words': 902}