Skip to content

Commit c787cfa

Browse files
authored
Forward fix the web api pr (#345)
* fix unittest
1 parent 63fca80 commit c787cfa

3 files changed

Lines changed: 21 additions & 94 deletions

File tree

src/libkernelbot/background_submission_manager.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import logging
55
from dataclasses import dataclass
66

7-
from kernelbot.api.api_utils import MultiProgressReporterAPI
87
from libkernelbot.backend import KernelBackend
98
from libkernelbot.consts import SubmissionMode
9+
from libkernelbot.report import MultiProgressReporter, RunProgressReporter, RunResultReport
1010
from libkernelbot.submission import ProcessedSubmissionRequest
1111
from libkernelbot.utils import setup_logging
1212

@@ -28,6 +28,25 @@ class JobItem:
2828
HARD_TIMEOUT_SEC = 60 * 30 # hard timeout 30 mins
2929

3030

31+
# Reporter used in background submission manager, it is a dummy reporter that does nothing
32+
class BackgroundSubmissionManagerReporter(MultiProgressReporter):
33+
def __init__(self):
34+
self.runs = []
35+
async def show(self, title: str):
36+
return
37+
def add_run(self, title: str) ->"BackgroundSubmissionManagerReporterRunProgressReporter":
38+
rep = BackgroundSubmissionManagerReporterRunProgressReporter(title)
39+
self.runs.append(rep)
40+
return rep
41+
def make_message(self):
42+
return
43+
class BackgroundSubmissionManagerReporterRunProgressReporter(RunProgressReporter):
44+
async def _update_message(self):
45+
pass
46+
async def display_report(self, title: str, report: RunResultReport):
47+
pass
48+
49+
3150
class BackgroundSubmissionManager:
3251
"""
3352
This class manages submission in the backeground. It is responsible for
@@ -211,7 +230,7 @@ async def heartbeat():
211230

212231
hb_task = asyncio.create_task(heartbeat(), name=f"hb-{sub_id}")
213232
try:
214-
reporter = MultiProgressReporterAPI()
233+
reporter = BackgroundSubmissionManagerReporter()
215234
await asyncio.wait_for(
216235
self.backend.submit_full(
217236
item.req, item.mode, reporter, sub_id

tests/conftest.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,9 @@
1-
import os
21
import subprocess
32
import time
43
from pathlib import Path
54

65
import pytest
76

8-
REQUIRED = {
9-
"DISCORD_TOKEN": "dummy",
10-
"GITHUB_TOKEN": "dummy",
11-
"GITHUB_REPO": "dummy",
12-
}
13-
14-
for k, v in REQUIRED.items():
15-
os.environ.setdefault(k, v)
16-
17-
@pytest.fixture(scope="session", autouse=True)
18-
def _restore_env():
19-
old = {k: os.environ.get(k) for k in REQUIRED}
20-
try:
21-
yield
22-
finally:
23-
for k, v in old.items():
24-
if v is None:
25-
os.environ.pop(k, None)
26-
else:
27-
os.environ[k] = v
28-
297
DATABASE_URL = "postgresql://postgres:postgres@localhost:5433/clusterdev"
308

319

tests/test_validate_user_header.py

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)