28 lines
1.2 KiB
Python
28 lines
1.2 KiB
Python
"""Een onbekend platform is geen bewijs dat een image installeerbaar is."""
|
|
import json
|
|
import sys
|
|
import time
|
|
|
|
from test_image_cache import ci
|
|
|
|
|
|
def test_onbekend_platform_krijgt_geen_goedkeuring(ci, monkeypatch):
|
|
monkeypatch.setattr(ci.image_controle, "platformen", lambda image: ["?"])
|
|
reden, _ = ci.controleer("voorbeeld/app:1")
|
|
assert reden, "Zonder platformbewijs mag de controle niet slagen"
|
|
|
|
|
|
def test_onbekend_platform_wordt_niet_als_succes_gecached(ci, monkeypatch, tmp_path):
|
|
monkeypatch.setattr(sys, "argv", ["controleer_images.py", "--json"])
|
|
monkeypatch.setattr(ci, "images", lambda: {"voorbeeld/app:1": ["proefapp"]})
|
|
monkeypatch.setattr(ci, "belooft_arm64", lambda: {"proefapp"})
|
|
monkeypatch.setattr(ci.image_controle, "platformen", lambda image: ["?"])
|
|
assert ci.main() == 1, "De wekelijkse CI mag een onbekend platform niet goedkeuren"
|
|
cache = json.loads((tmp_path / "images.json").read_text())
|
|
assert "voorbeeld/app:1" not in cache
|
|
|
|
|
|
def test_oude_cache_met_onbekende_platformen_wordt_opnieuw_gecontroleerd(ci):
|
|
nu = time.time()
|
|
cache = {"voorbeeld/app:1": {"ts": nu, "platformen": ["?"]}}
|
|
assert ci.te_controleren({"voorbeeld/app:1": ["proefapp"]}, cache, nu) == ["voorbeeld/app:1"]
|