示例#1
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()
示例#2
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()
示例#3
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"])
示例#4
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')
示例#5
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
示例#6
0
def test_sm_prior_invalid_ptype():
    with pytest.raises(AssertionError):
        # match=r'.*No prior type*'):
        SoilMoisturePriorCreator(ptype='climatologi')
示例#7
0
def test_sm_prior_no_ptype():
    with pytest.raises(AssertionError,
                       match=r'.*No prior type*'):
        SoilMoisturePriorCreator()
示例#8
0
def test_sm_prior_init():
    with pytest.raises(AssertionError):
        # match=("Expecting AssertionError \
        # --> no config specified")):
        SoilMoisturePriorCreator()
示例#9
0
def test_sm_prior_invalid_ptype():
    with pytest.raises(AssertionError,
                       message=("Expecting AssertionError \
                                --> no config specified")):
        SoilMoisturePriorCreator(ptype='climatologi')