69 lines
2.0 KiB
Python
69 lines
2.0 KiB
Python
"""employment_agent parse_employment_response — linkedin_url is an agent key."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from employment_agent.decorators import parse_employment_response
|
|
from employment_agent.prompt import EDUCATION, NO_COMPANY, NO_LINKEDIN
|
|
|
|
|
|
def test_parses_linkedin_url_key_separately():
|
|
company, education, title, url = parse_employment_response(
|
|
{
|
|
"current_employment": "Acme",
|
|
"education": "BS CS",
|
|
"current_title": "Engineer",
|
|
"linkedin_url": "https://www.linkedin.com/in/jane-doe",
|
|
},
|
|
"Acme BS CS Engineer",
|
|
)
|
|
assert company == "Acme"
|
|
assert education == "BS CS"
|
|
assert title == "Engineer"
|
|
assert url == "https://www.linkedin.com/in/jane-doe"
|
|
|
|
|
|
def test_sentinel_and_non_linkedin_are_dropped():
|
|
*_, url = parse_employment_response(
|
|
{
|
|
"current_employment": NO_COMPANY,
|
|
"education": EDUCATION,
|
|
"current_title": "x",
|
|
"linkedin_url": NO_LINKEDIN,
|
|
},
|
|
"",
|
|
)
|
|
assert url is None
|
|
*_, github = parse_employment_response(
|
|
{
|
|
"current_employment": NO_COMPANY,
|
|
"education": EDUCATION,
|
|
"current_title": "x",
|
|
"linkedin_url": "https://github.com/jane",
|
|
},
|
|
"",
|
|
)
|
|
assert github is None
|
|
|
|
|
|
def test_adds_scheme_and_rejects_company_page():
|
|
*_, url = parse_employment_response(
|
|
{
|
|
"current_employment": NO_COMPANY,
|
|
"education": EDUCATION,
|
|
"current_title": "x",
|
|
"linkedin_url": "www.linkedin.com/in/jane-doe",
|
|
},
|
|
"",
|
|
)
|
|
assert url == "https://www.linkedin.com/in/jane-doe"
|
|
*_, company = parse_employment_response(
|
|
{
|
|
"current_employment": NO_COMPANY,
|
|
"education": EDUCATION,
|
|
"current_title": "x",
|
|
"linkedin_url": "https://www.linkedin.com/company/acme",
|
|
},
|
|
"",
|
|
)
|
|
assert company is None
|