예제 #1
0
파일: test_ncf.py 프로젝트: DINKIN/ncf
 def test_parse_generic_method_data(self):
     """Parsing should return a dict with the data from the test generic_method"""
     metadata = ncf.parse_generic_method_metadata(
         self.generic_method_content)
     self.assertEqual(metadata['bundle_name'], "package_install_version")
     self.assertEqual(metadata['bundle_args'],
                      ["package_name", "package_version"])
     self.assertEqual(metadata['name'], "Package install")
     self.assertEqual(
         metadata['description'],
         "Install a package by name from the default system package manager"
     )
     self.assertEqual(metadata['parameter'],
                      [{
                          'name': 'package_name',
                          'description': 'Name of the package to install'
                      }, {
                          'name': 'package_version',
                          'description': 'Version of the package to install'
                      }])
     self.assertEqual(metadata['class_prefix'], "package_install")
     self.assertEqual(metadata['class_parameter'], "package_name")
     self.assertEqual(metadata['class_parameter_id'], 1)
     self.assertEqual(metadata['agent_version'], ">= 3.5")
     self.assertEqual(len(metadata), len(self.methods_expected_tags))
     self.assertEqual(metadata['agent_version'], ">= 3.5")
예제 #2
0
 def test_parse_generic_method(self):
     """Parsing a generic method should return a dict with all defined generic_method tags"""
     metadata = ncf.parse_generic_method_metadata(
         self.generic_method_content)
     self.assertEqual(
         sorted(metadata.keys()),
         sorted(ncf.tags["generic_method"] + ncf.tags["common"]))
예제 #3
0
def check_comments_for_all_generic_methods():
    errors = 0
    filenames = ncf.get_all_generic_methods_filenames()
    names = []

    for file in filenames:
        content = open(file).read()
        try:
            metadata = ncf.parse_generic_method_metadata(content)['result']
        except Exception as e:
            print("Error in " + file + ": " + e.__str__())

        if metadata['name'] in names:
            print("Name '" + metadata['name'] +
                  "' already used by another generic_method (found in file " +
                  file + ")")
            errors += 1
        else:
            names.append(metadata['name'])

    if errors == 0:
        print(
            "R: ./30_generic_methods/each_generic_method_name_should_be_unique.py Pass"
        )

    return (errors != 0)
예제 #4
0
파일: test_ncf.py 프로젝트: ncharles/ncf
 def test_parse_generic_method_data(self):
   """Parsing should return a dict with the data from the test generic_method"""
   metadata = ncf.parse_generic_method_metadata(self.generic_method_content)
   self.assertEqual(metadata['bundle_name'], "package_install_version")
   self.assertEqual(metadata['bundle_args'], ["package_name", "package_version"])
   self.assertEqual(metadata['name'], "Package install")
   self.assertEqual(metadata['class_prefix'], "package_install")
   self.assertEqual(metadata['class_parameter'], "package_name")
   self.assertEqual(metadata['class_parameter_id'], 1)
   self.assertEqual(len(metadata), len(ncf.tags["generic_method"]+ncf.tags["common"]))
예제 #5
0
 def test_parse_generic_method_data(self):
   """Parsing should return a dict with the data from the test generic_method"""
   metadata = ncf.parse_generic_method_metadata(self.generic_method_content)
   self.assertEqual(metadata['bundle_name'], "package_install_version")
   self.assertEqual(metadata['bundle_args'], ["package_name", "package_version"])
   self.assertEqual(metadata['name'], "Package install")
   self.assertEqual(metadata['description'], "Install a package by name from the default system package manager")
   self.assertEqual(metadata['parameter'], [{'name': 'package_name', 'description': 'Name of the package to install'},{'name': 'package_version', 'description': 'Version of the package to install'}])
   self.assertEqual(metadata['class_prefix'], "package_install")
   self.assertEqual(metadata['class_parameter'], "package_name")
   self.assertEqual(metadata['class_parameter_id'], 1)
   self.assertEqual(len(metadata), len(ncf.tags["generic_method"]+ncf.tags["common"]))
