mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-03-30 23:03:03 -07:00
@@ -23,9 +23,9 @@ import test_ui_plugins # noqa: E402 [flake8 lint suppression]
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Run all UI tests and provide summary"""
|
"""Run all UI tests and provide summary"""
|
||||||
print("\n" + "="*70)
|
print("\n" + "=" * 70)
|
||||||
print("NetAlertX UI Test Suite")
|
print("NetAlertX UI Test Suite")
|
||||||
print("="*70)
|
print("=" * 70)
|
||||||
|
|
||||||
test_modules = [
|
test_modules = [
|
||||||
("Dashboard", test_ui_dashboard),
|
("Dashboard", test_ui_dashboard),
|
||||||
@@ -49,9 +49,9 @@ def main():
|
|||||||
results[name] = False
|
results[name] = False
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
print("\n" + "="*70)
|
print("\n" + "=" * 70)
|
||||||
print("Test Summary")
|
print("Test Summary")
|
||||||
print("="*70 + "\n")
|
print("=" * 70 + "\n")
|
||||||
|
|
||||||
for name, passed in results.items():
|
for name, passed in results.items():
|
||||||
status = "✓" if passed else "✗"
|
status = "✓" if passed else "✗"
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ Shared test utilities and configuration
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pytest
|
|
||||||
import requests
|
import requests
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.chrome.options import Options
|
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")
|
BASE_URL = os.getenv("UI_BASE_URL", "http://localhost:20211")
|
||||||
API_BASE_URL = os.getenv("API_BASE_URL", "http://localhost:20212")
|
API_BASE_URL = os.getenv("API_BASE_URL", "http://localhost:20212")
|
||||||
|
|
||||||
|
|
||||||
def get_api_token():
|
def get_api_token():
|
||||||
"""Get API token from config file"""
|
"""Get API token from config file"""
|
||||||
config_path = "/data/config/app.conf"
|
config_path = "/data/config/app.conf"
|
||||||
@@ -29,14 +29,13 @@ def get_api_token():
|
|||||||
print(f"⚠ Config file not found: {config_path}")
|
print(f"⚠ Config file not found: {config_path}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_driver(download_dir=None):
|
def get_driver(download_dir=None):
|
||||||
"""Create a Selenium WebDriver for Chrome/Chromium
|
"""Create a Selenium WebDriver for Chrome/Chromium
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
download_dir: Optional directory for downloads. If None, uses /tmp/selenium_downloads
|
download_dir: Optional directory for downloads. If None, uses /tmp/selenium_downloads
|
||||||
"""
|
"""
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
# Check if chromedriver exists
|
# Check if chromedriver exists
|
||||||
chromedriver_paths = ['/usr/bin/chromedriver', '/usr/local/bin/chromedriver']
|
chromedriver_paths = ['/usr/bin/chromedriver', '/usr/local/bin/chromedriver']
|
||||||
@@ -97,6 +96,7 @@ def get_driver(download_dir=None):
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def api_get(endpoint, api_token, timeout=5):
|
def api_get(endpoint, api_token, timeout=5):
|
||||||
"""Make GET request to API - endpoint should be path only (e.g., '/devices')"""
|
"""Make GET request to API - endpoint should be path only (e.g., '/devices')"""
|
||||||
headers = {"Authorization": f"Bearer {api_token}"}
|
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}"
|
url = endpoint if endpoint.startswith('http') else f"{API_BASE_URL}{endpoint}"
|
||||||
return requests.get(url, headers=headers, timeout=timeout)
|
return requests.get(url, headers=headers, timeout=timeout)
|
||||||
|
|
||||||
|
|
||||||
def api_post(endpoint, api_token, data=None, timeout=5):
|
def api_post(endpoint, api_token, data=None, timeout=5):
|
||||||
"""Make POST request to API - endpoint should be path only (e.g., '/devices')"""
|
"""Make POST request to API - endpoint should be path only (e.g., '/devices')"""
|
||||||
headers = {"Authorization": f"Bearer {api_token}"}
|
headers = {"Authorization": f"Bearer {api_token}"}
|
||||||
|
|||||||
Reference in New Issue
Block a user