<%
    model_name = entity.name.capitalize()
    endpoint = '/' + entity.name.lower() + 's'
%>
import pytest
from fastapi.testclient import TestClient

def test_create_${entity.name.lower()}(client: TestClient):
    response = client.post(
        "${endpoint}/",
        json={
            % for field in entity.fields:
            % if field['name'] != 'id':
            "${field['name']}": ${'"test"' if field['type'] == 'String' else '1' if field['type'] == 'Long' else 'True' if field['type'] == 'Boolean' else '"test"'},
            % endif
            % endfor
        },
    )
    assert response.status_code == 200
    data = response.json()
    assert "id" in data
    % for field in entity.fields:
    % if field['name'] != 'id':
    assert data["${field['name']}"] == ${'"test"' if field['type'] == 'String' else '1' if field['type'] == 'Long' else 'True' if field['type'] == 'Boolean' else '"test"'}
    % endif
    % endfor

def test_get_${entity.name.lower()}(client: TestClient):
    # 先创建一个测试数据
    create_response = client.post(
        "${endpoint}/",
        json={
            % for field in entity.fields:
            % if field['name'] != 'id':
            "${field['name']}": ${'"test"' if field['type'] == 'String' else '1' if field['type'] == 'Long' else 'True' if field['type'] == 'Boolean' else '"test"'},
            % endif
            % endfor
        },
    )
    ${entity.name.lower()}_id = create_response.json()["id"]

    # 测试获取
    response = client.get(f"${endpoint}/{${entity.name.lower()}_id}")
    assert response.status_code == 200
    data = response.json()
    assert data["id"] == ${entity.name.lower()}_id