예제 #6
0
 def test_parse_generic_method_data(self):
     """Parsing should return a dict with the data from the test generic_method"""
     metadata = ncf.parse_generic_method_metadata(
         self.generic_method_content)
     self.assertEqual(metadata['bundle_name'], "package_install_version")
     self.assertEqual(metadata['bundle_args'],
                      ["package_name", "package_version"])
     self.assertEqual(metadata['name'], "Package install")
     self.assertEqual(metadata['class_prefix'], "package_install")
     self.assertEqual(metadata['class_parameter'], "package_name")
     self.assertEqual(metadata['class_parameter_id'], 1)
     self.assertEqual(len(metadata),
                      len(ncf.tags["generic_method"] + ncf.tags["common"]))
예제 #7
0
 def test_parse_generic_method_data(self):
   """Parsing should return a dict with the data from the test generic_method"""
   metadata = ncf.parse_generic_method_metadata(self.generic_method_content)['result']
   self.assertEqual(metadata['bundle_name'], "package_install_version")
   self.assertEqual(metadata['bundle_args'], ["package_name", "package_version"])
   self.assertEqual(metadata['name'], "Package install")
   self.assertEqual(metadata['description'], "Install a package by name from the default system package manager")
   self.assertEqual(metadata['parameter'], [ { 'constraints': ncf_constraints.default_constraint, 'name': 'package_name', 'description': 'Name of the package to install'},{ 'constraints': ncf_constraints.default_constraint, 'name': 'package_version', 'description': 'Version of the package to install'}])
   self.assertEqual(metadata['class_prefix'], "package_install")
   self.assertEqual(metadata['class_parameter'], "package_name")
   self.assertEqual(metadata['class_parameter_id'], 1)
   self.assertEqual(metadata['agent_version'], ">= 3.6")
   self.assertEqual(len(metadata), len(self.methods_expected_tags))
   self.assertEqual(metadata['agent_version'], ">= 3.6")
예제 #8
0
def custom_gm_metadata(alt_path=''):
    all_metadata = {}
    filenames = ncf.get_all_generic_methods_filenames()

    for file in filenames:
        with codecs.open(file, encoding="utf-8") as fd:
            content = fd.read()
        try:
            result = ncf.parse_generic_method_metadata(content)
            metadata = result["result"]
            metadata["filename"] = file
            all_metadata[metadata['bundle_name']] = metadata
        except NcfError as e:
            print("Could not parse generic method in '" + file + "'")
            continue  # skip this file, it doesn't have the right tags in - yuk!
    return all_metadata
def check_comments_for_all_generic_methods():
  errors = 0
  filenames = ncf.get_all_generic_methods_filenames()

  for file in filenames:
    content = open(file).read()
    try:
      metadata = ncf.parse_generic_method_metadata(content)
    except Exception as e:
      print("Error in " + file + ": " + e.__str__())
      errors += 1

  if errors == 0:
    print("R: ./30_generic_methods/all_bundles_should_be_commented.py Pass")

  return (errors != 0)
def check_comments_for_all_generic_methods():
  errors = 0
  filenames = ncf.get_all_generic_methods_filenames()

  for file in filenames:
    content = open(file).read()
    try:
      metadata = ncf.parse_generic_method_metadata(content)
    except Exception as e:
      print "Error in " + file + ": " + e.__str__()
      errors += 1

  if errors == 0:
    print "R: ./30_generic_methods/all_bundles_should_be_commented.py Pass"

  return (errors != 0)
예제 #11
0
파일: test_ncf.py 프로젝트: ageorgop/ncf
 def test_parse_generic_method_data(self):
     """Parsing should return a dict with the data from the test generic_method"""
     metadata = ncf.parse_generic_method_metadata(self.generic_method_content)
     self.assertEqual(metadata["bundle_name"], "package_install_version")
     self.assertEqual(metadata["bundle_args"], ["package_name", "package_version"])
     self.assertEqual(metadata["name"], "Package install")
     self.assertEqual(metadata["description"], "Install a package by name from the default system package manager")
     self.assertEqual(
         metadata["parameter"],
         [
             {"name": "package_name", "description": "Name of the package to install"},
             {"name": "package_version", "description": "Version of the package to install"},
         ],
     )
     self.assertEqual(metadata["class_prefix"], "package_install")
     self.assertEqual(metadata["class_parameter"], "package_name")
     self.assertEqual(metadata["class_parameter_id"], 1)
     self.assertEqual(len(metadata), len(ncf.tags["generic_method"] + ncf.tags["common"]))
