"""
Gate Unit tests
"""
import pytest

from anchore_engine.db import Image
from anchore_engine.services.policy_engine.engine.policy.gates.image_metadata import (
    ImageMetadataAttributeCheckTrigger,
    ImageMetadataGate,
)
from anchore_engine.subsys import logger
from tests.integration.services.policy_engine.engine.policy.gates import GateUnitTest

logger.enable_test_logging()

test_image = Image()
test_image.distro_name = "debian"
test_image.distro_version = "9"
test_image.like_distro = "debian"
test_image.user_id = "0"
test_image.layers_json = ["sha256:a", "sha256:b", "sha256:c"]
test_image.layer_info_json = ["layer1", "layer2"]
test_image.dockerfile_contents = "FROM SCRATCH\nHEALTHcheck blah\n"
test_image.dockerfile_mode = "Guessed"
test_image.size = 100 * 1024 * 1024
test_image.docker_data_json = {
    "Comment": "",
    "Container": "4e69ef98747345110dc23069be98ff0ae562cc83a187ff1bdd1d2e0048889679",
    "DockerVersion": "17.03.1-ce",
    "Parent": "",
    "Created": "2017-05-15T17:41:29.424239055Z",
    "Config": {
        "Tty": False,
        "Cmd": ["node"],
        "Volumes": None,
        "Domainname": "",
        "WorkingDir": "",
        "Image": "sha256:6f109e97451ad43719c0a1802153811ad2f02d912a1d15a2ed7f0728be3026b6",
        "Hostname": "200591939db7",
        "StdinOnce": False,
        "ArgsEscaped": True,
        "Labels": {},
        "AttachStdin": False,
        "User": "",
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "NPM_CONFIG_LOGLEVEL=info",
            "NODE_VERSION=7.10.0",
            "YARN_VERSION=0.24.4",
        ],
        "Entrypoint": False,
        "OnBuild": [],
        "AttachStderr": False,
        "AttachStdout": False,
        "OpenStdin": False,
    },
    "RepoDigests": [
        "node@sha256:ca55f4f5cb68a78c3ad9fe1ee13cba692906ec25dd73782800cbd4ae4b9fac45"
    ],
    "Author": "",
    "GraphDriver": {"Data": None, "Name": "aufs"},
    "Id": "sha256:6c792d9195914c8038f4cabd9356a5af47ead140b87682c8651edd55b010686c",
    "VirtualSize": 665664130,
    "Architecture": "amd64",
    "ContainerConfig": {
        "Tty": False,
        "Cmd": ["/bin/sh", "-c", "#(nop) ", 'CMD ["node"]'],
        "Volumes": None,
        "Domainname": "",
        "WorkingDir": "",
        "Image": "sha256:6f109e97451ad43719c0a1802153811ad2f02d912a1d15a2ed7f0728be3026b6",
        "Hostname": "200591939db7",
        "StdinOnce": False,
        "ArgsEscaped": True,
        "Labels": {},
        "AttachStdin": False,
        "User": "",
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "NPM_CONFIG_LOGLEVEL=info",