Ejemplo n.º 1
0
def test_read_cmor_tables():
    """Test that the function `read_cmor_tables` loads the tables correctly."""
    # Read the tables
    read_cmor_tables(read_config_developer_file())

    table_path = Path(root).parent / 'tables'

    for project in 'CMIP5', 'CMIP6':
        table = CMOR_TABLES[project]
        assert Path(
            table._cmor_folder) == table_path / project.lower() / 'Tables'
        assert table.strict is True

    project = 'OBS'
    table = CMOR_TABLES[project]
    assert Path(table._cmor_folder) == table_path / 'cmip5' / 'Tables'
    assert table.strict is False

    project = 'OBS6'
    table = CMOR_TABLES[project]
    assert Path(table._cmor_folder) == table_path / 'cmip6' / 'Tables'
    assert table.strict is False

    project = 'obs4mips'
    table = CMOR_TABLES[project]
    assert Path(table._cmor_folder) == table_path / 'obs4mips' / 'Tables'
    assert table.strict is False
Ejemplo n.º 2
0
import sys
import tempfile

import pytest
import yaml
from packaging import version

import esmvalcore
import esmvaltool.utils.recipe_filler as recipe_filler
from esmvalcore.cmor.table import read_cmor_tables
from esmvaltool.utils.recipe_filler import run

# Initialize with standard config developer file
std_config = recipe_filler.read_config_developer_file()
# Initialize CMOR tables
read_cmor_tables(std_config)

# Load test configuration
with open(os.path.join(os.path.dirname(__file__),
                       'recipe_filler.yml')) as file:
    CONFIG = yaml.safe_load(file)


@contextlib.contextmanager
def arguments(*args):
    backup = sys.argv
    sys.argv = list(args)
    yield
    sys.argv = backup

Ejemplo n.º 3
0
 def setUpClass():
     """Read cmor tables before testing"""
     read_cmor_tables(read_config_developer_file())
Ejemplo n.º 4
0
import os
import shutil
import tempfile

import pytest
import yaml

import esmvalcore._config
from esmvalcore._data_finder import get_input_filelist, get_output_file
from esmvalcore.cmor.table import read_cmor_tables

# Initialize with standard config developer file
CFG_DEVELOPER = esmvalcore._config.read_config_developer_file()
esmvalcore._config._config.CFG = CFG_DEVELOPER
# Initialize CMOR tables
read_cmor_tables(CFG_DEVELOPER)

# Load test configuration
with open(os.path.join(os.path.dirname(__file__), 'data_finder.yml')) as file:
    CONFIG = yaml.safe_load(file)


def print_path(path):
    """Print path."""
    txt = path
    if os.path.isdir(path):
        txt += '/'
    if os.path.islink(path):
        txt += ' -> ' + os.readlink(path)
    print(txt)
Ejemplo n.º 5
0
import os
import shutil
import tempfile

import pytest
import yaml

import esmvalcore._config
from esmvalcore._data_finder import (get_input_filelist, get_input_fx_filelist,
                                     get_output_file)
from esmvalcore.cmor.table import read_cmor_tables

# Initialize with standard config developer file
esmvalcore._config.CFG = esmvalcore._config.read_config_developer_file()
# Initialize CMOR tables
read_cmor_tables(esmvalcore._config.CFG)

# Load test configuration
with open(os.path.join(os.path.dirname(__file__), 'data_finder.yml')) as file:
    CONFIG = yaml.safe_load(file)


def print_path(path):
    """Print path."""
    txt = path
    if os.path.isdir(path):
        txt += '/'
    if os.path.islink(path):
        txt += ' -> ' + os.readlink(path)
    print(txt)
Ejemplo n.º 6
0
def load_config_developer(cfg_file=None):
    """Load the config developer file and initialize CMOR tables."""
    cfg_developer = read_config_developer_file(cfg_file)
    for key, value in cfg_developer.items():
        CFG[key] = value
    read_cmor_tables(CFG)