project-sheets: год опциональный с null
This commit is contained in:
parent
2e781ca809
commit
0a99aeed0c
@ -374,6 +374,10 @@ class AddProjectBody(BaseModel):
|
|||||||
staff_count: Optional[int] = None
|
staff_count: Optional[int] = None
|
||||||
total_area: Optional[float] = None
|
total_area: Optional[float] = None
|
||||||
|
|
||||||
|
@field_validator("year", mode="before")
|
||||||
|
@classmethod
|
||||||
|
def optional_year(cls, v: Any) -> Any:
|
||||||
|
return v or datetime.now().year
|
||||||
|
|
||||||
class AddLineSchema(BaseModel):
|
class AddLineSchema(BaseModel):
|
||||||
expense_item_id: Optional[int] = None
|
expense_item_id: Optional[int] = None
|
||||||
|
|||||||
@ -48,6 +48,31 @@ def _add_line(client, admin_tokens, auth_headers, project_id: int) -> int:
|
|||||||
pytest.skip("Не удалось подобрать expense_item_id для add_form3_line в текущей БД")
|
pytest.skip("Не удалось подобрать expense_item_id для add_form3_line в текущей БД")
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_project_smoke(client, admin_tokens, auth_headers):
|
||||||
|
name = f"PT_{uuid.uuid4().hex[:10]}"
|
||||||
|
response = client.post(
|
||||||
|
"/api/v1/projects",
|
||||||
|
json={"name": name, "year": None, "branch_id": 1},
|
||||||
|
headers=auth_headers(admin_tokens),
|
||||||
|
)
|
||||||
|
assert response.status_code == 200
|
||||||
|
payload = response.json()
|
||||||
|
assert "project_id" in payload
|
||||||
|
assert (project_id := payload["project_id"]) is not None
|
||||||
|
response = client.get(
|
||||||
|
f"/api/v1/projects/{project_id}",
|
||||||
|
headers=auth_headers(admin_tokens),
|
||||||
|
)
|
||||||
|
assert response.status_code == 200
|
||||||
|
payload = response.json()
|
||||||
|
assert "result" in payload
|
||||||
|
assert "id" in payload["result"]
|
||||||
|
assert payload["result"]["id"] == project_id
|
||||||
|
assert "years" in payload["result"]
|
||||||
|
assert isinstance(payload["result"]["years"], list)
|
||||||
|
assert len(payload["result"]["years"]) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_projects_write_smoke(client, admin_tokens, auth_headers):
|
def test_projects_write_smoke(client, admin_tokens, auth_headers):
|
||||||
project_id, name = _create_project(client, admin_tokens, auth_headers)
|
project_id, name = _create_project(client, admin_tokens, auth_headers)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user