def test_failure_count(): # expect system exit - expect 2 errors sys.argv = 'run_chunk.py -s min -m MOHC/HadGEM2-ES -e r12i1p1 -v rh ra'.split( ) args = run_chunk.arg_parse_chunk() SETTINGS.EXIT_AFTER_N_FAILURES = 1 run_chunk.run_chunk(args)
def test_arg_parse_return(): sys.argv = 'run_chunk.py -s min -m MOHC/HadGEM2-ES -e r11i1p1 -v rh'.split() fpath = '/badc/cmip5/data/cmip5/output1/MOHC/HadGEM2-ES/historical/mon/land/Lmon' \ '/r1i1p1/latest/rh/rh_Lmon_HadGEM2-ES_historical_r1i1p1_193412-195911.nc' ds = xr.open_dataset(fpath) args = arg_parse_chunk() mn = ds['rh'].min(dim='time') assert(mn.shape == (145, 192))
def test_arg_parse_chunk_3(): sys.argv = 'run_chunk.py -s min -m BCC/bcc-csm1-1 -e r11i1p1'.split() args = arg_parse_chunk() assert args.var_id == defaults.variables
def test_arg_parse_chunk_2(): try: sys.argv = 'run_chunk.py -s min -m BCC/bcc-csm1-1'.split() arg_parse_chunk() except SystemExit as exc: pass
def test_arg_parse_chunk_1(): try: sys.argv = 'run_chunk.py -s min'.split() arg_parse_chunk() except SystemExit as exc: pass