def thorough(self): self.app = create_app() with self.app.app_context(): datasets = DatasetConfig.get_datasets() variables = {} for dataset in datasets: variables.update({dataset: DatasetConfig(dataset).variables}) data = {'datasets': datasets, 'variables': variables} return data
def setUpClass(self): self.app = create_app().test_client() test_config = SetUpTest() #Suppressing Unclosed File Warning in basemap.py line 40,76 warnings.simplefilter("ignore", ResourceWarning) warnings.simplefilter("ignore", UserWarning) warnings.simplefilter("ignore", DeprecationWarning) test_level = sys.argv.pop() if test_level == 'thorough': print("\n\nTEST LEVEL : THOROUGH") print("WARNING : THIS MAY TAKE SEVERAL HOURS\n\n") self.test_data = test_config.thorough() else: print("\n\nTEST LEVEL : BASIC\n\n") self.test_data = test_config.basic()
"""Unit tests for data.class4 module. """ import os import shutil import unittest from pathlib import Path import numpy import xarray import data.class4 import oceannavigator app = oceannavigator.create_app(testing=True) class TestListClass4Models(unittest.TestCase): def setUp(self): self.test_data = Path("testdata") self.class4_test_data = Path("class4/2020/20201208") (self.test_data / self.class4_test_data).mkdir(parents=True) test_files = ( "class4_20201208_FOAM_orca025_14.1_profile.nc", "class4_20201208_GIOPS_CONCEPTS_3.0_profile.nc", ) for f in test_files: (self.test_data / self.class4_test_data / f).touch() def tearDown(self): shutil.rmtree(self.test_data / self.class4_test_data.parents[1])
def setUpClass(self): self.app = create_app().test_client()
import json import unittest from unittest.mock import patch from data.variable import Variable from data.variable_list import VariableList from oceannavigator import DatasetConfig, create_app app = create_app(testing=True) class TestAPIv1GetData(unittest.TestCase): def setUp(self): self.app = app.test_client() with open('tests/testdata/datasetconfigpatch.json') as dataPatch: self.patch_dataset_config_ret_val = json.load(dataPatch) self.patch_data_vars_ret_val = VariableList([ Variable('votemper', 'Water temperature at CMC', 'Kelvins', sorted(["deptht", "time_counter", "y", "x"])) ]) @unittest.skip("NotImplementedError: 'item' is not yet a valid method on dask arrays") @patch.object(DatasetConfig, "_get_dataset_config") @patch('data.sqlite_database.SQLiteDatabase.get_data_variables') def test_data_endpoint(self, patch_get_data_vars, patch_get_dataset_config): patch_get_data_vars.return_value = self.patch_data_vars_ret_val patch_get_dataset_config.return_value = self.patch_dataset_config_ret_val
def setUpClass(cls): cls.app = create_app()
#!/usr/bin/env python3 from oceannavigator import create_app app = create_app()
import unittest from oceannavigator import create_app app = create_app( testing=True, dataset_config_path="../tests/testdata/datasetconfigpatch.json") class TestApiv10GenerateScript(unittest.TestCase): def setUp(self) -> None: self.app = app.test_client() self.langs: list = ["python", "r"] def test_generatescript_endpoint_for_plot_script_type(self) -> None: for l in self.langs: res = self.app.get( "/api/v1.0/generatescript/", query_string={ "query": { "dataset": "giops_day", "names": [], "plotTitle": "", "quantum": "day", "showmap": False, "station": [[48.26684109261785, -45.12499928474428]], "time": 2257761600, "type": "profile", "variable": ["votemper"],
def __init__(self, *args, **kwargs): super(TestUtil, self).__init__(*args, **kwargs) self.app = create_app()
def test_create_app_actually_works(self): app = create_app()