def test_build_base_and_base_bare(data): data["base"] = "bare" data["build-base"] = "fake-base" Validator(data).validate()
def test_type_base_and_no_base(data): data.pop("base") data["type"] = "base" Validator(data).validate()
def test_build_base_and_type_base(data): data.pop("base") data["type"] = "base" data["build-base"] = "fake-base" Validator(data).validate()
def test_valid_types(data, snap_type): data["type"] = snap_type if snap_type in ("base", "kernel", "snapd"): data.pop("base") Validator(data).validate()
def test_invalid_types(data, snap_type): data["type"] = snap_type with pytest.raises(snapcraft_legacy.yaml_utils.errors.YamlValidationError): Validator(data).validate()
def test_daemon_missing_errors(data, mode): data["apps"] = {"service1": {"command": "binary1", "stop-mode": mode}} with pytest.raises(snapcraft_legacy.yaml_utils.errors.YamlValidationError): Validator(data).validate()
def test_valid_compression(data, compression): data["compression"] = compression Validator(data).validate()
def test_valid_adapter(data, adapter): data["apps"] = {"foo": {"command": "foo", "adapter": adapter}} Validator(data).validate()
def test_invalid_part_build_environment_key_type(data, build_environment): data["parts"]["part1"]["build-environment"] = build_environment with pytest.raises(snapcraft_legacy.yaml_utils.errors.YamlValidationError): Validator(data).validate()
def test_valid_epoch(data, epoch): data["epoch"] = epoch Validator(data).validate()
def test_valid_license(data): data["license"] = "MIT-0" Validator(data).validate()
def test_valid_grade(data, grade): data["grade"] = grade Validator(data).validate()
def test_valid_description(data, desc): data["description"] = desc Validator(data).validate()
def test_valid_confinement(data, confinement): data["confinement"] = confinement Validator(data).validate()
def test_valid_app_names(data, name): data["apps"] = {name: {"command": "foo"}} Validator(data).validate()
def test_yaml_valid_system_usernames_long(data, username): data["system-usernames"] = {username: {"scope": "shared"}} Validator(data).validate()
def test_valid_restart_conditions(data, condition): data["apps"] = {"service1": {"command": "binary1", "daemon": "simple"}} data["apps"]["service1"]["restart-condition"] = condition Validator(data).validate()
def test_yaml_valid_system_usernames_short(data, username): data["system-usernames"] = {username: "******"} Validator(data).validate()
def test_valid_title(data, title): data["title"] = title Validator(data).validate()
def test_valid_app_daemons(self): self.data["apps"] = { "service1": { "command": "binary1 start", "daemon": "simple" }, "service2": { "command": "binary2", "stop-command": "binary2 --stop", "daemon": "simple", }, "service3": { "command": "binary3", "daemon": "forking" }, "service4": { "command": "binary4", "daemon": "simple", "restart-condition": "always", }, "service5": { "command": "binary5", "daemon": "notify" }, "service6": { "command": "binary6", "post-stop-command": "binary6 --post-stop", "daemon": "simple", }, "service7": { "command": "binary7", "reload-command": "binary7 --reload", "daemon": "simple", }, "service8": { "command": "binary8", "daemon": "dbus", "bus-name": "org.test.snapcraft", }, "service9": { "command": "binary9", "daemon": "simple", "start-timeout": "1s", }, "service10": { "command": "binary10", "daemon": "simple", "stop-timeout": "1s", }, "service11": { "command": "binary11", "daemon": "simple", "restart-delay": "1s", }, "service12": { "command": "binary12", "daemon": "simple", "watchdog-timeout": "1s", }, "service13": { "command": "binary13", "daemon": "oneshot", "timer": "mon,10:00-12:00", }, "service14": { "command": "binary14", "daemon": "simple", "restart-condition": "on-watchdog", "watchdog-timeout": "30s", }, "service15": { "command": "binary15", "daemon": "simple", "install-mode": "enable", }, "service16": { "command": "binary16", "daemon": "simple", "install-mode": "disable", }, "service17": { "command": "binary17", "daemon": "simple", "activates-on": ["slot1", "slot2"], }, } Validator(self.data).validate()