예제 #12
0
def check_comments_for_all_generic_methods():
  errors = 0
  filenames = ncf.get_all_generic_methods_filenames()
  names = []

  for file in filenames:
    content = open(file).read()
    try:
      metadata = ncf.parse_generic_method_metadata(content)['result']
    except Exception as e:
      print "Error in " + file + ": " + e.__str__()

    if metadata['name'] in names:
      print "Name '" + metadata['name'] + "' already used by another generic_method (found in file " + file + ")"
      errors += 1
    else:
      names.append(metadata['name'])

  if errors == 0:
    print "R: ./30_generic_methods/each_generic_method_name_should_be_unique.py Pass"

  return (errors != 0)
예제 #13
0
파일: test_ncf.py 프로젝트: ikramBej/ncf
 def test_parse_generic_method_data(self):
     """Parsing should return a dict with the data from the test generic_method"""
     metadata = ncf.parse_generic_method_metadata(
         self.generic_method_content)['result']
     self.assertEqual(metadata['bundle_name'], "package_install_version")
     self.assertEqual(metadata['bundle_args'],
                      ["package_name", "package_version"])
     self.assertEqual(metadata['name'], "Package install")
     self.assertEqual(
         metadata['description'],
         "Install a package by name from the default system package manager"
     )
     self.assertEqual(metadata['parameter'],
                      [{
                          'constraints': {
                              "allow_empty_string": False,
                              "allow_whitespace_string": False,
                              "max_length": 16384
                          },
                          'type': 'string',
                          'name': 'package_name',
                          'description': 'Name of the package to install'
                      }, {
                          'constraints': {
                              "allow_empty_string": False,
                              "allow_whitespace_string": False,
                              "max_length": 16384
                          },
                          'type': 'version',
                          'name': 'package_version',
                          'description': 'Version of the package to install'
                      }])
     self.assertEqual(metadata['class_prefix'], "package_install")
     self.assertEqual(metadata['class_parameter'], "package_name")
     self.assertEqual(metadata['class_parameter_id'], 1)
     self.assertEqual(metadata['agent_version'], ">= 3.6")
     self.assertEqual(len(metadata), len(self.methods_expected_tags))
     self.assertEqual(metadata['agent_version'], ">= 3.6")
예제 #14
0
 def __init__(self, path):
     self.path = path
     self.path_basename = os.path.basename(self.path).split('.')[0]
     self.raw_content = self.get_raw_content()
     self.content = self.get_bundle_content()
     self.metadata = ncf.parse_generic_method_metadata(self.raw_content)["result"]
예제 #15
0
 def test_parse_generic_method(self):
   """Parsing a generic method should return a dict with all defined generic_method tags"""
   metadata = ncf.parse_generic_method_metadata(self.generic_method_content)
   self.assertEqual(sorted(metadata.keys()), sorted(ncf.tags["generic_method"]+ncf.tags["common"]))
예제 #16
0
파일: test_ncf.py 프로젝트: ikramBej/ncf
 def test_parse_generic_method(self):
     """Parsing a generic method should return a dict with all defined generic_method tags"""
     metadata = ncf.parse_generic_method_metadata(
         self.generic_method_content)['result']
     self.assertTrue(
         set(metadata.keys()).issuperset(set(self.methods_expected_tags)))
예제 #17
0
파일: test_ncf.py 프로젝트: DINKIN/ncf
 def test_parse_generic_method(self):
   """Parsing a generic method should return a dict with all defined generic_method tags"""
   metadata = ncf.parse_generic_method_metadata(self.generic_method_content)
   self.assertTrue(set(metadata.keys()).issuperset(set(self.methods_expected_tags)))