personabot-api / tests /test_site_profile.py
GitHub Actions
Deploy 33c771f
f6b36ec
Raw History Blame Contribute Delete
1.76 kB
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from ingestion.site_profile import profile_chunks
LLMS_TXT = """# Darshan Chheda
> London-based software engineer.
## Availability
Open to software engineering roles in the UK
## Links
- [Website](https://www.darshanchheda.com): Canonical portfolio and profile
- [Email](mailto:me@darshanchheda.com): Direct contact
- [GitHub](https://github.com/1337XCode)
- [LinkedIn](https://linkedin.com/in/darshchheda)
## Pages
- [Photos](https://www.darshanchheda.com/photos): Photographs.
"""
def test_each_section_is_a_chunk_that_says_whose_section_it_is() -> None:
[(page, label), *_] = profile_chunks(LLMS_TXT)
assert label == "site-profile"
assert [chunk["metadata"]["section"] for chunk in page] == ["Profile", "Availability", "Links", "Pages"]
assert page[0]["text"] == "Darshan Chheda — Profile:\n> London-based software engineer."
assert page[1]["text"] == "Darshan Chheda — Availability:\nOpen to software engineering roles in the UK"
assert {chunk["metadata"]["source_type"] for chunk in page} == {"profile"}
def test_each_off_site_profile_is_a_contact_chunk_of_its_own() -> None:
[_, *profiles] = profile_chunks(LLMS_TXT)
assert [(chunks[0]["metadata"]["source_title"], chunks[0]["metadata"]["source_url"], chunks[0]["metadata"]["source_type"]) for chunks, _ in profiles] == [
("GitHub", "https://github.com/1337XCode", "contact"),
("LinkedIn", "https://linkedin.com/in/darshchheda", "contact"),
]
linkedin = profiles[1][0][0]["text"]
assert linkedin.endswith("https://linkedin.com/in/darshchheda")
assert len(linkedin.split()) >= 8