def test_construct_version_query_4():
    """Test the GraphPopulator.construct_version_query() class method."""
    input_json = {
        "version": "0.4.59",
        "package": "access_points",
        "ecosystem": "pypi",
        "analyses": {
            "metadata": {"details": [
                {"description": "Some description here",
                 "declared_license": "GPL and\nv2.0"}
            ]}
        }
    }
    q = GraphPopulator.construct_version_query(input_json)
    logger.info(q)

    assert "access_points" in q
    assert "0.4.59" in q
    assert "pypi" in q

    input_json = {
        "version": "deb579d6e030503f430978ee229008b9bc912d40",
        "package": "github.com/gorilla/mux",
        "ecosystem": "go",
        "analyses": {
            "source_licenses": {
                "status": "success",
                "summary": {
                    "sure_licenses": [
                        "BSD-Modified"
                    ]
                }
            },
            "metadata": {
                "details": [
                    {
                        "code_repository": {
                            "type": "git",
                            "url": "https://github.com/gorilla/mux"
                        },
                        "dependencies": [],
                        "ecosystem": "gofedlib",
                        "name": "github.com/gorilla/mux",
                        "version": "deb579d6e030503f430978ee229008b9bc912d40"
                    }
                ]
            }
        }
    }
    q = GraphPopulator.construct_version_query(input_json)

    assert "'declared_licenses'" in q
    assert "'licenses'" in q
    assert "BSD-Modified" in q
def test_construct_version_query_1():
    """Test the GraphPopulator.construct_version_query() class method."""
    input_json = {
        "version": "0.4.59",
        "package": "access_points",
        "ecosystem": "pypi",
        "analyses": {
            "metadata": {}
        }
    }
    q = GraphPopulator.construct_version_query(input_json)
    logger.info(q)

    assert "access_points" in q
    assert "0.4.59" in q
    assert "pypi" in q
    assert "addVertex" in q
    assert "drop()" not in q
def test_construct_version_query_3():
    """Test the GraphPopulator.construct_version_query() class method."""
    input_json = {
        "version": "0.4.59",
        "package": "access_points",
        "ecosystem": "pypi",
        "analyses": {
            "metadata": {"details": [
                {"description": "Some description here",
                 "declared_license": "GPL \nv2.0"}
            ]}
        }
    }
    q = GraphPopulator.construct_version_query(input_json)
    logger.info(q)

    assert "access_points" in q
    assert "0.4.59" in q
    assert "pypi" in q
def test_construct_version_query_2():
    """Test the GraphPopulator.construct_version_query() class method."""
    input_json = {
        "version": "0.4.59",
        "package": "access_points",
        "ecosystem": "pypi",
        "analyses": {
            "metadata": {"details": [
                {"description": "Some description here",
                 "declared_licenses": ["GPL v3", "APL v2.0"]}
            ]},
            "github_details": {},
            'libraries_io': {},
            'source_licenses': {},
            'security_issues': {
                "details": [
                    {"id": "CEV-007", "cvss": {"score": 9.7}}
                ]
            },
            'code_metrics': {"details": {"languages": [{
                "metrics": {
                    "functions": {
                        'average_cyclomatic_complexity': 3
                    }
                }
            }]}},
            'redhat_downstream': {
                "summary": {
                    "all_rhsm_product_names": ["access_points_rh"]
                }
            }

        }
    }
    q = GraphPopulator.construct_version_query(input_json)
    logger.info(q)

    assert "access_points" in q
    assert "0.4.59" in q
    assert "pypi" in q