From a593a9cb941ac3af2051ba7b8996e4abc305d20c Mon Sep 17 00:00:00 2001 From: ocrd Date: Wed, 6 Mar 2024 09:55:10 +0100 Subject: [PATCH] fix 94c61e6 --- ocrdmonitor/environment.py | 3 +- ocrdmonitor/server/jobs.py | 1 - .../server/fixtures/environment.py | 9 ----- tests/ocrdmonitor/server/test_job_endpoint.py | 35 ++----------------- 4 files changed, 3 insertions(+), 45 deletions(-) diff --git a/ocrdmonitor/environment.py b/ocrdmonitor/environment.py index 8bbd5fb..88b9ac0 100644 --- a/ocrdmonitor/environment.py +++ b/ocrdmonitor/environment.py @@ -9,9 +9,8 @@ SubProcessOcrdBrowserFactory, ) from ocrdmonitor import database -from ocrdmonitor.protocols import RemoteServer, Repositories +from ocrdmonitor.protocols import Repositories from ocrdmonitor.server.settings import Settings -from ocrdmonitor.sshremote import SSHRemote BrowserType = Type[SubProcessOcrdBrowser] | Type[DockerOcrdBrowser] CreatingFactories: dict[str, Callable[[set[int]], OcrdBrowserFactory]] = { diff --git a/ocrdmonitor/server/jobs.py b/ocrdmonitor/server/jobs.py index 1eb5458..cf34dc7 100644 --- a/ocrdmonitor/server/jobs.py +++ b/ocrdmonitor/server/jobs.py @@ -8,7 +8,6 @@ from fastapi.responses import JSONResponse from fastapi.templating import Jinja2Templates -from ocrdmonitor.processstatus import ProcessStatus from ocrdmonitor.protocols import Environment, OcrdJob, Repositories import httpx diff --git a/tests/ocrdmonitor/server/fixtures/environment.py b/tests/ocrdmonitor/server/fixtures/environment.py index a9074b7..d50460e 100644 --- a/tests/ocrdmonitor/server/fixtures/environment.py +++ b/tests/ocrdmonitor/server/fixtures/environment.py @@ -12,11 +12,9 @@ from fastapi.testclient import TestClient from ocrdbrowser import OcrdBrowserFactory -from ocrdmonitor.processstatus import ProcessStatus from ocrdmonitor.protocols import ( BrowserProcessRepository, BrowserRestoringFactory, - RemoteServer, Repositories, ) from ocrdmonitor.server.app import create_app @@ -34,13 +32,6 @@ ) -class RemoteDummy: - async def read_file(self, path: str) -> str: - return "" - - async def process_status(self, process_group: int) -> list[ProcessStatus]: - return [] - @dataclass class DevEnvironment: diff --git a/tests/ocrdmonitor/server/test_job_endpoint.py b/tests/ocrdmonitor/server/test_job_endpoint.py index 0307b5c..93fd444 100644 --- a/tests/ocrdmonitor/server/test_job_endpoint.py +++ b/tests/ocrdmonitor/server/test_job_endpoint.py @@ -10,7 +10,6 @@ import pytest from pytest_httpx import HTTPXMock -from ocrdmonitor.processstatus import ProcessState, ProcessStatus from ocrdmonitor.protocols import OcrdJob from tests.ocrdmonitor.server import scraping from tests.ocrdmonitor.server.fixtures.environment import Fixture @@ -58,8 +57,6 @@ async def test__given_a_running_ocrd_job__the_job_endpoint_lists_it_with_resourc repository_fixture: Fixture, ) -> None: pid = 1234 - expected_status = make_status(pid) - remote_stub = RemoteServerStub(expected_status) async with fixture as env: app = env.app @@ -69,7 +66,7 @@ async def test__given_a_running_ocrd_job__the_job_endpoint_lists_it_with_resourc response = app.get("/jobs/") assert response.is_success - assert_lists_running_job(job, expected_status, response) + assert_lists_running_job(job, response) @pytest.mark.asyncio @@ -108,29 +105,6 @@ def non_mocked_hosts() -> list[str]: return ["testserver"] -def make_status(pid: int) -> ProcessStatus: - expected_status = ProcessStatus( - pid=pid, - state=ProcessState.RUNNING, - percent_cpu=0.25, - memory=1024, - cpu_time=timedelta(seconds=10, minutes=5, hours=1), - ) - - return expected_status - - -class RemoteServerStub: - def __init__(self, expected_status: ProcessStatus) -> None: - self.expected_status = expected_status - - async def read_file(self, path: str) -> str: - return str(self.expected_status.pid) - - async def process_status(self, process_group: int) -> list[ProcessStatus]: - return [self.expected_status] - - def running_ocrd_job(pid: int) -> OcrdJob: running_job = replace(job_template(), pid=pid) return running_job @@ -154,7 +128,6 @@ def assert_lists_completed_job( def assert_lists_running_job( running_job: OcrdJob, - process_status: ProcessStatus, response: Response, ) -> None: texts = collect_texts_from_job_table(response.content, "running-jobs") @@ -164,11 +137,7 @@ def assert_lists_running_job( str(running_job.task_id), str(running_job.process_id), running_job.workflow_file.name, - str(process_status.pid), - str(process_status.state), - str(process_status.percent_cpu), - str(process_status.memory), - str(process_status.cpu_time), + str(running_job.pid), ]