Skip to content

Commit

Permalink
Move tests inside data_request_api package
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-mizielinski committed Jan 23, 2025
1 parent 956cb03 commit cb33b5d
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 252,147 deletions.
3 changes: 3 additions & 0 deletions data_request_api/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import os

TEST_DATA_LOCATION = os.path.join(os.path.dirname(__file__), 'test_datasets')
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

from data_request_api.stable.query.data_request import DRObjects, ExperimentsGroup, VariablesGroup, Opportunity, DataRequest, version
from data_request_api.stable.query.vocabulary_server import VocabularyServer, is_link_id_or_value
from data_request_api.tests import TEST_DATA_LOCATION


class TestDRObjects(unittest.TestCase):
def setUp(self):
self.dr = DataRequest.from_separated_inputs(VS_input="test_datasets/one_base_VS_output.json",
DR_input="test_datasets/one_base_DR_output.json")
#import pdb; pdb.set_trace()
self.dr = DataRequest.from_separated_inputs(VS_input=os.path.join(TEST_DATA_LOCATION,"one_base_VS_output.json"),
DR_input=os.path.join(TEST_DATA_LOCATION,"one_base_DR_output.json"))

def test_init(self):
with self.assertRaises(TypeError):
Expand Down Expand Up @@ -87,8 +89,8 @@ def test_filter_on_request(self):

class TestExperimentsGroup(unittest.TestCase):
def setUp(self):
self.dr = DataRequest.from_separated_inputs(VS_input="test_datasets/one_base_VS_output.json",
DR_input="test_datasets/one_base_DR_output.json")
self.dr = DataRequest.from_separated_inputs(VS_input=os.path.join(TEST_DATA_LOCATION,"one_base_VS_output.json"),
DR_input=os.path.join(TEST_DATA_LOCATION,"one_base_DR_output.json"))

def test_init(self):
with self.assertRaises(TypeError):
Expand Down Expand Up @@ -188,8 +190,8 @@ def test_filter_on_request(self):

class TestVariablesGroup(unittest.TestCase):
def setUp(self):
self.dr = DataRequest.from_separated_inputs(DR_input="test_datasets/one_base_DR_output.json",
VS_input="test_datasets/one_base_VS_output.json")
self.dr = DataRequest.from_separated_inputs(DR_input=os.path.join(TEST_DATA_LOCATION,"one_base_DR_output.json"),
VS_input=os.path.join(TEST_DATA_LOCATION,"one_base_VS_output.json"))

def test_init(self):
with self.assertRaises(TypeError):
Expand Down Expand Up @@ -296,8 +298,8 @@ def test_eq(self):

class TestOpportunity(unittest.TestCase):
def setUp(self):
self.dr = DataRequest.from_separated_inputs(DR_input="test_datasets/one_base_DR_output.json",
VS_input="test_datasets/one_base_VS_output.json")
self.dr = DataRequest.from_separated_inputs(DR_input=os.path.join(TEST_DATA_LOCATION,"one_base_DR_output.json"),
VS_input=os.path.join(TEST_DATA_LOCATION,"one_base_VS_output.json"))

def test_init(self):
with self.assertRaises(TypeError):
Expand Down Expand Up @@ -412,14 +414,14 @@ def test_eq(self):

class TestDataRequest(unittest.TestCase):
def setUp(self):
self.vs_file = "test_datasets/one_base_VS_output.json"
self.vs_file = os.path.join(TEST_DATA_LOCATION, "one_base_VS_output.json")
self.vs_dict = read_json_input_file_content(self.vs_file)
self.vs = VocabularyServer.from_input(self.vs_file)
self.input_database_file = "test_datasets/one_base_DR_output.json"
self.input_database_file = os.path.join(TEST_DATA_LOCATION, "one_base_DR_output.json")
self.input_database = read_json_input_file_content(self.input_database_file)
self.complete_input_file = "test_datasets/one_base_input.json"
self.complete_input_file = os.path.join(TEST_DATA_LOCATION, "one_base_input.json")
self.complete_input = read_json_input_file_content(self.complete_input_file)
self.DR_dump = "test_datasets/one_base_DR_dump.txt"
self.DR_dump = os.path.join(TEST_DATA_LOCATION, "one_base_DR_dump.txt")

def test_init(self):
with self.assertRaises(TypeError):
Expand Down Expand Up @@ -623,9 +625,9 @@ def test_get_themes(self):

class TestDataRequestFilter(unittest.TestCase):
def setUp(self):
self.vs_file = "test_datasets/one_base_VS_output.json"
self.vs_file = os.path.join(TEST_DATA_LOCATION, "one_base_VS_output.json")
self.vs = VocabularyServer.from_input(self.vs_file)
self.input_database_file = "test_datasets/one_base_DR_output.json"
self.input_database_file = os.path.join(TEST_DATA_LOCATION, "one_base_DR_output.json")
self.input_database = read_json_input_file_content(self.input_database_file)
self.dr = DataRequest(input_database=self.input_database, VS=self.vs)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
from __future__ import print_function, division, unicode_literals, absolute_import

