예제 #1
0
def test_params_file_creation_path(config_dir, file_name, expected_path):
    """Test that the default pysteps parameters file is create in the right place."""

    pysteps_data_dir = "dummy/path/to/data"
    params_file_path = create_default_pystepsrc(
        pysteps_data_dir, config_dir=config_dir, file_name=file_name, dryrun=True
    )

    assert expected_path == params_file_path
예제 #2
0
def test_params_file_creation_path(config_dir, file_name, expected_path):
    """Test that the default pysteps parameters file is created in the right place."""

    # For windows compatibility
    if config_dir is not None:
        config_dir = os.path.normpath(config_dir)
    expected_path = os.path.normpath(expected_path)

    pysteps_data_dir = "dummy/path/to/data"
    params_file_path = create_default_pystepsrc(
        pysteps_data_dir, config_dir=config_dir, file_name=file_name, dryrun=True
    )

    assert expected_path == params_file_path
예제 #3
0
def _test_download_data():
    """Test the example data installers."""
    temp_dir = TemporaryDirectory()

    try:
        download_pysteps_data(temp_dir.name, force=True)
        with pytest.raises(DirectoryNotEmpty):
            download_pysteps_data(temp_dir.name, force=False)

        params_file = create_default_pystepsrc(temp_dir.name,
                                               config_dir=temp_dir.name)

        pysteps.load_config_file(params_file)
    finally:
        temp_dir.cleanup()
        pysteps.load_config_file()
예제 #4
0
# -*- coding: utf-8 -*-
"""
Script used to install the pysteps data in a test environment and set a pystepsrc
configuration file that points to that data.

The test data is downloaded in the `PYSTEPS_DATA_DIR` environmental variable.

After this script is run, the `PYSTEPSRC` environmental variable should be set to
PYSTEPSRC=$PYSTEPS_DATA_DIR/pystepsrc for pysteps to use that configuration file.
"""

import os

from pysteps.datasets import create_default_pystepsrc, download_pysteps_data

tox_test_data_dir = os.environ['PYSTEPS_DATA_DIR']

download_pysteps_data(tox_test_data_dir, force=True)

create_default_pystepsrc(tox_test_data_dir,
                         config_dir=tox_test_data_dir,
                         file_name="pystepsrc")