import pytest from fastapi.testclient import TestClient from devterm.server.app import create_app @pytest.fixture def client(): app = create_app() return TestClient(app) class TestServer: def test_home_page(self, client): response = client.get("/") assert response.status_code == 200 assert "Devterm" in response.text def test_json_page(self, client): response = client.get("/json") assert response.status_code == 200 assert "JSON" in response.text def test_jwt_page(self, client): response = client.get("/jwt") assert response.status_code == 200 assert "JWT" in response.text def test_cron_page(self, client): response = client.get("/cron") assert response.status_code == 200 assert "Cron" in response.text def test_base64_page(self, client): response = client.get("/base64") assert response.status_code == 200 assert "Base64" in response.text def test_url_page(self, client): response = client.get("/url") assert response.status_code == 200 assert "URL" in response.text def test_json_format_endpoint(self, client): response = client.post("/json/format", content='{"key":"value"}') assert response.status_code == 200 data = response.json() assert "result" in data def test_json_validate_endpoint(self, client): response = client.post("/json/validate", content='{"key":"value"}') assert response.status_code == 200 data = response.json() assert data["valid"] is True def test_jwt_decode_endpoint(self, client): token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" response = client.post("/jwt/decode", content=token) assert response.status_code == 200 data = response.json() assert "payload" in data def test_cron_validate_endpoint(self, client): response = client.post("/cron/validate", content="* * * * *") assert response.status_code == 200 data = response.json() assert data["valid"] is True def test_base64_encode_endpoint(self, client): response = client.post("/base64/encode", content="hello") assert response.status_code == 200 data = response.json() assert data["result"] == "aGVsbG8=" def test_base64_decode_endpoint(self, client): response = client.post("/base64/decode", content="aGVsbG8=") assert response.status_code == 200 data = response.json() assert data["result"] == "hello" def test_url_encode_endpoint(self, client): response = client.post("/url/encode", content="hello world") assert response.status_code == 200 data = response.json() assert data["result"] == "hello%20world" def test_url_decode_endpoint(self, client): response = client.post("/url/decode", content="hello%20world") assert response.status_code == 200 data = response.json() assert data["result"] == "hello world"