fix: suppress noisy cleanup warnings in pytest and fix fleet test auth

This commit is contained in:
2026-04-09 01:05:34 -04:00
parent 9dc6ff3887
commit 0123e1c69e
6 changed files with 34 additions and 6 deletions

View File

@@ -0,0 +1,4 @@
# file: /home/anti/Tools/DECNET/.venv/bin/pytest
# hypothesis_version: 6.151.12
['__main__']

View File

@@ -1,6 +1,7 @@
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import { NavLink } from 'react-router-dom'; import { NavLink } from 'react-router-dom';
import { Menu, X, Search, Activity, LayoutDashboard, Terminal, Settings, LogOut, Server } from 'lucide-react'; import { Menu, X, Search, Activity, LayoutDashboard, Terminal, Settings, LogOut, Server } from 'lucide-react';
import api from '../utils/api';
import './Layout.css'; import './Layout.css';
interface LayoutProps { interface LayoutProps {
@@ -12,12 +13,27 @@ interface LayoutProps {
const Layout: React.FC<LayoutProps> = ({ children, onLogout, onSearch }) => { const Layout: React.FC<LayoutProps> = ({ children, onLogout, onSearch }) => {
const [sidebarOpen, setSidebarOpen] = useState(true); const [sidebarOpen, setSidebarOpen] = useState(true);
const [search, setSearch] = useState(''); const [search, setSearch] = useState('');
const [systemActive, setSystemActive] = useState(false);
const handleSearchSubmit = (e: React.FormEvent) => { const handleSearchSubmit = (e: React.FormEvent) => {
e.preventDefault(); e.preventDefault();
onSearch(search); onSearch(search);
}; };
useEffect(() => {
const fetchStatus = async () => {
try {
const res = await api.get('/stats');
setSystemActive(res.data.deployed_deckies > 0);
} catch (err) {
console.error('Failed to fetch system status', err);
}
};
fetchStatus();
const interval = setInterval(fetchStatus, 10000);
return () => clearInterval(interval);
}, []);
return ( return (
<div className="layout-container"> <div className="layout-container">
{/* Sidebar */} {/* Sidebar */}
@@ -60,7 +76,9 @@ const Layout: React.FC<LayoutProps> = ({ children, onLogout, onSearch }) => {
/> />
</form> </form>
<div className="topbar-status"> <div className="topbar-status">
<span className="matrix-text neon-blink">SYSTEM: ACTIVE</span> <span className="matrix-text" style={{ color: systemActive ? 'var(--text-color)' : 'var(--accent-color)' }}>
SYSTEM: {systemActive ? 'ACTIVE' : 'INACTIVE'}
</span>
</div> </div>
</header> </header>

View File

@@ -196,8 +196,8 @@ const LiveLogs: React.FC = () => {
onClick={handleToggleLive} onClick={handleToggleLive}
style={{ style={{
display: 'flex', alignItems: 'center', gap: '8px', display: 'flex', alignItems: 'center', gap: '8px',
border: `1px solid ${streaming ? 'var(--text-color)' : 'var(--border-color)'}`, border: `1px solid ${streaming ? 'var(--text-color)' : 'var(--accent-color)'}`,
color: streaming ? 'var(--text-color)' : 'var(--dim-color)', color: streaming ? 'var(--text-color)' : 'var(--accent-color)',
minWidth: '120px', justifyContent: 'center' minWidth: '120px', justifyContent: 'center'
}} }}
> >

View File

@@ -35,6 +35,11 @@ dev = [
[project.scripts] [project.scripts]
decnet = "decnet.cli:app" decnet = "decnet.cli:app"
[tool.pytest.ini_options]
filterwarnings = [
"ignore::pytest.PytestUnhandledThreadExceptionWarning",
]
[tool.setuptools.packages.find] [tool.setuptools.packages.find]
where = ["."] where = ["."]
include = ["decnet*"] include = ["decnet*"]

View File

@@ -4,6 +4,7 @@ from fastapi.testclient import TestClient
from decnet.web.api import app from decnet.web.api import app
import decnet.config import decnet.config
from pathlib import Path from pathlib import Path
from decnet.env import DECNET_ADMIN_USER, DECNET_ADMIN_PASSWORD
TEST_STATE_FILE = Path("test-decnet-state.json") TEST_STATE_FILE = Path("test-decnet-state.json")
@@ -64,7 +65,7 @@ def mock_state_file():
def test_get_deckies_endpoint(mock_state_file): def test_get_deckies_endpoint(mock_state_file):
with TestClient(app) as _client: with TestClient(app) as _client:
# Login to get token # Login to get token
_login_resp = _client.post("/api/v1/auth/login", json={"username": "admin", "password": "admin"}) _login_resp = _client.post("/api/v1/auth/login", json={"username": DECNET_ADMIN_USER, "password": DECNET_ADMIN_PASSWORD})
_token = _login_resp.json()["access_token"] _token = _login_resp.json()["access_token"]
_response = _client.get("/api/v1/deckies", headers={"Authorization": f"Bearer {_token}"}) _response = _client.get("/api/v1/deckies", headers={"Authorization": f"Bearer {_token}"})
@@ -76,7 +77,7 @@ def test_get_deckies_endpoint(mock_state_file):
def test_stats_includes_deployed_count(mock_state_file): def test_stats_includes_deployed_count(mock_state_file):
with TestClient(app) as _client: with TestClient(app) as _client:
_login_resp = _client.post("/api/v1/auth/login", json={"username": "admin", "password": "admin"}) _login_resp = _client.post("/api/v1/auth/login", json={"username": DECNET_ADMIN_USER, "password": DECNET_ADMIN_PASSWORD})
_token = _login_resp.json()["access_token"] _token = _login_resp.json()["access_token"]
_response = _client.get("/api/v1/stats", headers={"Authorization": f"Bearer {_token}"}) _response = _client.get("/api/v1/stats", headers={"Authorization": f"Bearer {_token}"})