From b42b00675e27ec397ef32383484ea0357dbbd229 Mon Sep 17 00:00:00 2001
From: ThanKarab <tkarabatsis@hotmail.com>
Date: Mon, 20 Dec 2021 18:53:25 +0200
Subject: [PATCH] Moved mip-algorithms test urls in __init__.

---
 .../src/mip-algorithms/tests/__init__.py      | 15 ++++++++
 .../test_ANOVA.py                             |  5 +--
 .../algorithm_tests_with_privacy/test_Cart.py |  3 +-
 .../test_Histograms.py                        |  4 +--
 .../algorithm_tests_with_privacy/test_ID3.py  |  5 +--
 .../test_KMEANS.py                            |  4 +--
 .../test_LinearRegression.py                  |  4 +--
 .../test_MultipleHistograms.py                |  4 +--
 .../test_NaiveBayes.py                        |  9 ++---
 .../test_NaiveBayes_Training_Standalone.py    |  4 +--
 .../test_ttest_independent.py                 |  4 +--
 .../test_ttest_onesample.py                   |  5 +--
 .../test_ttest_paired.py                      |  4 +--
 .../exareme_tests/test_missingDataset.py      |  4 +--
 .../exareme_tests/test_missingPathology.py    |  6 ++--
 .../tests/exareme_tests/test_parameters.py    | 17 ++++-----
 .../tests/exareme_tests/test_privacy.py       | 35 +++++++------------
 .../tests/exareme_tests/test_wrongDataset.py  |  4 +--
 .../exareme_tests/test_wrongPathology.py      |  4 +--
 19 files changed, 52 insertions(+), 88 deletions(-)

diff --git a/Exareme-Docker/src/mip-algorithms/tests/__init__.py b/Exareme-Docker/src/mip-algorithms/tests/__init__.py
index 8fb2ad354..6c720a151 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/__init__.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/__init__.py
@@ -1 +1,16 @@
 vm_url = "http://88.197.53.100:9090/mining/query/"
+
+anova_url = vm_url + "ANOVA"
+cart_url = vm_url + "CART"
+histograms_url = vm_url + "HISTOGRAMS"
+id3_url = vm_url + "ID3"
+kmeans_url = vm_url + "KMEANS"
+linear_regression_url = vm_url + "LINEAR_REGRESSION"
+multiple_histograms_url = vm_url + "MULTIPLE_HISTOGRAMS"
+cross_validation_url = vm_url + "CROSS_VALIDATION_K_FOLD"
+naive_bayes_training_url = vm_url + "NAIVE_BAYES_TRAINING"
+naive_bayes_testing_url = vm_url + "NAIVE_BAYES_TESTING"
+naive_bayes_training_standalone_url = vm_url + "NAIVE_BAYES_TRAINING_STANDALONE"
+ttest_independent_url = vm_url + "TTEST_INDEPENDENT"
+ttest_onesample_url = vm_url + "TTEST_ONESAMPLE"
+ttest_paired_url = vm_url + "TTEST_PAIRED"
diff --git a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ANOVA.py b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ANOVA.py
index d6cf005ff..456d33185 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ANOVA.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ANOVA.py
@@ -10,11 +10,8 @@ import rpy2.robjects as robjects
 
 import sys
 from os import path
-
 sys.path.append(path.abspath(__file__))
-from tests import vm_url
-
-endpointUrl = vm_url + "ANOVA"
+from tests import anova_url as endpointUrl
 
 folderPath = "R_scripts"
 file = "ANOVA.Rmd"
diff --git a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_Cart.py b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_Cart.py
index fe68ef56a..0e790c1a7 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_Cart.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_Cart.py
@@ -21,9 +21,8 @@ from scipy import stats
 
 from os import path
 sys.path.append(path.abspath(__file__))
+from tests import cart_url as endpointUrl_CartTraining
 
-from tests import vm_url
-endpointUrl_CartTraining= vm_url + 'CART'
 #endpointUrl_CartPredict= vm_url + 'CART_PREDICT'
 path = '../data/dementia/'
 
diff --git a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_Histograms.py b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_Histograms.py
index aa96f53a3..cd8b6ec05 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_Histograms.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_Histograms.py
@@ -10,11 +10,9 @@ import rpy2.robjects as robjects
 
 import sys
 from os import path
-
 sys.path.append(path.abspath(__file__))
