Example #1
0
def test_calc_variable():
    with pytest.raises(AssertionError):
        # Expecting AssertionError
        # --> no variable specified
        P = PriorEngine(config='./test/prior_engine/test_config_prior.yml',
                        datestr='2017-03-01')
        P.get_priors()
Example #2
0
def test_priorengine_get_priors_sand_fraction():
    P = PriorEngine(config='./test/prior_engine/test_config_prior.yml',
                    datestr='2017-03-01',
                    variables=['sand_fraction'])
    priors = P.get_priors()
    assert type(priors) is dict
    assert 'sand_fraction' in priors.keys()
Example #3
0
def test_recent_prior():
    P = PriorEngine(config='./test/prior_engine/test_config_recent_prior.yml',
                    datestr='2017-03-01',
                    variables=['sm'])
    with pytest.raises(AssertionError,
                       match=r'.*Directory does not exist.*'):
        P.get_priors()
Example #4
0
def test_recent_prior():
    P = PriorEngine(config='./test/prior_engine/test_config_recent_prior.yml',
                    datestr='2017-03-01',
                    variables=['sm'])
    with pytest.raises(AssertionError,
                       message=("Expecting AssertionError"),
                       match=r'.*recent.*'):
        P.get_priors()
Example #5
0
def test_climatology_prior():
    P = PriorEngine(config='./test/prior_engine/test_config_prior.yml',
                    datestr='2017-03-01',
                    variables=['sm'])
    SoilMoisturePriorCreator(config=P.config,
                             datestr='2017-01-01',
                             ptype='climatology',
                             var=["sm"])
Example #6
0
def test_sm_prior_missing_datestr():
    P = PriorEngine(config='./test/prior_engine/test_config_prior.yml',
                    datestr='2017-03-01',
                    variables=['sm'])
    with pytest.raises(AssertionError):
        # Expecting AssertionError \
        # --> no datestr & variable specified
        SoilMoisturePriorCreator(config=P.config,
                                 ptype='climatology')
Example #7
0
def test_calc_config():
    P = PriorEngine(config='./test/prior_engine/test_config_prior.yml',
                    datestr='2017-03-01',
                    variables=['sm'])
    S = SoilMoisturePriorCreator(config=P.config,
                                 datestr='2017-03-01',
                                 ptype='climatology',
                                 var="sm")
    assert type(S.config) is dict
Example #8
0
def test_recent_prior2():
    P = PriorEngine(config='./test/prior_engine/test_config_recent_prior.yml',
                    datestr='2017-03-01',
                    variables=['sm'])
    with pytest.raises(AssertionError,
                       message=("Expecting AssertionError \
                                --> recent prior not implemented")):
        S = SoilMoisturePriorCreator(config=P.config,
                                     datestr='2017-03-01',
                                     var="sm",
                                     ptype='recent')
        S.compute_prior_file()
Example #9
0
def test_user_prior_initialization():
    P = PriorEngine(config='./test/prior_engine/test_config_user_prior.yml',
                    datestr='2017-03-01',
                    variables=['sm'])
    S = SoilMoisturePriorCreator(config=P.config,
                                 datestr='2017-03-01',
                                 var="sm",
                                 ptype='user1')
    with pytest.raises(AssertionError,
                       # Expecting AssertionError
                       # --> wrong path in config file.
                       match=r'.*path/to/file*'):
        S.compute_prior_file()
Example #10
0
def test_priorengine_get_priors_n():
    P = PriorEngine(config='./test/prior_engine/test_config_prior.yml',
                    datestr='2017-01-01',
                    variables=['n'])
    assert type(P.get_priors()) is dict
Example #11
0
def test_priorengine_init():
    P = PriorEngine(config='./test/prior_engine/test_config_prior.yml',
                    datestr='2017-01-01',
                    variables=['sm'])
    assert P.configfile is not None
    assert type(P.configfile) is str