def test_set_all_long(self): clevel = 3 lsigfig = 2 ncfmt = 'netcdf' metadata = ['meta1', 'meta2'] xlist = ['x', 'y', 'z'] specfile = 'myspec.s2s' prefix = 'prefix.' suffix = '.suffix' tseries = ['tsvar1', 'tsvar2'] infiles = ['test_s2smake.py', 'test_specification.py'] argv = ['--meta1d'] argv.extend( [ '--compression_level', str(clevel), '--least_significant_digit', str(lsigfig), '--netcdf_format', ncfmt, ] ) for md in metadata: argv.extend(['--metadata', md]) for x in xlist: argv.extend(['--exclude', x]) argv.extend(['--specfile', specfile, '--output_prefix', prefix, '--output_suffix', suffix]) for ts in tseries: argv.extend(['--time_series', ts]) argv.extend(infiles) opts, args = s2smake.cli(argv) assert opts.compression_level == clevel assert opts.least_significant_digit == lsigfig assert len(args) == len(infiles) for i1, i2 in zip(args, infiles): assert i1 == i2 for i1, i2 in zip(opts.metadata, metadata): assert i1 == i2 assert opts.netcdf_format == ncfmt assert opts.output_prefix == prefix assert opts.output_suffix == suffix for i1, i2 in zip(opts.time_series, tseries): assert i1 == i2 assert opts.specfile == specfile assert opts.meta1d assert opts.exclude == xlist
def test_defaults(self): argv = ['test_s2smake.py'] opts, args = s2smake.cli(argv) assert opts.compression_level == 1 assert opts.least_significant_digit is None for i1, i2 in zip(args, argv): assert i1 == i2 assert len(opts.metadata) == 0 assert opts.netcdf_format == 'netcdf4' assert opts.output_prefix == 'tseries.' assert opts.output_suffix == '.nc' assert opts.time_series is None assert opts.specfile == 'input.s2s' assert not opts.meta1d assert opts.metafile is None assert opts.exclude == []
def test_set_all_short(self): clevel = 3 lsigfig = 2 ncfmt = 'netcdf' metadata = ['meta1', 'meta2'] specfile = 'myspec.s2s' prefix = 'prefix.' suffix = '.suffix' xlist = ['x', 'y', 'z'] infiles = ['test_s2smake.py', 'test_specification.py'] argv = ['-1'] argv.extend(['-c', str(clevel), '-d', str(lsigfig), '-f', ncfmt]) for md in metadata: argv.extend(['-m', md]) for x in xlist: argv.extend(['-x', x]) argv.extend(['-o', specfile, '-p', prefix, '-s', suffix]) argv.extend(infiles) opts, args = s2smake.cli(argv) assert opts.compression_level == clevel assert opts.least_significant_digit == lsigfig assert len(args) == len(infiles) for i1, i2 in zip(args, infiles): assert i1 == i2 assert len(opts.metadata) == len(metadata) for i1, i2 in zip(opts.metadata, metadata): assert i1 == i2 assert opts.netcdf_format == ncfmt assert opts.output_prefix == prefix assert opts.output_suffix == suffix assert opts.time_series is None assert opts.specfile == specfile assert opts.meta1d assert opts.exclude == xlist
def test_help(self): argv = ['-h'] with pytest.raises(SystemExit): s2smake.cli(argv)
def test_empty(self): argv = [] with pytest.raises(ValueError): s2smake.cli(argv)