TEST: linting fixes

Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
jokob-sk
2026-01-11 12:56:56 +11:00
parent 75ee015864
commit 3cb55eb35c
2 changed files with 8 additions and 7 deletions

View File

@@ -23,9 +23,9 @@ import test_ui_plugins # noqa: E402 [flake8 lint suppression]
def main():
"""Run all UI tests and provide summary"""
print("\n" + "="*70)
print("\n" + "=" * 70)
print("NetAlertX UI Test Suite")
print("="*70)
print("=" * 70)
test_modules = [
("Dashboard", test_ui_dashboard),
@@ -49,9 +49,9 @@ def main():
results[name] = False
# Summary
print("\n" + "="*70)
print("\n" + "=" * 70)
print("Test Summary")
print("="*70 + "\n")
print("=" * 70 + "\n")
for name, passed in results.items():
status = "" if passed else ""

View File

@@ -4,7 +4,6 @@ Shared test utilities and configuration
"""
import os
import pytest
import requests
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
@@ -14,6 +13,7 @@ from selenium.webdriver.chrome.service import Service
BASE_URL = os.getenv("UI_BASE_URL", "http://localhost:20211")
API_BASE_URL = os.getenv("API_BASE_URL", "http://localhost:20212")
def get_api_token():
"""Get API token from config file"""
config_path = "/data/config/app.conf"
@@ -29,14 +29,13 @@ def get_api_token():
print(f"⚠ Config file not found: {config_path}")
return None
def get_driver(download_dir=None):
"""Create a Selenium WebDriver for Chrome/Chromium
Args:
download_dir: Optional directory for downloads. If None, uses /tmp/selenium_downloads
"""
import os
import subprocess
# Check if chromedriver exists
chromedriver_paths = ['/usr/bin/chromedriver', '/usr/local/bin/chromedriver']
@@ -97,6 +96,7 @@ def get_driver(download_dir=None):
traceback.print_exc()
return None
def api_get(endpoint, api_token, timeout=5):
"""Make GET request to API - endpoint should be path only (e.g., '/devices')"""
headers = {"Authorization": f"Bearer {api_token}"}
@@ -104,6 +104,7 @@ def api_get(endpoint, api_token, timeout=5):
url = endpoint if endpoint.startswith('http') else f"{API_BASE_URL}{endpoint}"
return requests.get(url, headers=headers, timeout=timeout)
def api_post(endpoint, api_token, data=None, timeout=5):
"""Make POST request to API - endpoint should be path only (e.g., '/devices')"""
headers = {"Authorization": f"Bearer {api_token}"}