def test_get_dates(self): frequency = Frequency(1, Frequency.UNIT.MONTH, Frequency.TYPE.PER, dateformat=Frequency.DATEFORMAT.MONTHDAY) from_date = datetime.date(2014, 1, 1) to_date = datetime.date(2014, 12, 31) self.assertEqual(len(frequency.get_dates(from_date, to_date)), 12)
def test_get_internet_dates(self): frequency = Frequency(1, Frequency.UNIT.MONTH, Frequency.TYPE.PER, dateformat=Frequency.DATEFORMAT.MONTHDAY) from_date = datetime.date(2014, 1, 1) to_date = datetime.date(2014, 12, 31) dates = frequency.get_dates(from_date, to_date) templates = frequency.get_internet_dates( dates, "/Modis_%Y%m/mcd14dl.%Y-%m-%d.tif") self.assertEqual(templates[0], '/Modis_201401/mcd14dl.2014-01-01.tif')
def test_get_internet_dates_add_days(self): #%{+/-<Nt><strftime>} = +/- N delta days/hours/ frequency = Frequency(1, Frequency.UNIT.DAY, Frequency.TYPE.PER, dateformat=Frequency.DATEFORMAT.DATE) from_date = datetime.date(2014, 1, 1) to_date = datetime.date(2014, 1, 31) dates = frequency.get_dates(from_date, to_date) templates = frequency.get_internet_dates( dates, "/Modis_%{+8dY-m-d}_%Y%m/mcd14dl.%Y-%m-%d.tif") self.assertEqual(templates[0], '/Modis_2014-01-09_201401/mcd14dl.2014-01-01.tif') self.assertEqual(templates[1], '/Modis_2014-01-10_201401/mcd14dl.2014-01-02.tif')
def test_get_internet_dates_dekad(self): #%{dkm} frequency = Frequency(1, Frequency.UNIT.DEKAD, Frequency.TYPE.PER, dateformat=Frequency.DATEFORMAT.DATE) from_date = datetime.date(2014, 1, 1) to_date = datetime.date(2014, 12, 31) dates = frequency.get_dates(from_date, to_date) templates = frequency.get_internet_dates( dates, "/Modis_%{dkm}_%Y%m%d/mcd14dl.%Y-%m-%d.tif") self.assertEqual(templates[0], '/Modis_1_20140101/mcd14dl.2014-01-01.tif') self.assertEqual(templates[1], '/Modis_2_20140111/mcd14dl.2014-01-11.tif')
def test_get_internet_dates_cgl_dekad(self): #%{dkm} frequency = Frequency(1, Frequency.UNIT.CGL_DEKAD, Frequency.TYPE.PER, dateformat=Frequency.DATEFORMAT.DATE) from_date = datetime.date(2014, 1, 1) to_date = datetime.date(2014, 12, 31) dates = frequency.get_dates(from_date, to_date) templates = frequency.get_internet_dates( dates, "/%Y/%m/%d/DMP-RT6_%Y%m%d0000_GLOBE_PROBAV_V2.0/c_gls_DMP-RT6_%Y%m%d0000_GLOBE_PROBAV_V2.0.1.nc" ) self.assertEqual( templates[0], '/2014/01/10/DMP-RT6_201401100000_GLOBE_PROBAV_V2.0/c_gls_DMP-RT6_201401100000_GLOBE_PROBAV_V2.0.1.nc' ) self.assertEqual( templates[1], '/2014/01/20/DMP-RT6_201401200000_GLOBE_PROBAV_V2.0/c_gls_DMP-RT6_201401200000_GLOBE_PROBAV_V2.0.1.nc' )