def test_generate_sst_datacube(): filePath = fileDirectory + "sst1981-1982.nc" generate_sst_datacube(1981, 1982, fileDirectory, "sst1981-1982") if os.path.isfile(filePath): assert True start = "1981-09-01" end = "1982-12-31" x = xr.open_dataset(filePath) if np.datetime_as_string(x["time"][0], unit='D') == start and np.datetime_as_string( x["time"][-1], unit='D') == end: assert True
def test_invalidTimeframe(): with pytest.raises(TimeframeError): generate_sst_datacube(2019, 2018, fileDirectory, "sst20182019")
def test_invalidDirectory(): with pytest.raises(DirectoryNotFoundError): generate_sst_datacube(1981, 1982, "../nonExistentDirectory/noFileEver/", "sst1981-1982")
def test_invalidFilename_4(): with pytest.raises(FilenameError): generate_sst_datacube(1981, 1982, fileDirectory, "")