Exemplo n.º 1
0
 def test_cli_min_args_bad_path(self):
     """Should error with bad shapfile path"""
     with self.assertRaises(SystemExit):
         subset_conus.parse_args([
             '-i', 'path_no_exists', '-s', self.good_shape_file_name, '-f',
             '.'
         ])
Exemplo n.º 2
0
 def test_cli_alt_manifest_file(self):
     argstring = f'-i {self.good_shape_file_path} -s {self.good_shape_file_name} -f . ' \
                 f'-m {test_files.test_domain_manifest}'
     args = subset_conus.parse_args(argstring.split(' '))
     self.assertEqual(
         os.fspath(test_files.test_domain_manifest), args.manifest_file,
         'should be able to provide an alternate manifest file')
Exemplo n.º 3
0
 def test_cli_min_args_bad_shape_name(self):
     """Should not error with bad shapefile name, not because we don't want to.
     Separating the input path from the file name means we can't check for the file while parsing args
     """
     args = subset_conus.parse_args(
         ['-i', os.fspath(self.good_shape_file_path), '-s', 'shape_name_no_exists', '-f', '.'])
     self.assertEqual('shape_name_no_exists', args.shapefile)
     self.assertEqual(os.fspath(self.good_shape_file_path), args.input_path)
Exemplo n.º 4
0
 def test_cli_min_args_missing_shape_parts(self):
     """A shapefile with missing components will not raise an exception"""
     args = subset_conus.parse_args([
         '-i',
         os.fspath(self.partial_shapefile_path), '-s',
         self.partial_shapefile_name, '-f', '.'
     ])
     self.assertEqual(os.fspath(self.partial_shapefile_path),
                      args.input_path)
     self.assertEqual(self.partial_shapefile_name, args.shapefile)
Exemplo n.º 5
0
 def test_good_start(self):
     args = subset_conus.parse_args(
         ['-i', os.fspath(self.good_shape_file_path), '-s', self.good_shape_file_name, '-f', '.'])
     self.assertEqual(os.fspath(self.good_shape_file_path), args.input_path)
     self.assertEqual(self.good_shape_file_name, args.shapefile)
     self.assertEqual('.', args.conus_files)
     self.assertEqual(1, args.conus_version)
     self.assertEqual('.', args.out_dir)
     self.assertIsNone(args.out_name)
     self.assertFalse(args.clip_clm)
     self.assertFalse(args.write_tcl)
     self.assertSequenceEqual((0, 0, 0, 0), args.padding)
     self.assertSequenceEqual([1], args.attribute_ids)
     self.assertEqual('OBJECTID', args.attribute_name)
     self.assertFalse(args.write_tifs)
Exemplo n.º 6
0
 def test_cli_all_options_non_default(self):
     argstring = f'-i {self.good_shape_file_path} -s {self.good_shape_file_name} ' \
                 f'-f . -v 2 -o .. -n output_name -c -w -p 1 2 3 4 -a 2 3 -e ID -t'.split(' ')
     args = subset_conus.parse_args(argstring)
     self.assertTrue(args.write_tifs)
     self.assertTrue(args.write_tcl)
     self.assertTrue(args.clip_clm)
     self.assertEqual(self.good_shape_file_name, args.shapefile)
     self.assertEqual(os.fspath(self.good_shape_file_path), args.input_path)
     self.assertEqual(2, args.conus_version)
     self.assertEqual('.', args.conus_files)
     self.assertEqual('..', args.out_dir)
     self.assertEqual('output_name', args.out_name)
     self.assertSequenceEqual((1, 2, 3, 4), args.padding)
     self.assertSequenceEqual([2, 3], args.attribute_ids)
     self.assertEqual('ID', args.attribute_name)
Exemplo n.º 7
0
 def test_cli_all_options_watershed_non_default(self):
     argstring = f'-i {self.good_shape_file_path} -w {self.good_huc_ids[0]} {self.good_huc_ids[1]} ' \
                 f'-f . -v 2 -o .. -n output_name -c -r -p 1 2 3 4 -a 2 3 -e ID -t'.split(' ')
     args = subset_conus.parse_args(argstring)
     self.assertTrue(args.write_tifs)
     self.assertTrue(args.run_script)
     self.assertTrue(args.clip_clm)
     self.assertIsNone(None, args.shapefile)
     self.assertListEqual(self.good_huc_ids, args.hucs)
     self.assertEqual(os.fspath(self.good_shape_file_path), args.input_path)
     self.assertEqual(2, args.conus_version)
     self.assertEqual('.', args.conus_files)
     self.assertEqual('..', args.out_dir)
     self.assertEqual('output_name', args.out_name)
     self.assertSequenceEqual((1, 2, 3, 4), args.padding)
     self.assertSequenceEqual([2, 3], args.attribute_ids)
     self.assertEqual('ID', args.attribute_name)
Exemplo n.º 8
0
 def test_cli_no_args(self):
     """should error without arguments"""
     with self.assertRaises(SystemExit):
         subset_conus.parse_args([])