Пример #1
0
 def test_invalid_region(self):
     with pytest.raises(InvalidInputValue) as ex:
         _ = gh.nlcd(GEOM,
                     years=self.years,
                     resolution=self.res,
                     region="us")
     assert "L48" in str(ex.value)
Пример #2
0
class TestNLCDExceptions:
    "Test NLCD Exceptions"
    years = {"cover": [2016, 2019]}
    res = 1e3
    lulc = gh.nlcd(GEOM,
                   years={"cover": [2016, 2019]},
                   resolution=1e3,
                   crs="epsg:3542")

    @pytest.mark.skipif(has_typeguard, reason="Broken if Typeguard is enabled")
    def test_invalid_years_type(self):
        with pytest.raises(InvalidInputType) as ex:
            _ = gh.nlcd(GEOM, years=2010, resolution=self.res)
        assert "dict" in str(ex.value)

    def test_invalid_region(self):
        with pytest.raises(InvalidInputValue) as ex:
            _ = gh.nlcd(GEOM,
                        years=self.years,
                        resolution=self.res,
                        region="us")
        assert "L48" in str(ex.value)

    def test_invalid_years(self):
        with pytest.raises(InvalidInputValue) as ex:
            _ = gh.nlcd(GEOM, years={"cover": 2020}, resolution=self.res)
        assert "2019" in str(ex.value)

    @pytest.mark.skipif(has_typeguard, reason="Broken if Typeguard is enabled")
    def test_invalid_cover_type(self):
        with pytest.raises(InvalidInputType) as ex:
            _ = gh.cover_statistics(self.lulc)
        assert "DataArray" in str(ex.value)

    def test_invalid_cover_values(self):
        with pytest.raises(InvalidInputValue) as ex:
            _ = gh.cover_statistics(self.lulc.cover_2016 * 2)
        assert "11" in str(ex.value)
Пример #3
0
 def test_invalid_years(self):
     with pytest.raises(InvalidInputValue) as ex:
         _ = gh.nlcd(GEOM, years={"cover": 2020}, resolution=self.res)
     assert "2019" in str(ex.value)
Пример #4
0
 def test_invalid_years_type(self):
     with pytest.raises(InvalidInputType) as ex:
         _ = gh.nlcd(GEOM, years=2010, resolution=self.res)
     assert "dict" in str(ex.value)
Пример #5
0
 def test_nlcd_deprecated(self):
     lulc = gh.nlcd(GEOM, years=self.years, resolution=self.res)
     self.assertion(lulc.cover_2016, 83.4)