import pytest from flask import url_for def test_dashboard_home(client): """Test dashboard home route""" response = client.get('/dashboard/') assert response.status_code == 200 assert b"Dashboard" in response.data def test_server_view(client, app): """Test server detail view""" # Create test server from app.core.models import Subnet, Server from app.core.extensions import db with app.app_context(): subnet = Subnet(cidr='192.168.1.0/24', location='Test') server = Server(hostname='test-server', ip_address='192.168.1.10', subnet=subnet) db.session.add(subnet) db.session.add(server) db.session.commit() # Test viewing the server response = client.get(f'/dashboard/server/{server.id}') assert response.status_code == 200 assert b'test-server' in response.data assert b'192.168.1.10' in response.data def test_api_status(client): """Test API status endpoint""" response = client.get('/api/status') assert response.status_code == 200 json_data = response.get_json() assert json_data['status'] == 'OK' def test_markdown_preview(client): """Test markdown preview API""" md_content = "# Test Heading\nThis is a test." response = client.post('/api/markdown-preview', json={'markdown': md_content}) assert response.status_code == 200 json_data = response.get_json() assert '

Test Heading

' in json_data['html'] assert '

This is a test.

' in json_data['html'] def test_subnet_scan(client, app): """Test subnet scanning API""" # Create test subnet from app.core.models import Subnet from app.core.extensions import db with app.app_context(): subnet = Subnet(cidr='192.168.1.0/24', location='Test', auto_scan=True) db.session.add(subnet) db.session.commit() # Test scanning endpoint response = client.post(f'/ipam/subnet/{subnet.id}/scan') assert response.status_code == 200 json_data = response.get_json() assert json_data['status'] == 'scanning' assert json_data['subnet_id'] == subnet.id