Esempio n. 1
0
def check_vsc(context, vcs):
    """Check the type of version control system for the component."""
    details = get_details_node(context)[0]
    code_repository = check_and_get_attribute(details, "code_repository")
    actual_vcs = check_and_get_attribute(code_repository, "type")
    assert actual_vcs == vcs.lower(), "Expected {v1} version control system type, " \
        "but {v2} has been found instead".format(v1=vcs, v2=actual_vcs)
Esempio n. 2
0
def check_repository_url(context, url):
    """Check the repository URL (if set) for the component."""
    details = get_details_node(context)[0]
    code_repository = check_and_get_attribute(details, "code_repository")
    actual_url = check_and_get_attribute(code_repository, "url")
    assert actual_url == url, "Repository URL should be set to {u1}, " \
        "but {u2} has been found instead".format(u1=url, u2=actual_url)
Esempio n. 3
0
def check_package_name_and_version(context, name, version):
    """Check the package name and version."""
    details = get_details_node(context)[0]
    actual_name = check_and_get_attribute(details, "name")
    actual_version = check_and_get_attribute(details, "version")

    assert name == actual_name, "Name '{n1}' is different from " \
        "expected name '{n2}'".format(n1=actual_name, n2=name)

    assert version == actual_version, "Version {v1} is different from expected " \
        "version {v2}".format(v1=actual_version, v2=version)
Esempio n. 4
0
def check_keywords_tagging_file(context, package, ecosystem):
    """Check that the tagging metadata are correct for given package and ecosystem."""
    data = context.s3_data

    check_audit_metadata(data)
    check_release_attribute(data, ecosystem, package)
    check_status_attribute(data)

    details = get_details_node(context)
    check_attribute_presence(details, "package_name")
    check_attribute_presence(details, "repository_description")
Esempio n. 5
0
def check_dependents_count(context, expected_dependents_count):
    """Check the number of dependend projects for given package."""
    details = get_details_node(context)

    dependents = check_and_get_attribute(details, 'dependents')

    dependents_count = check_and_get_attribute(dependents, 'count')

    assert int(dependents_count) == expected_dependents_count, \
        "Expected {e} dependents, but found {f} instead".format(e=expected_dependents_count,
                                                                f=dependents_count)
Esempio n. 6
0
def check_weight_for_word_in_keywords_tagging(context, word, where):
    """Check that the given word and its weight can be found in the tagging report."""
    selector = S3Interface.selector_to_key(where)
    assert selector in [
        "package_name", "repository_description", "description"
    ]

    details = get_details_node(context)
    word_dict = check_and_get_attribute(details, selector)

    check_attribute_presence(word_dict, word)
    assert float(word_dict[word]) > 0.0
Esempio n. 7
0
def check_dependent_repositories_count(context, expected_repo_count):
    """Check the number of dependent repositories for given package."""
    details = get_details_node(context)

    dependent_repositories = check_and_get_attribute(details,
                                                     'dependent_repositories')

    repo_count = check_and_get_attribute(dependent_repositories, 'count')

    assert int(repo_count) == expected_repo_count, \
        "Expected {e} repositories, but found {f} instead".format(e=expected_repo_count,
                                                                  f=repo_count)
Esempio n. 8
0
def check_package_license(context, license):
    """Check that the package has assigned given license."""
    details = get_details_node(context)
    licenses = check_and_get_attribute(details, "licenses")
    assert license in licenses, "Can not find license {lic}".format(
        lic=license)
Esempio n. 9
0
def check_project_description(context, description):
    """Check the package description existence and content."""
    details = get_details_node(context)[0]
    actual_description = check_and_get_attribute(details, "description")
    assert actual_description == description, "Description is set to {d1}, " \
        "but {d2} is expected".format(d1=actual_description, d2=description)
Esempio n. 10
0
def check_project_homepage(context, url):
    """Check the project homepage (if exist) for the component."""
    details = get_details_node(context)[0]
    actual_homepage = check_and_get_attribute(details, "homepage")
    assert actual_homepage == url, "Homepage URL should be set to {u1}, " \
        "but {u2} has been found instead".format(u1=url, u2=actual_homepage)
Esempio n. 11
0
def check_package_author(context, author):
    """Check the author of component."""
    details = get_details_node(context)[0]
    actual_author = check_and_get_attribute(details, "author")
    assert actual_author.startswith(author), "Expected author {a1}, " \
        "but {a2} has been found instead".format(a1=author, a2=actual_author)
Esempio n. 12
0
def check_empty_github_details(context):
    """Check that the details about GitHub repository are empty."""
    details = get_details_node(context)
    assert not details, "Empty 'details' node is expected"
Esempio n. 13
0
def _get_releases_node_from_libraries_io(context):
    details = get_details_node(context)

    return check_and_get_attribute(details, 'releases')