Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions huntflow_api_client/entities/vacancy_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ async def list(
count: int = 30,
page: int = 1,
values: bool = False,
include_taken: bool = False,
include_not_approved: bool = False,
) -> VacancyRequestListResponse:
"""
API method reference:
Expand All @@ -32,8 +34,18 @@ async def list(
:param count: Number of items per page
:param page: Page number
:param values: Show values flag. If True, vacancy requests fields will be included
:param include_taken: Show requests already taken to work.
If True,requests taken to work shown
:param include_not_approved: Show vacancy requests from other coworkers.
If True, requests from other coworkers shown
:raises ValueError:
Parameters include_taken/include_not_approved cannot be passed with vacancy_id
:return: List of vacancy requests
"""
if vacancy_id and (include_taken or include_not_approved):
raise ValueError(
"Parameters include_taken/include_not_approved cannot be passed with vacancy_id",
)
path = f"/accounts/{account_id}/vacancy_requests"
params = {
"count": count,
Expand All @@ -42,6 +54,9 @@ async def list(
}
if vacancy_id:
params["vacancy_id"] = vacancy_id
else:
params["include_taken"] = include_taken
params["include_not_approved"] = include_not_approved

response = await self._api.request("GET", path, params=params)
return VacancyRequestListResponse.model_validate(response.json())
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

[project]
name = "huntflow-api-client"
version = "2.13.7"
version = "2.13.8"
description = "Huntflow API Client for Python"
authors = [
{name = "Developers huntflow", email = "developer@huntflow.ru"},
Expand Down
52 changes: 52 additions & 0 deletions tests/test_entities/test_vacancy_request.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
from pytest_httpx import HTTPXMock

from huntflow_api_client import HuntflowAPI
Expand Down Expand Up @@ -85,6 +86,7 @@ async def test_list_vacancy_request(
url=(
f"{VERSIONED_BASE_URL}/accounts/{ACCOUNT_ID}"
f"/vacancy_requests?page=1&&count=30&&values=false"
f"&&include_taken=false&&include_not_approved=false"
),
json=VACANCY_REQUEST_LIST_WITHOUT_VALUES,
)
Expand All @@ -107,6 +109,56 @@ async def test_list_vacancy_request(
response = await vacancy_request.list(ACCOUNT_ID, vacancy_id=1, values=True)
assert response == VacancyRequestListResponse.model_validate(VACANCY_REQUEST_LIST_WITH_VALUES)

httpx_mock.add_response(
url=(
f"{VERSIONED_BASE_URL}/accounts/{ACCOUNT_ID}/vacancy_requests?"
f"page=1&&count=30&&values=false&&include_taken=false&&include_not_approved=true"
),
json=VACANCY_REQUEST_LIST_WITHOUT_VALUES,
)
response = await vacancy_request.list(ACCOUNT_ID, include_not_approved=True)
assert response == VacancyRequestListResponse.model_validate(
VACANCY_REQUEST_LIST_WITHOUT_VALUES,
)

httpx_mock.add_response(
url=(
f"{VERSIONED_BASE_URL}/accounts/{ACCOUNT_ID}/vacancy_requests?"
f"page=1&&count=30&&values=false&&include_taken=true&&include_not_approved=false"
),
json=VACANCY_REQUEST_LIST_WITHOUT_VALUES,
)
response = await vacancy_request.list(ACCOUNT_ID, include_taken=True)
assert response == VacancyRequestListResponse.model_validate(
VACANCY_REQUEST_LIST_WITHOUT_VALUES,
)

httpx_mock.add_response(
url=(
f"{VERSIONED_BASE_URL}/accounts/{ACCOUNT_ID}/vacancy_requests?"
f"page=1&&count=30&&values=false&&include_taken=true&&include_not_approved=true"
),
json=VACANCY_REQUEST_LIST_WITHOUT_VALUES,
)
response = await vacancy_request.list(ACCOUNT_ID, include_taken=True, include_not_approved=True)
assert response == VacancyRequestListResponse.model_validate(
VACANCY_REQUEST_LIST_WITHOUT_VALUES,
)

with pytest.raises(ValueError):
await vacancy_request.list(
ACCOUNT_ID,
vacancy_id=1,
include_taken=True,
include_not_approved=True,
)

with pytest.raises(ValueError):
await vacancy_request.list(ACCOUNT_ID, vacancy_id=1, include_taken=True)

with pytest.raises(ValueError):
await vacancy_request.list(ACCOUNT_ID, vacancy_id=1, include_not_approved=True)


async def test_get_vacancy_request(
httpx_mock: HTTPXMock,
Expand Down
Loading