示例#1
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)
示例#2
0
  def test_get_all_generic_methods_metadata_with_arg(self):
    """get_all_generic_methods_metadata should return a list of all generic_methods with all defined metadata tags"""
    alternative_path = os.path.dirname(os.path.realpath(__file__)) + "/test_methods"
    metadata = ncf.get_all_generic_methods_metadata(alternative_path)["data"]

    number_generic_methods = len(ncf.get_all_generic_methods_filenames(alternative_path))
    self.assertEquals(number_generic_methods, len(metadata))
示例#3
0
文件: test_ncf.py 项目: ikramBej/ncf
    def test_get_all_generic_methods_metadata_with_arg(self):
        """get_all_generic_methods_metadata should return a list of all generic_methods with all defined metadata tags"""
        metadata = ncf.get_all_generic_methods_metadata(
        )["data"]["generic_methods"]

        number_generic_methods = len(ncf.get_all_generic_methods_filenames())
        self.assertEqual(number_generic_methods, len(metadata))
示例#4
0
文件: test_ncf.py 项目: DINKIN/ncf
    def test_get_all_generic_methods_filenames(self):
        """test_get_all_generic_methods_filenames should return a list of all generic_methods files"""
        base_dir = ncf.get_root_dir() + "/tree/30_generic_methods"
        alternative_path = os.path.dirname(
            os.path.realpath(__file__)) + "/test_methods"

        # Get list of generic_methods without prefix "_" on the filesystem
        list_methods_files = []
        ## Get recursivly each promises in the basic path and the alternative one
        list_methods_files += [
            os.path.join(full_path, filename)
            for full_path, dirname, files in os.walk(base_dir)
            for filename in files
            if not filename.startswith('_') and filename.endswith('.cf')
        ]
        list_methods_files += [
            os.path.join(full_path, filename)
            for full_path, dirname, files in os.walk(alternative_path +
                                                     "/30_generic_methods")
            for filename in files
            if not filename.startswith('_') and filename.endswith('.cf')
        ]

        filenames = ncf.get_all_generic_methods_filenames(alternative_path)

        filenames.sort()
        list_methods_files.sort()

        self.assertEqual(filenames, list_methods_files)
示例#5
0
文件: test_ncf.py 项目: ageorgop/ncf
    def test_get_all_generic_methods_filenames(self):
        """test_get_all_generic_methods_filenames should return a list of all generic_methods files"""
        base_dir = ncf.get_root_dir() + "/tree/30_generic_methods"
        alternative_path = os.path.dirname(os.path.realpath(__file__)) + "/test_methods"

        # Get list of generic_methods without prefix "_" on the filesystem
        list_methods_files = []
        ## Get recursivly each promises in the basic path and the alternative one
        list_methods_files += [
            os.path.join(full_path, filename)
            for full_path, dirname, files in os.walk(base_dir)
            for filename in files
            if not filename.startswith("_") and filename.endswith(".cf")
        ]
        list_methods_files += [
            os.path.join(full_path, filename)
            for full_path, dirname, files in os.walk(alternative_path + "/30_generic_methods")
            for filename in files
            if not filename.startswith("_") and filename.endswith(".cf")
        ]

        filenames = ncf.get_all_generic_methods_filenames(alternative_path)

        filenames.sort()
        list_methods_files.sort()

        self.assertEquals(filenames, list_methods_files)
示例#6
0
文件: test_ncf.py 项目: DINKIN/ncf
    def test_get_all_generic_methods_metadata_with_arg(self):
        """get_all_generic_methods_metadata should return a list of all generic_methods with all defined metadata tags"""
        alternative_path = os.path.dirname(
            os.path.realpath(__file__)) + "/test_methods"
        metadata = ncf.get_all_generic_methods_metadata(
            alternative_path)["data"]

        number_generic_methods = len(
            ncf.get_all_generic_methods_filenames(alternative_path))
        self.assertEqual(number_generic_methods, len(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)
示例#9
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
示例#10
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)
示例#11
0
  def test_get_all_generic_methods_metadata(self):
    """get_all_generic_methods_metadata should return a list of all generic_methods with all defined metadata tags"""
    metadata = ncf.get_all_generic_methods_metadata()["data"]

    number_generic_methods = len(ncf.get_all_generic_methods_filenames())
    self.assertEquals(number_generic_methods, len(metadata))