Skip to content

Commit

Permalink
Moved mip-algorithms test urls in __init__.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThanKarab committed Dec 20, 2021
1 parent d08b6f0 commit b42b006
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 88 deletions.
15 changes: 15 additions & 0 deletions Exareme-Docker/src/mip-algorithms/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@

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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@

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/'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@

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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@

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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@

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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@

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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@

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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@

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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@

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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@

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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@

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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@

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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
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():
Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
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"},
Expand All @@ -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")
Expand All @@ -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"},
Expand All @@ -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
Expand All @@ -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"},
Expand All @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,19 @@
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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
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():
Expand Down

0 comments on commit b42b006

Please sign in to comment.