-from tests import vm_url
+from tests import histograms_url as endpointUrl
 
-endpointUrl = vm_url + "HISTOGRAMS"
 folderPath = "R_scripts"
 file = "Histograms.Rmd"
 
diff --git a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ID3.py b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ID3.py
index ff5400181..c3d6ac0ae 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ID3.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ID3.py
@@ -5,11 +5,8 @@ import re
 
 import sys
 from os import path
-
 sys.path.append(path.abspath(__file__))
-from tests import vm_url
-
-endpointUrl = vm_url + "ID3"
+from tests import id3_url as endpointUrl
 
 
 def test_ID3_1():
diff --git a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_KMEANS.py b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_KMEANS.py
index b72440dbc..8eefd850d 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_KMEANS.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_KMEANS.py
@@ -10,11 +10,9 @@ import rpy2.robjects as robjects
 
 import sys
 from os import path
-
 sys.path.append(path.abspath(__file__))
-from tests import vm_url
+from tests import kmeans_url as endpointUrl
 
-endpointUrl = vm_url + "KMEANS"
 folderPath = "R_scripts"
 file = "kMeans.Rmd"
 
diff --git a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_LinearRegression.py b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_LinearRegression.py
index 5d2ac66e2..4d4534ab5 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_LinearRegression.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_LinearRegression.py
@@ -11,11 +11,9 @@ import rpy2.robjects as robjects
 
 import sys
 from os import path
-
 sys.path.append(path.abspath(__file__))
-from tests import vm_url
+from tests import linear_regression_url as endpointUrl
 
-endpointUrl = vm_url + "LINEAR_REGRESSION"
 folderPath = "R_scripts"
 file = "LinearRegression.Rmd"
 
diff --git a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_MultipleHistograms.py b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_MultipleHistograms.py
index 572f581b0..af4d58ab2 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_MultipleHistograms.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_MultipleHistograms.py
@@ -10,11 +10,9 @@ import rpy2.robjects as robjects
 
 import sys
 from os import path
-
 sys.path.append(path.abspath(__file__))
-from tests import vm_url
+from tests import multiple_histograms_url as endpointUrl
 
-endpointUrl = vm_url + "MULTIPLE_HISTOGRAMS"
 folderPath = "R_scripts"
 file = "MultipleHistograms.Rmd"
 
diff --git a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_NaiveBayes.py b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_NaiveBayes.py
index 4c42080ff..e502f258b 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_NaiveBayes.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_NaiveBayes.py
@@ -6,13 +6,10 @@ from decimal import *
 
 import sys
 from os import path
-
 sys.path.append(path.abspath(__file__))
-from tests import vm_url
-
-url1 = vm_url + "CROSS_VALIDATION_K_FOLD"
-url2 = vm_url + "NAIVE_BAYES_TRAINING"
-url3 = vm_url + "NAIVE_BAYES_TESTING"
+from tests import cross_validation_url as url1
+from tests import naive_bayes_training_url as url2
+from tests import naive_bayes_testing_url as url3
 
 
 def test_NAIVEBAYES_1():
diff --git a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_NaiveBayes_Training_Standalone.py b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_NaiveBayes_Training_Standalone.py
index d85c855fe..61137714c 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_NaiveBayes_Training_Standalone.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_NaiveBayes_Training_Standalone.py
@@ -11,11 +11,9 @@ import rpy2.robjects as robjects
 
 import sys
 from os import path
-
 sys.path.append(path.abspath(__file__))
-from tests import vm_url
+from tests import naive_bayes_training_standalone_url as endpointUrl
 
-endpointUrl = vm_url + "NAIVE_BAYES_TRAINING_STANDALONE"
 folderPath = "R_scripts"
 file = "NaiveBayes_Training_Standalone.Rmd"
 
diff --git a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ttest_independent.py b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ttest_independent.py
index 9347317fb..e422fe832 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ttest_independent.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ttest_independent.py
@@ -10,11 +10,9 @@ import rpy2.robjects as robjects
 
 import sys
 from os import path
-
 sys.path.append(path.abspath(__file__))
-from tests import vm_url
+from tests import ttest_independent_url as endpointUrl
 
-endpointUrl = vm_url + "TTEST_INDEPENDENT"
 folderPath = "R_scripts"
 file = "ttest_independent.Rmd"
 
