def test_manifest_v2_metrics_to_check_validator_check_not_in_manifest(
        setup_route):
    """
    Ensure MetricToCheckValidator fails if supplied an empty check value
    """
    check_not_in_manifest = JSONDict({
        "assets": {
            "integration": {
                "metrics": {
                    "auto_install": True,
                    "check": "",
                    "metadata_path": "metrics_metadata.csv",
                    "prefix": "oracle.",
                },
            },
        },
    })

    # Use specific validator
    validator = common.MetricToCheckValidator(version=V2)
    validator.validate('active_directory', check_not_in_manifest, False)

    # Assert test case
    assert validator.result.failed, validator.result
    assert not validator.result.fixed
def test_manifest_v2_metrics_metadata_validator_file_in_manifest_not_exist(
        _, setup_route):
    """
    Ensure MetricsMetadataValidator fails if supplied a path to a non-existant metadata.csv
    """
    file_in_manifest_does_not_exist = JSONDict({
        "assets": {
            "integration": {
                "metrics": {
                    "auto_install": True,
                    "check": "oracle.session_count",
                    "metadata_path": "metrics_metadata1.csv",
                    "prefix": "oracle.",
                },
            },
        },
    })
    # Use specific validator
    validator = common.MetricsMetadataValidator(version=V2)
    validator.validate('active_directory', file_in_manifest_does_not_exist,
                       False)

    # Assert test case
    assert validator.result.failed, validator.result
    assert not validator.result.fixed
def get_changed_immutable_short_name_manifest():
    """
    Helper function to change immutable short names in a manifest
    """
    immutable_attributes_changed_short_name = JSONDict(
        deepcopy(input_constants.V2_VALID_MANIFEST))
    immutable_attributes_changed_short_name['assets']['dashboards'] = {
        "oracle-changed": "assets/dashboards/example.json"
    }
    return immutable_attributes_changed_short_name
def test_manifest_v2_maintainer_validator_correct_maintainer(setup_route):
    # Use specific validator
    validator = common.MaintainerValidator(is_extras=False,
                                           is_marketplace=False,
                                           check_in_extras=False,
                                           check_in_marketplace=False,
                                           version=V2)
    validator.validate('active_directory',
                       JSONDict(input_constants.V2_VALID_MANIFEST), False)

    # Assert test case
    assert not validator.result.failed, validator.result
    assert not validator.result.fixed