test: add comprehensive tests for license_routes, database migrations, SFTP, S3, and notifications
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
"""Tests for app/views/license_routes.py module."""
|
||||
|
||||
from pathlib import Path
|
||||
from unittest.mock import mock_open, patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -11,3 +14,26 @@ class TestLicenseViews:
|
||||
"""Test license API endpoint."""
|
||||
response = client.get("/api/license")
|
||||
assert response.status_code in (200, 404)
|
||||
|
||||
def test_get_lgpl_license_success(self, client):
|
||||
"""Test successful LGPL license retrieval."""
|
||||
# Create a mock license file
|
||||
license_content = "GNU Lesser General Public License\nVersion 3, 29 June 2007"
|
||||
|
||||
with patch("pathlib.Path.exists", return_value=True):
|
||||
with patch("builtins.open", mock_open(read_data=license_content)):
|
||||
response = client.get("/licenses/lgpl.txt")
|
||||
assert response.status_code == 200
|
||||
assert "GNU Lesser General Public License" in response.text
|
||||
|
||||
def test_get_lgpl_license_not_found(self, client):
|
||||
"""Test LGPL license file not found."""
|
||||
with patch("pathlib.Path.exists", return_value=False):
|
||||
response = client.get("/licenses/lgpl.txt")
|
||||
assert response.status_code == 404
|
||||
assert "not found" in response.json()["detail"].lower()
|
||||
|
||||
def test_serve_attribution_page(self, client):
|
||||
"""Test attribution page is served."""
|
||||
response = client.get("/attribution")
|
||||
assert response.status_code in (200, 404, 500) # Allow for missing template
|
||||
|
||||
Reference in New Issue
Block a user