code cleanup, UI change to menu to make it cleaner

This commit is contained in:
2025-11-19 21:27:05 -06:00
parent 41ba4c47b5
commit fdf689316f
10 changed files with 32 additions and 3069 deletions

View File

@@ -37,7 +37,7 @@ class TestScanAPIEndpoints:
assert len(data['scans']) == 1
assert data['scans'][0]['id'] == sample_scan.id
def test_list_scans_pagination(self, client, db):
def test_list_scans_pagination(self, client, db, sample_db_config):
"""Test scan list pagination."""
# Create 25 scans
for i in range(25):
@@ -126,7 +126,7 @@ class TestScanAPIEndpoints:
def test_trigger_scan_success(self, client, db, sample_db_config):
"""Test triggering a new scan."""
response = client.post('/api/scans',
json={'config_file': str(sample_db_config)},
json={'config_id': sample_db_config.id},
content_type='application/json'
)
assert response.status_code == 201
@@ -142,8 +142,8 @@ class TestScanAPIEndpoints:
assert scan.status == 'running'
assert scan.triggered_by == 'api'
def test_trigger_scan_missing_config_file(self, client, db):
"""Test triggering scan without config_file."""
def test_trigger_scan_missing_config_id(self, client, db):
"""Test triggering scan without config_id."""
response = client.post('/api/scans',
json={},
content_type='application/json'
@@ -152,12 +152,12 @@ class TestScanAPIEndpoints:
data = json.loads(response.data)
assert 'error' in data
assert 'config_file is required' in data['message']
assert 'config_id is required' in data['message']
def test_trigger_scan_invalid_config_file(self, client, db):
"""Test triggering scan with non-existent config file."""
def test_trigger_scan_invalid_config_id(self, client, db):
"""Test triggering scan with non-existent config."""
response = client.post('/api/scans',
json={'config_file': '/nonexistent/config.yaml'},
json={'config_id': 99999},
content_type='application/json'
)
assert response.status_code == 400
@@ -231,7 +231,7 @@ class TestScanAPIEndpoints:
"""
# Step 1: Trigger scan
response = client.post('/api/scans',
json={'config_file': str(sample_db_config)},
json={'config_id': sample_db_config.id},
content_type='application/json'
)
assert response.status_code == 201

View File

@@ -151,7 +151,7 @@ class TestScheduleAPIEndpoints:
data = json.loads(response.data)
assert data['id'] == sample_schedule.id
assert data['name'] == sample_schedule.name
assert data['config_file'] == sample_schedule.config_file
assert data['config_id'] == sample_schedule.config_id
assert data['cron_expression'] == sample_schedule.cron_expression
assert data['enabled'] == sample_schedule.enabled
assert 'history' in data
@@ -169,7 +169,7 @@ class TestScheduleAPIEndpoints:
"""Test creating a new schedule."""
schedule_data = {
'name': 'New Test Schedule',
'config_file': sample_db_config,
'config_id': sample_db_config.id,
'cron_expression': '0 3 * * *',
'enabled': True
}
@@ -197,7 +197,7 @@ class TestScheduleAPIEndpoints:
# Missing cron_expression
schedule_data = {
'name': 'Incomplete Schedule',
'config_file': '/app/configs/test.yaml'
'config_id': 1
}
response = client.post(
@@ -215,7 +215,7 @@ class TestScheduleAPIEndpoints:
"""Test creating schedule with invalid cron expression."""
schedule_data = {
'name': 'Invalid Cron Schedule',
'config_file': sample_db_config,
'config_id': sample_db_config.id,
'cron_expression': 'invalid cron'
}
@@ -231,10 +231,10 @@ class TestScheduleAPIEndpoints:
assert 'invalid' in data['error'].lower() or 'cron' in data['error'].lower()
def test_create_schedule_invalid_config(self, client, db):
"""Test creating schedule with non-existent config file."""
"""Test creating schedule with non-existent config."""
schedule_data = {
'name': 'Invalid Config Schedule',
'config_file': '/nonexistent/config.yaml',
'config_id': 99999,
'cron_expression': '0 2 * * *'
}
@@ -399,7 +399,7 @@ class TestScheduleAPIEndpoints:
assert scan is not None
assert scan.triggered_by == 'manual'
assert scan.schedule_id == sample_schedule.id
assert scan.config_file == sample_schedule.config_file
assert scan.config_id == sample_schedule.config_id
def test_trigger_schedule_not_found(self, client, db):
"""Test triggering non-existent schedule."""
@@ -436,7 +436,7 @@ class TestScheduleAPIEndpoints:
# 1. Create schedule
schedule_data = {
'name': 'Integration Test Schedule',
'config_file': sample_db_config,
'config_id': sample_db_config.id,
'cron_expression': '0 2 * * *',
'enabled': True
}
@@ -527,7 +527,7 @@ class TestScheduleAPIEndpoints:
"""Test creating a disabled schedule."""
schedule_data = {
'name': 'Disabled Schedule',
'config_file': sample_db_config,
'config_id': sample_db_config.id,
'cron_expression': '0 2 * * *',
'enabled': False
}
@@ -600,7 +600,7 @@ class TestScheduleAPICronValidation:
for cron_expr in valid_expressions:
schedule_data = {
'name': f'Schedule for {cron_expr}',
'config_file': sample_db_config,
'config_id': sample_db_config.id,
'cron_expression': cron_expr
}
@@ -626,7 +626,7 @@ class TestScheduleAPICronValidation:
for cron_expr in invalid_expressions:
schedule_data = {
'name': f'Schedule for {cron_expr}',
'config_file': sample_db_config,
'config_id': sample_db_config.id,
'cron_expression': cron_expr
}