예제 #1
0
def test_remote_access_get_data_access_info5(remote_setup_dirs):
    """
    No SKA or ENG_ARCHIVE and SKA_ACCESS_REMOTELY=False

    Raises RuntimeError on windows and not-windows.
    """
    setenv('SKA', None)
    setenv('ENG_ARCHIVE', None)
    setenv('SKA_ACCESS_REMOTELY', False)

    for is_windows in True, False:
        with pytest.raises(RuntimeError) as err:
            get_data_access_info(is_windows)
        assert 'need to define SKA or ENG_ARCHIVE environment variable' in str(
            err.value)
예제 #2
0
def test_remote_access_get_data_access_info4(remote_setup_dirs):
    """
    ENG_ARCHIVE set to a non-existent directory
    """
    setenv('SKA', None)
    setenv('ENG_ARCHIVE', INVALID_DIR)
    setenv('SKA_ACCESS_REMOTELY', None)

    # Windows doesn't care about an invalid ENG_ARCHIVE, goes to remote access
    # with hardwired /proj/sot/ska root for remote data.
    eng_archive, ska_access_remotely = get_data_access_info(is_windows=True)
    assert eng_archive == '/proj/sot/ska/data/eng_archive'
    assert ska_access_remotely is True

    # Not windows: raises RuntimeError because no local data around found
    with pytest.raises(RuntimeError):
        get_data_access_info(is_windows=False)
예제 #3
0
def test_remote_access_get_data_access_info1(remote_setup_dirs):
    """
    Unit test of the get_data_access_info() function with no env vars set.
    """
    # No env vars set
    setenv('SKA', None)
    setenv('ENG_ARCHIVE', None)  # I.e. not set
    setenv('SKA_ACCESS_REMOTELY', None)

    # Windows
    eng_archive, ska_access_remotely = get_data_access_info(is_windows=True)
    assert eng_archive == '/proj/sot/ska/data/eng_archive'
    assert ska_access_remotely is True

    # Not windows
    with pytest.raises(RuntimeError) as err:
        get_data_access_info(is_windows=False)
    assert 'need to define SKA or ENG_ARCHIVE environment variable' in str(
        err.value)
예제 #4
0
def test_remote_access_get_data_access_info1(remote_setup_dirs):
    """
    Unit test of the get_data_access_info() function with no env vars set.
    """
    # No env vars set
    setenv('SKA', None)
    setenv('ENG_ARCHIVE', None)  # I.e. not set
    setenv('SKA_ACCESS_REMOTELY', None)

    # Windows
    eng_archive, ska_access_remotely = get_data_access_info(is_windows=True)
    assert eng_archive == '/proj/sot/ska/data/eng_archive'
    assert ska_access_remotely is True

    # Not windows
    with pytest.warns(AstropyUserWarning):
        eng_archive, ska_access_remotely = get_data_access_info(
            is_windows=False)
    assert eng_archive is None
    assert ska_access_remotely is False
예제 #5
0
def test_remote_access_get_data_access_info2(remote_setup_dirs):
    """
    Just SKA set to a valid directory (typical case on linux/mac)
    """
    ska_dir, eng_archive_dir = remote_setup_dirs

    setenv('SKA', ska_dir)
    setenv('ENG_ARCHIVE', None)  # I.e. not set
    setenv('SKA_ACCESS_REMOTELY', None)
    for is_windows in True, False:
        eng_archive, ska_access_remotely = get_data_access_info(is_windows)
        assert eng_archive == str(eng_archive_dir.absolute())
        assert ska_access_remotely is False
예제 #6
0
def test_remote_access_get_data_access_info6(remote_setup_dirs):
    """
    SKA set to a valid directory and SKA_ACCESS_REMOTELY=True
    """
    ska_dir, eng_archive_dir = remote_setup_dirs

    setenv('SKA', ska_dir)
    setenv('ENG_ARCHIVE', None)  # I.e. not set
    setenv('SKA_ACCESS_REMOTELY', 'True')

    for is_windows in True, False:
        eng_archive, ska_access_remotely = get_data_access_info(is_windows)
        assert eng_archive == '/proj/sot/ska/data/eng_archive'
        assert ska_access_remotely is True
예제 #7
0
def test_remote_access_get_data_access_info3(remote_setup_dirs):
    """
    Just ENG_ARCHIVE set to a valid directory (typical for testing)
    SKA either unset or set to a bad directory
    """
    ska_dir, eng_archive_dir = remote_setup_dirs

    for ska_env in None, INVALID_DIR:
        setenv('SKA', ska_env)
        setenv('ENG_ARCHIVE', eng_archive_dir)
        setenv('SKA_ACCESS_REMOTELY', None)
        for is_windows in True, False:
            eng_archive, ska_access_remotely = get_data_access_info(is_windows)
            assert eng_archive == str(eng_archive_dir.absolute())
            assert ska_access_remotely is False
예제 #8
0
def test_remote_access_get_data_access_info5(remote_setup_dirs):
    """
    No SKA or ENG_ARCHIVE and SKA_ACCESS_REMOTELY=False

    Raises RuntimeError on windows and not-windows.
    """
    setenv('SKA', None)
    setenv('ENG_ARCHIVE', None)
    setenv('SKA_ACCESS_REMOTELY', False)

    for is_windows in True, False:
        with pytest.warns(
                AstropyUserWarning,
                match='need to define SKA or ENG_ARCHIVE environment variable'
        ):
            out = get_data_access_info(is_windows)
        assert out == (None, False)