def test__constraints_for_new_request(self): old_list = [1302393600, 1302480000, 1302566400, 1302652800, 1302739200, 1302825600, 1302912000, 1302998400, 1303084800, 1303171200, 1303257600, 1303344000, 1303430400, 1303516800, 1303603200, 1303689600, 1303776000, 1303862400, 1303948800, 1304035200, 1304121600, 1304208000, 1304294400, 1304380800, 1304467200, 1304553600, 1304640000, 1304726400, 1304812800, 1304899200, 1304985600, 1305072000, 1305158400, 1305244800, 1305331200, 1305417600, 1305504000, 1305590400, 1305676800, 1305763200, 1305849600, 1305936000, 1306022400, 1306108800, 1306195200, 1306281600, 1306368000, 1306454400, 1306540800, 1306627200, 1306713600, 1306800000, 1306886400, 1306972800, 1307059200, 1307145600, 1307232000, 1307318400, 1307404800, 1307491200, 1307577600, 1307664000, 1307750400, 1307836800, 1307923200, 1308009600, 1308096000, 1308182400, 1308268800, 1308355200, 1308441600, 1308528000, 1308614400, 1308700800, 1308787200, 1308873600, 1308960000, 1309046400, 1309132800, 1309219200, 1309305600, 1309392000, 1309478400, 1309564800, 1309651200, 1309737600, 1309824000, 1309910400, 1309996800, 1310083200, 1310169600, 1310256000, 1310342400, 1310428800, 1310515200, 1310601600, 1310688000, 1310774400, 1310860800, 1310947200, 1311033600, 1311120000, 1311206400, 1311292800, 1311379200, 1311465600, 1311552000, 1311638400, 1311724800, 1311811200, 1311897600, 1311984000, 1312070400, 1312156800, 1312243200, 1312329600, 1312416000, 1312502400, 1312588800, 1312675200, 1312761600, 1312848000, 1312934400, 1313020800, 1313107200, 1313193600, 1313280000, 1313366400, 1313452800, 1313539200, 1313625600, 1313712000, 1313798400, 1313884800, 1313971200, 1314057600, 1314144000, 1314230400, 1314316800, 1314403200, 1314489600, 1314576000, 1314662400, 1314748800, 1314835200, 1314921600, 1315008000, 1315094400, 1315180800, 1315267200, 1315353600, 1315440000, 1315526400, 1315612800, 1315699200, 1315785600, 1315872000, 1315958400, 1316044800, 1316131200, 1316217600, 1316304000, 1316390400, 1316476800, 1316563200, 1316649600, 1316736000, 1316822400, 1316908800, 1316995200, 1317081600, 1317168000, 1317254400, 1317340800, 1317427200, 1317513600, 1317600000, 1317686400, 1317772800, 1317859200, 1317945600, 1318032000, 1318118400, 1318204800, 1318291200, 1318377600, 1318464000, 1318550400, 1318636800, 1318723200, 1318809600, 1318896000, 1318982400, 1319068800, 1319155200, 1319241600, 1319328000, 1319414400, 1319500800, 1319587200, 1319673600, 1319760000, 1319846400, 1319932800, 1320019200, 1320105600, 1320192000, 1320278400, 1320364800, 1320451200, 1320537600, 1320624000, 1320710400, 1320796800, 1320883200, 1320969600, 1321056000, 1321142400, 1321228800, 1321315200, 1321401600, 1321488000, 1321574400, 1321660800, 1321747200, 1321833600, 1321920000, 1322006400, 1322092800, 1322179200, 1322265600, 1322352000, 1322438400, 1322524800, 1322611200, 1322697600, 1322784000, 1322870400, 1322956800, 1323043200, 1323129600, 1323216000, 1323302400, 1323388800, 1323475200, 1323561600, 1323648000, 1323734400, 1323820800, 1323907200, 1323993600, 1324080000, 1324166400, 1324252800, 1324339200, 1324425600, 1324512000, 1324598400, 1324684800, 1324771200, 1324857600, 1324944000, 1325030400, 1325116800, 1325203200, 1325289600, 1325376000, 1325462400, 1325548800, 1325635200, 1325721600, 1325808000, 1325894400, 1325980800, 1326067200, 1326153600, 1326240000, 1326326400, 1326412800, 1326499200, 1326585600] edres = ExternalDataset(name='test_ed_res', dataset_description=DatasetDescription(), update_description=UpdateDescription(), contact=ContactInformation()) edres.dataset_description.parameters['dataset_path'] = 'test_data/usgs.nc' edres.dataset_description.parameters['temporal_dimension'] = 'time' edres.update_description.parameters['new_data_check'] = msgpack.packb(old_list, default=encode_ion) config = {'external_dataset_res': edres, 'dataset_object': Dataset(edres.dataset_description.parameters['dataset_path'])} ret = NetcdfDataHandler._constraints_for_new_request(config) #log.debug('test__constraints_for_new_request: {0}'.format(ret['temporal_slice'])) self.assertEqual(ret['temporal_slice'], slice(281, 295, None))
def test__constraints_for_new_request(self): old_list = [ 1302393600, 1302480000, 1302566400, 1302652800, 1302739200, 1302825600, 1302912000, 1302998400, 1303084800, 1303171200, 1303257600, 1303344000, 1303430400, 1303516800, 1303603200, 1303689600, 1303776000, 1303862400, 1303948800, 1304035200, 1304121600, 1304208000, 1304294400, 1304380800, 1304467200, 1304553600, 1304640000, 1304726400, 1304812800, 1304899200, 1304985600, 1305072000, 1305158400, 1305244800, 1305331200, 1305417600, 1305504000, 1305590400, 1305676800, 1305763200, 1305849600, 1305936000, 1306022400, 1306108800, 1306195200, 1306281600, 1306368000, 1306454400, 1306540800, 1306627200, 1306713600, 1306800000, 1306886400, 1306972800, 1307059200, 1307145600, 1307232000, 1307318400, 1307404800, 1307491200, 1307577600, 1307664000, 1307750400, 1307836800, 1307923200, 1308009600, 1308096000, 1308182400, 1308268800, 1308355200, 1308441600, 1308528000, 1308614400, 1308700800, 1308787200, 1308873600, 1308960000, 1309046400, 1309132800, 1309219200, 1309305600, 1309392000, 1309478400, 1309564800, 1309651200, 1309737600, 1309824000, 1309910400, 1309996800, 1310083200, 1310169600, 1310256000, 1310342400, 1310428800, 1310515200, 1310601600, 1310688000, 1310774400, 1310860800, 1310947200, 1311033600, 1311120000, 1311206400, 1311292800, 1311379200, 1311465600, 1311552000, 1311638400, 1311724800, 1311811200, 1311897600, 1311984000, 1312070400, 1312156800, 1312243200, 1312329600, 1312416000, 1312502400, 1312588800, 1312675200, 1312761600, 1312848000, 1312934400, 1313020800, 1313107200, 1313193600, 1313280000, 1313366400, 1313452800, 1313539200, 1313625600, 1313712000, 1313798400, 1313884800, 1313971200, 1314057600, 1314144000, 1314230400, 1314316800, 1314403200, 1314489600, 1314576000, 1314662400, 1314748800, 1314835200, 1314921600, 1315008000, 1315094400, 1315180800, 1315267200, 1315353600, 1315440000, 1315526400, 1315612800, 1315699200, 1315785600, 1315872000, 1315958400, 1316044800, 1316131200, 1316217600, 1316304000, 1316390400, 1316476800, 1316563200, 1316649600, 1316736000, 1316822400, 1316908800, 1316995200, 1317081600, 1317168000, 1317254400, 1317340800, 1317427200, 1317513600, 1317600000, 1317686400, 1317772800, 1317859200, 1317945600, 1318032000, 1318118400, 1318204800, 1318291200, 1318377600, 1318464000, 1318550400, 1318636800, 1318723200, 1318809600, 1318896000, 1318982400, 1319068800, 1319155200, 1319241600, 1319328000, 1319414400, 1319500800, 1319587200, 1319673600, 1319760000, 1319846400, 1319932800, 1320019200, 1320105600, 1320192000, 1320278400, 1320364800, 1320451200, 1320537600, 1320624000, 1320710400, 1320796800, 1320883200, 1320969600, 1321056000, 1321142400, 1321228800, 1321315200, 1321401600, 1321488000, 1321574400, 1321660800, 1321747200, 1321833600, 1321920000, 1322006400, 1322092800, 1322179200, 1322265600, 1322352000, 1322438400, 1322524800, 1322611200, 1322697600, 1322784000, 1322870400, 1322956800, 1323043200, 1323129600, 1323216000, 1323302400, 1323388800, 1323475200, 1323561600, 1323648000, 1323734400, 1323820800, 1323907200, 1323993600, 1324080000, 1324166400, 1324252800, 1324339200, 1324425600, 1324512000, 1324598400, 1324684800, 1324771200, 1324857600, 1324944000, 1325030400, 1325116800, 1325203200, 1325289600, 1325376000, 1325462400, 1325548800, 1325635200, 1325721600, 1325808000, 1325894400, 1325980800, 1326067200, 1326153600, 1326240000, 1326326400, 1326412800, 1326499200, 1326585600 ] edres = ExternalDataset(name='test_ed_res', dataset_description=DatasetDescription(), update_description=UpdateDescription(), contact=ContactInformation()) edres.dataset_description.parameters[ 'dataset_path'] = 'test_data/usgs.nc' edres.dataset_description.parameters['temporal_dimension'] = 'time' edres.update_description.parameters['new_data_check'] = msgpack.packb( old_list, default=encode_ion) config = { 'external_dataset_res': edres, 'dataset_object': Dataset(edres.dataset_description.parameters['dataset_path']) } ret = NetcdfDataHandler._constraints_for_new_request(config) #log.debug('test__constraints_for_new_request: {0}'.format(ret['temporal_slice'])) self.assertEqual(ret['temporal_slice'], slice(281, 295, None))
def test__constraints_for_new_request_no_ext_ds(self): config = {} retval = NetcdfDataHandler._constraints_for_new_request(config=config) self.assertIsNone(retval)