File size: 1,758 Bytes
a09abbb
 
 
 
 
 
 
f6b36ec
a09abbb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f6b36ec
 
a09abbb
f6b36ec
 
 
 
 
 
 
 
 
 
 
 
 
a09abbb
f6b36ec
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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