This repository has been archived on 2024-06-02. You can view files and clone it, but cannot push or open issues or pull requests.
spud-py/tests/test_daemon.py

29 lines
648 B
Python
Raw Permalink Normal View History

from unittest.mock import Mock
import pytest
from fastapi.testclient import TestClient
import spud.daemon
@pytest.fixture(name="client")
def client_fixture():
return TestClient(spud.daemon.app)
def test_alive_returns_200(client):
response = client.get("/")
assert response.status_code == 200
# FIXME: Test premise could be stronger and cover the response schema / API contract.
def test_check_service_statuses_calls_get_services(client, monkeypatch):
mock = Mock()
mock.return_value = []
monkeypatch.setattr(spud.daemon.PodmanManager, "get_services", mock)
client.get("/status")
mock.assert_called_once()