diff --git a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ttest_onesample.py b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ttest_onesample.py
index 46753e3e5..b6bbe74f7 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ttest_onesample.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ttest_onesample.py
@@ -8,14 +8,11 @@ from decimal import *
 
 import rpy2.robjects as robjects
 
-
 import sys
 from os import path
-
 sys.path.append(path.abspath(__file__))
-from tests import vm_url
+from tests import ttest_onesample_url as endpointUrl
 
-endpointUrl = vm_url + "TTEST_ONESAMPLE"
 folderPath = "R_scripts"
 file = "ttest_onesample.Rmd"
 
diff --git a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ttest_paired.py b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ttest_paired.py
index 49c3450c8..54c5b7bbc 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ttest_paired.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/algorithm_tests_with_privacy/test_ttest_paired.py
@@ -10,11 +10,9 @@ import rpy2.robjects as robjects
 
 import sys
 from os import path
-
 sys.path.append(path.abspath(__file__))
-from tests import vm_url
+from tests import ttest_paired_url as endpointUrl
 
-endpointUrl = vm_url + "TTEST_PAIRED"
 folderPath = "R_scripts"
 file = "ttest_paired.Rmd"
 
diff --git a/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_missingDataset.py b/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_missingDataset.py
index 25ac28bca..cc9ec5a21 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_missingDataset.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_missingDataset.py
@@ -5,9 +5,7 @@ import logging
 import sys
 
 sys.path.insert(0, "../")
-from tests import vm_url
-
-endpointUrl = vm_url + "LINEAR_REGRESSION"
+from tests import linear_regression_url as endpointUrl
 
 
 def test_LINEAR_REGRESSION():
diff --git a/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_missingPathology.py b/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_missingPathology.py
index 5c75907b4..327768c0b 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_missingPathology.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_missingPathology.py
@@ -5,9 +5,7 @@ import logging
 import sys
 
 sys.path.insert(0, "../")
-from tests import vm_url
-
-endpointUrl = vm_url + "LINEAR_REGRESSION"
+from tests import linear_regression_url
 
 
 def test_LINEAR_REGRESSION():
@@ -22,7 +20,7 @@ def test_LINEAR_REGRESSION():
         {"name": "filter", "value": ""},
     ]
     headers = {"Content-type": "application/json", "Accept": "text/plain"}
-    r = requests.post(endpointUrl, data=json.dumps(data), headers=headers)
+    r = requests.post(linear_regression_url, data=json.dumps(data), headers=headers)
     result = json.loads(r.text)
     check_result(r.text)
 
diff --git a/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_parameters.py b/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_parameters.py
index fbd534d60..a5c9bbcef 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_parameters.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_parameters.py
@@ -5,14 +5,13 @@ import logging
 import sys
 
 sys.path.insert(0, "../")
-from tests import vm_url
-
+from tests import ttest_paired_url
+from tests import linear_regression_url
+from tests import anova_url
 
 
 def test_parameter_modulo2():
 
-    endpointUrl1 = vm_url + "TTEST_PAIRED"
-
     logging.info("---------- TEST : t-test input parameters throwing error.")
     data = [
        {"name": "y", "value": "lefthippocampus-righthippocampus,leftententorhinalarea"},
@@ -22,7 +21,7 @@ def test_parameter_modulo2():
        {"name": "filter", "value": ""},
     ]
     headers = {"Content-type": "application/json", "Accept": "text/plain"}
-    r = requests.post(endpointUrl1, data=json.dumps(data), headers=headers)
+    r = requests.post(ttest_paired_url, data=json.dumps(data), headers=headers)
     result = json.loads(r.text)
     assert(result["result"][0]["data"]==" The input should be in the form of y1-y2,y3-y4,.. Therefore the number of variables should be modulo 2 ")
     assert(result["result"][0]["type"]=="text/plain+user_error")
@@ -31,8 +30,6 @@ def test_parameter_modulo2():
 
 def test_valueEnumerationsParameter():
 
-    endpointUrl1 = vm_url + "LINEAR_REGRESSION"
-
     logging.info("---------- TEST : valueEnumerations throwing error.")
     data = [
         {"name": "x", "value": "alzheimerbroadcategory*gender*brainstem*opticchiasm"},
@@ -44,7 +41,7 @@ def test_valueEnumerationsParameter():
         {"name": "filter", "value": ""},
     ]
     headers = {"Content-type": "application/json", "Accept": "text/plain"}
