Repository: CSCfi/rems
Pull request #3094 (2022-11-30 13:00:33)

Rename rems.db.test-data namespace to rems.service.test-data
relates #3017

- rename `rems.db.test-data` ns to `rems.service.test-data` and update references from other namespaces
- update `rems.service.test-data` ns docstring

# Checklist for author

Remove items that aren't applicable, check items that are done.

## Reviewability
- [x] Link to issue



Patch:
diff --git a/src/clj/rems/main.clj b/src/clj/rems/main.clj
index 8264f9c72..16832f228 100644
--- a/src/clj/rems/main.clj
+++ b/src/clj/rems/main.clj
@@ -18,7 +18,7 @@
             [rems.db.core :as db]
             [rems.db.fix-userid]
             [rems.db.roles :as roles]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.db.users :as users]
             [rems.handler :as handler]
             [rems.json :as json]


Test patch:
diff --git a/src/clj/rems/db/test_data.clj b/src/clj/rems/service/test_data.clj
similarity index 99%
rename from src/clj/rems/db/test_data.clj
rename to src/clj/rems/service/test_data.clj
index d38cb03e2..0449f1bd6 100644
--- a/src/clj/rems/db/test_data.clj
+++ b/src/clj/rems/service/test_data.clj
@@ -1,5 +1,7 @@
-(ns rems.db.test-data
-  "Populating the database with nice test data."
+(ns rems.service.test-data
+  "Generate and populate database with usable test data. Contains multiple high-level
+   test data helper functions. Separate functions are provided to generate complete
+   test and demo data, which create the same data, but with different users."
   (:require [clj-time.core :as time]
             [clojure.string :as str]
             [clojure.test :refer :all]
diff --git a/test/clj/rems/api/test_applications.clj b/test/clj/rems/api/test_applications.clj
index 35c1c5e1c..febd9dc99 100644
--- a/test/clj/rems/api/test_applications.clj
+++ b/test/clj/rems/api/test_applications.clj
@@ -11,7 +11,7 @@
             [rems.db.attachments]
             [rems.db.blacklist :as blacklist]
             [rems.db.core :as db]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.db.test-data-helpers :as test-helpers]
             [rems.handler :refer [handler]]
             [rems.json]
diff --git a/test/clj/rems/api/test_catalogue.clj b/test/clj/rems/api/test_catalogue.clj
index 99a230fa1..091d02d7d 100644
--- a/test/clj/rems/api/test_catalogue.clj
+++ b/test/clj/rems/api/test_catalogue.clj
@@ -3,7 +3,7 @@
             [rems.service.catalogue :as catalogue]
             [rems.api.testing :refer :all]
             [rems.db.category :as category]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.db.test-data-helpers :as test-helpers]
             [rems.handler :refer [handler]]
             [rems.testing-util :refer [with-user]]
diff --git a/test/clj/rems/api/test_email.clj b/test/clj/rems/api/test_email.clj
index 2d5313cc0..d9c9ca590 100644
--- a/test/clj/rems/api/test_email.clj
+++ b/test/clj/rems/api/test_email.clj
@@ -4,7 +4,7 @@
             [rems.api.testing :refer :all]
             [rems.db.outbox :as outbox]
             [rems.db.test-data-helpers :as test-helpers]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.handler :refer [handler]]
             [ring.mock.request :refer :all]))
 
diff --git a/test/clj/rems/api/test_extra_pages.clj b/test/clj/rems/api/test_extra_pages.clj
index f942312a6..63e681c7b 100644
--- a/test/clj/rems/api/test_extra_pages.clj
+++ b/test/clj/rems/api/test_extra_pages.clj
@@ -1,6 +1,6 @@
 (ns ^:integration rems.api.test-extra-pages
   (:require [clojure.test :refer :all]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.api.testing :refer :all]
             [rems.handler :refer [handler]]
             [ring.mock.request :refer :all]))
