<commit_before>;
;  (C) Copyright 2016  <NAME>
;
;  All rights reserved. This program and the accompanying materials
;  are made available under the terms of the Eclipse Public License v1.0
;  which accompanies this distribution, and is available at
;  http://www.eclipse.org/legal/epl-v10.html
;
;  Contributors:
;      <NAME>
;

(ns zg.db-interface-test
  (:require [clojure.test :refer :all]
            [zg.db-interface :refer :all]))

;
; Common functions used by tests.
;

(defn callable?
    "Test if given function-name is bound to the real function."
    [function-name]
    (clojure.test/function? function-name))

;
; Tests for function existence
;

(deftest test-status->int-existence
    "Check that the zg.db-interface/status->int definition exists."
    (testing "if the zg.db-interface/status->int definition exists."
        (is (callable? 'zg.db-interface/status->int))))


(deftest test-dictionary-type->char-existence
    "Check that the zg.db-interface/dictionary-type->char definition exists."
    (testing "if the zg.db-interface/dictionary-type->char definition exists."
        (is (callable? 'zg.db-interface/dictionary-type->char))))


(deftest test-insert-word-into-dictionary-existence
    "Check that the zg.db-interface/insert-word-into-dictionary definition exists."
    (testing "if the zg.db-interface/insert-word-into-dictionary definition exists."
        (is (callable? 'zg.db-interface/insert-word-into-dictionary))))


(deftest test-add-new-word-into-dictionary-existence
    "Check that the zg.db-interface/add-new-word-into-dictionary definition exists."
    (testing "if the zg.db-interface/add-new-word-into-dictionary definition exists."
        (is (callable? 'zg.db-interface/add-new-word-into-dictionary))))


(deftest test-set-word-status-existence
    "Check that the zg.db-interface/set-word-status definition exists."
    (testing "if the zg.db-interface/set-word-status definition exists."
        (is (callable? 'zg.db-interface/set-word-status))))


(deftest test-delete-word-existence
    "Check that the zg.db-interface/delete-word definition exists."
    (testing "if the zg.db-interface/delete-word definition exists."
        (is (callable? 'zg.db-interface/delete-word))))


(deftest test-undelete-word-existence
    "Check that the zg.db-interface/undelete-word definition exists."
    (testing "if the zg.db-interface/undelete-word definition exists."
        (is (callable? 'zg.db-interface/undelete-word))))


(deftest test-read-all-words-existence
    "Check that the zg.db-interface/read-all-words definition exists."
    (testing "if the zg.db-interface/read-all-words definition exists."
        (is (callable? 'zg.db-interface/read-all-words))))


(deftest test-read-words-for-pattern-existence
    "Check that the zg.db-interface/read-words-for-pattern definition exists."
    (testing "if the zg.db-interface/read-words-for-pattern definition exists."
        (is (callable? 'zg.db-interface/read-words-for-pattern))))


(deftest test-read-words-with-status-existence
    "Check that the zg.db-interface/read-words-with-status definition exists."
    (testing "if the zg.db-interface/read-words-with-status definition exists."
        (is (callable? 'zg.db-interface/read-words-with-status))))


(deftest test-read-deleted-words-existence
    "Check that the zg.db-interface/read-deleted-words definition exists."
    (testing "if the zg.db-interface/read-deleted-words definition exists."
        (is (callable? 'zg.db-interface/read-deleted-words))))


(deftest test-read-active-words-existence
    "Check that the zg.db-interface/read-active-words definition exists."
    (testing "if the zg.db-interface/read-active-words definition exists."
        (is (callable? 'zg.db-interface/read-active-words))))


(deftest test-read-changes-statistic-existence
    "Check that the zg.db-interface/read-changes-statistic definition exists."
    (testing "if the zg.db-interface/read-changes-statistic definition exists."
        (is (callable? 'zg.db-interface/read-changes-statistic))))


(deftest test-read-changes-existence
    "Check that the zg.db-interface/read-changes definition exists."
    (testing "if the zg.db-interface/read-changes definition exists."
        (is (callable? 'zg.db-interface/read-changes))))


(deftest test-read-changes-for-user-existence
    "Check that the zg.db-interface/read-changes-for-user definition exists."
    (testing "if the zg.db-interface/read-changes-for-user definition exists."
        (is (callable? 'zg.db-interface/read-changes-for-user))))

<commit_msg>Two db-interface tests: test-status->int and test-dictionary-type->char<commit_after>;
;  (C) Copyright 2016  <NAME>
;
;  All rights reserved. This program and the accompanying materials
;  are made available under the terms of the Eclipse Public License v1.0
;  which accompanies this distribution, and is available at
;  http://www.eclipse.org/legal/epl-v10.html
;
;  Contributors:
;      <NAME>
;

(ns zg.db-interface-test
  (:require [clojure.test      :refer :all]
            [clojure.java.jdbc :as jdbc]
            [zg.db-interface   :refer :all]))

;
; Common functions used by tests.
;

(defn callable?
    "Test if given function-name is bound to the real function."
    [function-name]
    (clojure.test/function? function-name))

;
; Tests for function existence
;

(deftest test-status->int-existence
    "Check that the zg.db-interface/status->int definition exists."
    (testing "if the zg.db-interface/status->int definition exists."
        (is (callable? 'zg.db-interface/status->int))))


(deftest test-dictionary-type->char-existence
    "Check that the zg.db-interface/dictionary-type->char definition exists."
    (testing "if the zg.db-interface/dictionary-type->char definition exists."
        (is (callable? 'zg.db-interface/dictionary-type->char))))


(deftest test-insert-word-into-dictionary-existence
    "Check that the zg.db-interface/insert-word-into-dictionary definition exists."
    (testing "if the zg.db-interface/insert-word-into-dictionary definition exists."
        (is (callable? 'zg.db-interface/insert-word-into-dictionary))))


(deftest test-add-new-word-into-dictionary-existence
    "Check that the zg.db-interface/add-new-word-into-dictionary definition exists."
    (testing "if the zg.db-interface/add-new-word-into-dictionary definition exists."
        (is (callable? 'zg.db-interface/add-new-word-into-dictionary))))


(deftest test-set-word-status-existence
    "Check that the zg.db-interface/set-word-status definition exists."
    (testing "if the zg.db-interface/set-word-status definition exists."
        (is (callable? 'zg.db-interface/set-word-status))))


(deftest test-delete-word-existence
    "Check that the zg.db-interface/delete-word definition exists."
    (testing "if the zg.db-interface/delete-word definition exists."
        (is (callable? 'zg.db-interface/delete-word))))


(deftest test-undelete-word-existence
    "Check that the zg.db-interface/undelete-word definition exists."
    (testing "if the zg.db-interface/undelete-word definition exists."
        (is (callable? 'zg.db-interface/undelete-word))))


(deftest test-read-all-words-existence
    "Check that the zg.db-interface/read-all-words definition exists."
    (testing "if the zg.db-interface/read-all-words definition exists."
        (is (callable? 'zg.db-interface/read-all-words))))


(deftest test-read-words-for-pattern-existence
    "Check that the zg.db-interface/read-words-for-pattern definition exists."
    (testing "if the zg.db-interface/read-words-for-pattern definition exists."
        (is (callable? 'zg.db-interface/read-words-for-pattern))))


(deftest test-read-words-with-status-existence
    "Check that the zg.db-interface/read-words-with-status definition exists."
    (testing "if the zg.db-interface/read-words-with-status definition exists."
        (is (callable? 'zg.db-interface/read-words-with-status))))


(deftest test-read-deleted-words-existence
    "Check that the zg.db-interface/read-deleted-words definition exists."
    (testing "if the zg.db-interface/read-deleted-words definition exists."
        (is (callable? 'zg.db-interface/read-deleted-words))))


(deftest test-read-active-words-existence
    "Check that the zg.db-interface/read-active-words definition exists."
    (testing "if the zg.db-interface/read-active-words definition exists."
        (is (callable? 'zg.db-interface/read-active-words))))


(deftest test-read-changes-statistic-existence
    "Check that the zg.db-interface/read-changes-statistic definition exists."
    (testing "if the zg.db-interface/read-changes-statistic definition exists."
        (is (callable? 'zg.db-interface/read-changes-statistic))))


(deftest test-read-changes-existence
    "Check that the zg.db-interface/read-changes definition exists."
    (testing "if the zg.db-interface/read-changes definition exists."
        (is (callable? 'zg.db-interface/read-changes))))


(deftest test-read-changes-for-user-existence
    "Check that the zg.db-interface/read-changes-for-user definition exists."
    (testing "if the zg.db-interface/read-changes-for-user definition exists."
        (is (callable? 'zg.db-interface/read-changes-for-user))))

;
; Test function behaviour
;

(deftest test-status->int
    "Checking the function status->int."
    (testing "the function status->int."
        (are [x y] (= x (status->int y))
            1 :deleted
            0 :undeleted
            0 nil)))

(deftest test-dictionary-type->char
    "Checking the function dictionary-type->char."
    (testing "the function dictionary-type->char."
        (are [x y] (= x (dictionary-type->char y))
            "w" :whitelist
            "b" :blacklist
            "o" :other)))


{'fraction_non_alphanumeric': 0.13507981989357348, 'fraction_numerical': 0.0019443307408923455, 'mean_word_length': 3.420171867933062, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3284270', 'n_tokens_mistral': 3181, 'n_tokens_neox': 3048, 'n_words': 705}