Skip to content
Merged
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
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ jobs:
id: setup-uv
with:
enable-cache: true
cache-prefix: ${{ matrix.python-version }}

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ jobs:
id: setup-uv
with:
enable-cache: true
cache-prefix: ${{ matrix.python-version }}

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
Expand Down
6 changes: 6 additions & 0 deletions magicalapi/types/resume_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Basic(BaseModelValidated, OptionalModel):
university: str
graduation_year: str
majors: str
birthday: str

class ProjectExperience(BaseModelValidated, OptionalModel):
title: str | None
Expand Down Expand Up @@ -63,6 +64,10 @@ class Skill(BaseModelValidated, OptionalModel):
name: str


class Intereset(BaseModelValidated, OptionalModel):
name: str


class ResumeParser(BaseModelValidated):
basic: Resume.Basic
summary: str | None
Expand All @@ -72,6 +77,7 @@ class ResumeParser(BaseModelValidated):
certifications: list[Resume.Certification]
languages: list[Resume.Language]
skills: list[Resume.Skill]
interests: list[Intereset]


class ResumeParserResponse(BaseResponse):
Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def resume_data():
"university": fake.company(),
"graduation_year": fake.date_object().strftime("%m/%Y"),
"majors": fake.text(max_nb_chars=50),
"birthday": fake.text(max_nb_chars=50),
},
"summary": fake.text(),
"project_experiences": [{"title": fake.text(), "description": fake.text()}],
Expand Down Expand Up @@ -72,6 +73,7 @@ def resume_data():
"skills": [
{"name": "Python"},
],
"interests": [{"name": fake.text()} for _ in range(randint(1, 5))],
}
yield resume_parser_data

Expand Down
19 changes: 15 additions & 4 deletions tests/services/test_base_service.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections.abc import AsyncGenerator
import json
from random import randint

Expand All @@ -13,9 +14,18 @@


@pytest_asyncio.fixture(scope="function")
async def httpxclient():
async def httpxclient(request) -> AsyncGenerator[httpx.AsyncClient]:
timeout = (
request.param
if hasattr(request, "param") and isinstance(request.param, int | float)
else None
)

# base url is empty
client = httpx.AsyncClient(headers={"content-type": "application/json"}, timeout=5)
client = httpx.AsyncClient(
headers={"content-type": "application/json"},
timeout=timeout,
)

yield client

Expand Down Expand Up @@ -51,18 +61,19 @@ async def test_base_service_get_request(httpxclient: httpx.AsyncClient):


@pytest.mark.asyncio
@pytest.mark.parametrize("httpxclient", [4.0], indirect=True)
async def test_base_service_request_timed_out(httpxclient: httpx.AsyncClient):
base_service = BaseService(httpxclient)
# change in fixture timeout

# post request
with pytest.raises(APIServerTimedout):
await base_service._send_post_request(
path="https://httpbin.org/delay/6", data={}
path="https://httpbin.org/delay/10", data={}
)
# gee request
with pytest.raises(APIServerTimedout):
await base_service._send_get_request(path="https://httpbin.org/delay/6")
await base_service._send_get_request(path="https://httpbin.org/delay/10")


def test_base_service_validating_response(httpxclient: httpx.AsyncClient):
Expand Down