diff --git a/test/clj/rems/api/test_invitations.clj b/test/clj/rems/api/test_invitations.clj
index ec3257ddd..316225800 100644
--- a/test/clj/rems/api/test_invitations.clj
+++ b/test/clj/rems/api/test_invitations.clj
@@ -3,7 +3,7 @@
             [rems.service.invitation :as invitation]
             [rems.api.testing :refer :all]
             [rems.db.applications]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.db.test-data-helpers :as test-helpers]
             [rems.json]
             [rems.testing-util :refer [with-user]]
diff --git a/test/clj/rems/api/test_permissions.clj b/test/clj/rems/api/test_permissions.clj
index 397a90e87..00cbe9be3 100644
--- a/test/clj/rems/api/test_permissions.clj
+++ b/test/clj/rems/api/test_permissions.clj
@@ -4,7 +4,7 @@
             [buddy.core.keys :as buddy-keys]
             [clojure.test :refer :all]
             [rems.api.testing :refer :all]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.db.test-data-helpers :as test-helpers]
             [rems.config]
             [rems.ga4gh :as ga4gh]
diff --git a/test/clj/rems/api/test_user_settings.clj b/test/clj/rems/api/test_user_settings.clj
index 611a7f6f1..2cd5690c0 100644
--- a/test/clj/rems/api/test_user_settings.clj
+++ b/test/clj/rems/api/test_user_settings.clj
@@ -3,7 +3,7 @@
             [clojure.test :refer :all]
             [clj-time.core :as time-core]
             [rems.api.testing :refer :all]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.db.test-data-helpers :as test-helpers]
             [rems.db.user-secrets :as user-secrets]
             [rems.db.user-settings :as user-settings]
diff --git a/test/clj/rems/api/test_users.clj b/test/clj/rems/api/test_users.clj
index e56f3d818..5d7c2e446 100644
--- a/test/clj/rems/api/test_users.clj
+++ b/test/clj/rems/api/test_users.clj
@@ -3,7 +3,7 @@
             [rems.api.testing :refer :all]
             [rems.testing-util :refer [with-fake-login-users]]
             [rems.db.roles :as roles]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.db.testing :refer [owners-fixture +test-api-key+]]
             [rems.db.users :as users]
             [rems.db.user-mappings :as user-mappings]
diff --git a/test/clj/rems/application/test_process_managers.clj b/test/clj/rems/application/test_process_managers.clj
index 60ce2d446..4cf2df071 100644
--- a/test/clj/rems/application/test_process_managers.clj
+++ b/test/clj/rems/application/test_process_managers.clj
@@ -5,7 +5,7 @@
             [rems.api.testing :refer :all]
             [rems.db.attachments :as attachments]
             [rems.db.applications :as applications]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.db.test-data-helpers :as test-helpers]
             [rems.handler :refer [handler]]
             [ring.mock.request :refer :all]))
diff --git a/test/clj/rems/application/test_search.clj b/test/clj/rems/application/test_search.clj
index 6287f8c0a..15b6a962c 100644
--- a/test/clj/rems/application/test_search.clj
+++ b/test/clj/rems/application/test_search.clj
@@ -2,7 +2,7 @@
   (:require [clojure.test :refer :all]
             [rems.application.search :as search]
             [rems.db.applications :as applications]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.db.test-data-helpers :as test-helpers]
             [rems.db.testing :refer [rollback-db-fixture search-index-fixture test-db-fixture]]))
 
diff --git a/test/clj/rems/browser_test_util.clj b/test/clj/rems/browser_test_util.clj
index 5e64e2657..b0cc557f0 100644
--- a/test/clj/rems/browser_test_util.clj
+++ b/test/clj/rems/browser_test_util.clj
@@ -15,7 +15,7 @@
             [rems.db.api-key :as api-key]
             [rems.db.test-data-helpers :as test-helpers]
             [rems.db.test-data-users :as test-users]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.json :as json]
             [rems.main]
             [rems.util :refer [ensure-empty-directory!]]
@@ -171,7 +171,7 @@
   (test-helpers/create-user! (get test-users/+fake-user-data+ "developer"))
   (test-helpers/create-workflow! nil) ;;master workflow
   ;; Forms, workflows etc.
