# -*- coding: utf-8 -*-
"""
Test the PyLinkForwardModel class in bayesvalidrox.
Tests are available for the following functions
PyLinkForwardModel:
    within_range *not used again in here            - x
    read_observation *not used again in here
    read_mc_reference *not used again in here
    read_output *used only once
    update_input_params *used only once
    run_command *used only once
    run_forwardmodel
    run_model_parallel
    _store_simulations *used only once
    zip_subdirs *used in metamodel again
OutputData:
    constructor only

@author: Rebecca Kohlhaas
"""
import sys
sys.path.append("src/")
import pytest

from bayesvalidrox.pylink.pylink import PyLinkForwardModel as PL

#%% Test constructor

def test_PL() -> None:
    """
    Build PyLinkForwardModel without inputs
    """
    pl = PL()


#%% Test PyLink.within_range

def test_within_range_noarray() -> None:
    """
    Value not an array
    """
    pl = PL()
    with pytest.raises(AttributeError) as excinfo:
        pl.within_range(1,2,3)
    assert str(excinfo.value) == 'The given values should be a 1D array, but are not'

def test_within_range_2d() -> None:
    """
    Value not an array
    """
    pl = PL()
    with pytest.raises(AttributeError) as excinfo:
        pl.within_range([[1],[2]],2,3)
    assert str(excinfo.value) == 'The given values should be a 1D array, but are not'

def test_within_range_err() -> None:
    """
    Value not in range
    """
    pl = PL()
    assert pl.within_range([1],2,3) == False

def test_within_range_switchbounds() -> None:
    """
    Switched min and max
    """
    pl = PL()
    with pytest.raises(ValueError) as excinfo:
        pl.within_range([1],4,3)
    assert str(excinfo.value) == 'The lower and upper bounds do not form a valid range, they might be switched'

def test_within_range() -> None:
    """
    Value in range
    """
    pl = PL()
    assert pl.within_range([1],0,3) == True

if __name__ == '__main__':
    None