Add BOINC Telegram bot, CI, and deploy compose
All checks were successful
publish-images / build (push) Successful in 1m3s
All checks were successful
publish-images / build (push) Successful in 1m3s
This commit is contained in:
6
tests/conftest.py
Normal file
6
tests/conftest.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
17
tests/test_boinc_parser.py
Normal file
17
tests/test_boinc_parser.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
from bot.boinc import BoincSnapshot, parse_boinccmd_tasks
|
||||
|
||||
|
||||
def test_parse_sample_tasks():
|
||||
text = Path("sample_data/boinccmd_tasks.txt").read_text()
|
||||
tasks = parse_boinccmd_tasks(text)
|
||||
assert len(tasks) == 3
|
||||
assert tasks[0].status == "active"
|
||||
assert tasks[1].status == "completed"
|
||||
assert tasks[2].status == "active"
|
||||
snapshot = BoincSnapshot(tasks=tasks, fetched_at=datetime.now(timezone.utc))
|
||||
assert len(snapshot.active) == 2
|
||||
assert len(snapshot.completed) == 1
|
||||
assert snapshot.average_progress > 0
|
||||
Reference in New Issue
Block a user