-  ;; These should match the rems.db.test-data closely enough
+  ;; These should match the rems.service.test-data closely enough
   ;; so that one can use also development mode and dev db
   ;; with the tests
   (let [link (test-helpers/create-license! {:actor "owner"
diff --git a/test/clj/rems/db/testing.clj b/test/clj/rems/db/testing.clj
index e59379106..c89b06faa 100644
--- a/test/clj/rems/db/testing.clj
+++ b/test/clj/rems/db/testing.clj
@@ -11,7 +11,7 @@
             [rems.db.catalogue :as catalogue]
             [rems.db.category :as category]
             [rems.db.core :as db]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.db.user-mappings :as user-mappings]
             [rems.locales])
   (:import [org.joda.time Duration ReadableInstant]))
diff --git a/test/clj/rems/test_db.clj b/test/clj/rems/test_db.clj
index f002cf79b..3533da5a0 100644
--- a/test/clj/rems/test_db.clj
+++ b/test/clj/rems/test_db.clj
@@ -8,7 +8,7 @@
             [rems.db.core :as db]
             [rems.db.entitlements :as entitlements]
             [rems.db.roles :as roles]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.db.test-data-helpers :as test-helpers]
             [rems.db.testing :refer [test-db-fixture rollback-db-fixture]]
             [rems.testing-tempura :refer [fake-tempura-fixture]])
diff --git a/test/clj/rems/test_event_notification.clj b/test/clj/rems/test_event_notification.clj
index de8b8aeb8..cc189e6ba 100644
--- a/test/clj/rems/test_event_notification.clj
+++ b/test/clj/rems/test_event_notification.clj
@@ -6,7 +6,7 @@
             [rems.service.command :as command]
             [rems.api.testing :refer [api-fixture api-call]]
             [rems.db.events]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.db.test-data-helpers :as test-helpers]
             [rems.event-notification :as event-notification]
             [rems.json :as json]
diff --git a/test/clj/rems/test_layers.clj b/test/clj/rems/test_layers.clj
index 245b4db37..885f5c160 100644
--- a/test/clj/rems/test_layers.clj
+++ b/test/clj/rems/test_layers.clj
@@ -26,10 +26,10 @@
            (str/starts-with? s "rems.service.")
            (str/starts-with? s "rems.api"))))
 
+;; use for future namespace renaming needs
 (defn rename-ns [s]
-  ;; TODO implement these namespace renames
   (-> s
-      (str/replace "rems.db.test-data" "rems.service.test-data")))
+      #_(str/replace "rems.db.test-data" "rems.service.test-data")))
 
 (defn ok-transition? [from to]
   (case [(:layer from) (:layer to)]
@@ -49,7 +49,7 @@
                         :namespace-definitions
                         (mapv (comp str :name))
                         ;;(concat ["rems.cli"]) ; consider implementing `rems.cli` ns
-                        (mapv rename-ns)
+                        #_(mapv rename-ns)
                         (filter interesting-ns?)
                         (mapv #(merge {:name %}
                                       (cond (str/starts-with? % "rems.ext.") {:layer :ext}
@@ -63,7 +63,7 @@
                               :namespace-usages
                               (map (juxt (comp str :from) (comp str :to)))
                               distinct
-                              (map (fn [[from to]] [(rename-ns from) (rename-ns to)]))
+                              #_(map (fn [[from to]] [(rename-ns from) (rename-ns to)]))
                               (filterv (fn [[from to]]
                                          (and (interesting-ns? from)
                                               (interesting-ns? to))))
diff --git a/test/clj/rems/test_pdf.clj b/test/clj/rems/test_pdf.clj
index e1af1387b..128b5d4d2 100644
--- a/test/clj/rems/test_pdf.clj
+++ b/test/clj/rems/test_pdf.clj
@@ -3,7 +3,7 @@
             [clojure.test :refer :all]
             [rems.db.applications :as applications]
             [rems.db.core :as db]
-            [rems.db.test-data :as test-data]
+            [rems.service.test-data :as test-data]
             [rems.db.test-data-helpers :as test-helpers]
             [rems.db.testing :refer [test-db-fixture rollback-db-fixture]]
             [rems.pdf :as pdf]