from datetime import UTC, datetime from aiatlas.connectors.labs.microsoft_research import FEED, MicrosoftResearchConnector, is_publication, paper_entity from aiatlas.registry import org_ref from aiatlas.sdk.extract.feeds import FeedItem from aiatlas.sdk.facts import Facts, Target from tests.conftest import extract_from_fixture, fixture_path async def test_feed(): facts = await extract_from_fixture(MicrosoftResearchConnector(), Target(url=FEED, doc_type="feed", key="feed"), fixture_path("microsoft_research", "feed.xml"), content_type="application/rss+xml") assert len(facts.events) == 10 first = facts.events[0] assert first.summary.startswith("Microsoft: GigaPath-Flash and GigaTIME-Flash") and first.effective_at.date().isoformat() == "2026-08-31" assert first.meta["categories"] == ["Research Blog"] and first.entity.name == "Microsoft" assert not [e for e in facts.entities if e.entity_type == "paper"] # research-blog items are events, not publications assert len([t for t in facts.targets if t.doc_type == "news"]) == 10 def test_publication_detection(): blog = FeedItem(id="1", url="https://www.microsoft.com/en-us/research/blog/x/", title="X", summary=None, published_at=None, updated_at=None, categories=["Research Blog"]) pub = FeedItem(id="2", url="https://www.microsoft.com/en-us/research/publication/y/", title="Y paper", summary="Abstract.", published_at=datetime(2026, 9, 1, tzinfo=UTC), updated_at=None, authors=["A. One, B. Two and C. Three"], categories=["Publication"]) assert not is_publication(blog) and is_publication(pub) facts = Facts() paper = paper_entity(facts, org_ref("microsoft"), pub) assert paper.entity_type == "paper" and paper.identifiers == {"url": pub.url} claims = {c.property: c.value for c in facts.claims} assert claims["authors"] == ["A. One", "B. Two", "C. Three"] and claims["published_at"] == "2026-09-01" assert facts.relations[0].predicate == "published_by"