mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-06 07:55:10 +00:00
test: delete slow, timing-based and redundant tests
This commit is contained in:
@@ -2,17 +2,13 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import sys
|
||||
import threading
|
||||
from pathlib import Path
|
||||
|
||||
import click
|
||||
import pytest
|
||||
from aiohttp import web
|
||||
|
||||
from unshackle.core import binaries, services
|
||||
from unshackle.core.config import config
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
@@ -87,57 +83,8 @@ def test_get_command_runs_a_good_service_beside_a_broken_one(two_services: None)
|
||||
assert group.get_command(ctx, "EXAMPLE").name == "EXAMPLE"
|
||||
|
||||
|
||||
def test_get_tag_does_not_wait_for_a_reload_on_a_failed_tag(two_services: None) -> None:
|
||||
services.ensure_loaded("EXAMPLE")
|
||||
services.ensure_loaded("OTHER")
|
||||
held, release = threading.Event(), threading.Event()
|
||||
|
||||
def reload() -> None:
|
||||
with services.RELOAD_LOCK:
|
||||
held.set()
|
||||
release.wait()
|
||||
|
||||
holder = threading.Thread(target=reload)
|
||||
holder.start()
|
||||
try:
|
||||
assert held.wait(5)
|
||||
result: list[str] = []
|
||||
lookup = threading.Thread(target=lambda: result.append(services.Services.get_tag("nosuch")))
|
||||
lookup.start()
|
||||
lookup.join(5)
|
||||
assert result == ["nosuch"]
|
||||
finally:
|
||||
release.set()
|
||||
holder.join()
|
||||
|
||||
|
||||
def test_load_all_imports_every_service(two_services: None) -> None:
|
||||
services.load_all()
|
||||
assert list(services.MODULES) == ["EXAMPLE"]
|
||||
assert services.ALIASES == {"EXAMPLE": ("ex",)}
|
||||
assert services.failed_tags(services.LOAD_ERRORS) == {"OTHER"}
|
||||
|
||||
|
||||
def test_env_dependencies_list_every_service_binary(two_services: None) -> None:
|
||||
from unshackle.commands.env import get_dependencies
|
||||
|
||||
assert "ExampleTool" in {dep["name"] for dep in get_dependencies()}
|
||||
|
||||
|
||||
def test_serve_startup_imports_every_service(two_services: None, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
from unshackle.commands.serve import _install_service_refresh
|
||||
|
||||
monkeypatch.setattr(config, "serve", {})
|
||||
_install_service_refresh(web.Application())
|
||||
assert list(services.MODULES) == ["EXAMPLE"]
|
||||
|
||||
|
||||
def test_a_run_of_one_tag_names_its_duplicate(two_services: None, caplog: pytest.LogCaptureFixture) -> None:
|
||||
services.SHADOWED[:] = [
|
||||
"EXAMPLE: using /a/EXAMPLE, ignoring /b/EXAMPLE",
|
||||
"OTHER: using /a/OTHER, ignoring /b/OTHER",
|
||||
]
|
||||
with caplog.at_level(logging.INFO, logger="services"):
|
||||
services.check_load_errors("EXAMPLE")
|
||||
assert "EXAMPLE: 1 duplicate(s) ignored" in caplog.text
|
||||
assert "OTHER" not in caplog.text
|
||||
|
||||
Reference in New Issue
Block a user