import copy
import os
import unittest

from data_request_api.stable.utilities.tools import read_json_file, write_json_output_file_content
from data_request_api.stable.content.dump_transformation import correct_key_string, correct_dictionaries, transform_content_one_base,\
transform_content_three_bases, transform_content, split_content_one_base
from data_request_api.tests import TEST_DATA_LOCATION


class TestCorrectKeyString(unittest.TestCase):
Expand Down Expand Up @@ -78,21 +80,21 @@ def test_error(self):
class TestTransformContent(unittest.TestCase):
def setUp(self):
self.version = "test"
self.one_base_input = read_json_file("test_datasets/one_base_input.json")
self.one_base_output_format = read_json_file("test_datasets/one_base_output_format.json")
self.one_base_output_transform = read_json_file("test_datasets/one_base_output_transform.json")
self.one_base_VS_output = read_json_file("test_datasets/one_base_VS_output.json")
self.one_base_DR_output = read_json_file("test_datasets/one_base_DR_output.json")
self.one_base_input = read_json_file(os.path.join(TEST_DATA_LOCATION, "one_base_input.json"))
self.one_base_output_format = read_json_file(os.path.join(TEST_DATA_LOCATION, "one_base_output_format.json"))
self.one_base_output_transform = read_json_file(os.path.join(TEST_DATA_LOCATION, "one_base_output_transform.json"))
self.one_base_VS_output = read_json_file(os.path.join(TEST_DATA_LOCATION, "one_base_VS_output.json"))
self.one_base_DR_output = read_json_file(os.path.join(TEST_DATA_LOCATION, "one_base_DR_output.json"))
self.one_base_VS_output_noversion = copy.deepcopy(self.one_base_VS_output)
del self.one_base_VS_output_noversion["version"]
self.one_base_DR_output_noversion = copy.deepcopy(self.one_base_DR_output)
del self.one_base_DR_output_noversion["version"]
self.several_bases_input = read_json_file("test_datasets/several_bases_input.json")
self.several_bases_output_transform_to_one = read_json_file("test_datasets/several_bases_output_transform_to_one.json")
self.several_bases_output_format = read_json_file("test_datasets/several_bases_output_format.json")
self.several_bases_output_transform = read_json_file("test_datasets/several_bases_output_transform.json")
self.several_bases_VS_output = read_json_file("test_datasets/several_bases_VS_output.json")
self.several_bases_DR_output = read_json_file("test_datasets/several_bases_DR_output.json")
self.several_bases_input = read_json_file(os.path.join(TEST_DATA_LOCATION, "several_bases_input.json"))
self.several_bases_output_transform_to_one = read_json_file(os.path.join(TEST_DATA_LOCATION, "several_bases_output_transform_to_one.json"))
self.several_bases_output_format = read_json_file(os.path.join(TEST_DATA_LOCATION, "several_bases_output_format.json"))
self.several_bases_output_transform = read_json_file(os.path.join(TEST_DATA_LOCATION, "several_bases_output_transform.json"))
self.several_bases_VS_output = read_json_file(os.path.join(TEST_DATA_LOCATION, "several_bases_VS_output.json"))
self.several_bases_DR_output = read_json_file(os.path.join(TEST_DATA_LOCATION, "several_bases_DR_output.json"))
self.several_bases_VS_output_noversion = copy.deepcopy(self.several_bases_VS_output)
del self.several_bases_VS_output_noversion["version"]
self.several_bases_DR_output_noversion = copy.deepcopy(self.several_bases_DR_output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
from __future__ import print_function, division, unicode_literals, absolute_import

import copy
import os
import unittest

from data_request_api.stable.utilities.tools import read_json_input_file_content
from data_request_api.stable.query.vocabulary_server import VocabularyServer, is_link_id_or_value, build_link_from_id
from data_request_api.tests import TEST_DATA_LOCATION


class TestLinks(unittest.TestCase):
Expand All @@ -30,7 +32,7 @@ def test_build_link_from_id(self):

class TestVocabularyServer(unittest.TestCase):
def setUp(self):
self.vs_file = "test_datasets/one_base_VS_output.json"
self.vs_file = os.path.join(TEST_DATA_LOCATION, "one_base_VS_output.json")
self.vs_content = read_json_input_file_content(self.vs_file)
self.vs_content_infinite_loop = copy.deepcopy(self.vs_content)
self.vs_content_infinite_loop["cell_methods"]["CellMethods::am-tm"]["structure_title"] = "link::default_483"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import unittest
import tempfile


import data_request_api.stable.content.dreq_api.dreq_content as dc
from data_request_api.stable.query.data_request import DataRequest

Expand Down
Empty file removed tests/__init__.py
Empty file.
Loading

0 comments on commit cb33b5d

Please sign in to comment.