-    r = requests.post(endpointUrl1, data=json.dumps(data), headers=headers)
+    r = requests.post(linear_regression_url, data=json.dumps(data), headers=headers)
     result = json.loads(r.text)
     assert (
         r.text
@@ -54,8 +51,6 @@ def test_valueEnumerationsParameter():
 
 def test_parameter_max_value():
 
-    endpointUrl = vm_url + "ANOVA"
-
     logging.info("---------- TEST : Algorithms for User Error")
     data = [
         {"name": "iterations_max_number", "value": "20"},
@@ -68,7 +63,7 @@ def test_parameter_max_value():
         {"name": "outputformat", "value": "pfa"},
     ]
     headers = {"Content-type": "application/json", "Accept": "text/plain"}
-    r = requests.post(endpointUrl, data=json.dumps(data), headers=headers)
+    r = requests.post(anova_url, data=json.dumps(data), headers=headers)
     result = json.loads(r.text)
 
     assert (
diff --git a/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_privacy.py b/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_privacy.py
index 1872d3547..d67cc65fb 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_privacy.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_privacy.py
@@ -4,30 +4,19 @@ import logging
 import unittest
 
 import requests
-from tests.algorithm_tests_with_privacy.test_ANOVA import endpointUrl as url_anova
+from tests import anova_url as url_anova
+from tests import histograms_url as url_hist
+from tests import id3_url as url_id3
+from tests import kmeans_url as url_kmeans
+from tests import linear_regression_url as url_linreg
+from tests import multiple_histograms_url as url_multi_hist
+from tests import cross_validation_url as url1
+from tests import naive_bayes_training_standalone_url as url_naive_bayes_standalone
+from tests import ttest_independent_url as url_ttest_indep
+from tests import ttest_onesample_url as url_ttest_onesample
+from tests import ttest_paired_url as url_ttest_paired
+
 from tests import vm_url
-from tests.algorithm_tests_with_privacy.test_Histograms import endpointUrl as url_hist
-from tests.algorithm_tests_with_privacy.test_ID3 import endpointUrl as url_id3
-from tests.algorithm_tests_with_privacy.test_KMEANS import endpointUrl as url_kmeans
-from tests.algorithm_tests_with_privacy.test_LinearRegression import (
-    endpointUrl as url_linreg,
-)
-from tests.algorithm_tests_with_privacy.test_MultipleHistograms import (
-    endpointUrl as url_multi_hist,
-)
-from tests.algorithm_tests_with_privacy.test_NaiveBayes import url1
-from tests.algorithm_tests_with_privacy.test_NaiveBayes_Training_Standalone import (
-    endpointUrl as url_naive_bayes_standalone,
-)
-from tests.algorithm_tests_with_privacy.test_ttest_independent import (
-    endpointUrl as url_ttest_indep,
-)
-from tests.algorithm_tests_with_privacy.test_ttest_onesample import (
-    endpointUrl as url_ttest_onesample,
-)
-from tests.algorithm_tests_with_privacy.test_ttest_paired import (
-    endpointUrl as url_ttest_paired,
-)
 
 url_calibration = vm_url + "CALIBRATION_BELT"
 url_pearson = vm_url + "PEARSON_CORRELATION"
diff --git a/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_wrongDataset.py b/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_wrongDataset.py
index ece5dbfe1..bfde57d81 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_wrongDataset.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_wrongDataset.py
@@ -5,9 +5,7 @@ import logging
 import sys
 
 sys.path.insert(0, "../")
-from tests import vm_url
-
-endpointUrl = vm_url + "LINEAR_REGRESSION"
+from tests import linear_regression_url as endpointUrl
 
 
 def test_LINEAR_REGRESSION():
diff --git a/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_wrongPathology.py b/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_wrongPathology.py
index 9b7892334..614b1c71c 100644
--- a/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_wrongPathology.py
+++ b/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_wrongPathology.py
@@ -5,9 +5,7 @@ import logging
 import sys
 
 sys.path.insert(0, "../")
-from tests import vm_url
-
-endpointUrl = vm_url + "LINEAR_REGRESSION"
+from tests import linear_regression_url as endpointUrl
 
 
 def test_LINEAR_REGRESSION():
-- 
GitLab