This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

at main 2.3 kB View raw
1from __future__ import annotations 2 3from app.config import Settings 4from app.recommend import _issue_out, _repo_out, _seed_url_map 5from app.types import Candidate 6 7 8def _settings() -> Settings: 9 return Settings(db_connection_string="", web_base="https://tangled.org") 10 11 12def test_seed_url_map_builds_absolute_urls(): 13 seeds = [ 14 {"repo_did": "did:plc:a", "repo_name": "nixpkgs", "owner_handle": "nixos"}, 15 {"repo_did": "did:plc:b", "repo_name": "cli", "owner_handle": "me"}, 16 ] 17 urls = _seed_url_map(seeds, _settings()) 18 assert urls["nixpkgs"] == "https://tangled.org/@nixos/nixpkgs" 19 assert urls["cli"] == "https://tangled.org/@me/cli" 20 21 22def test_repo_out_includes_recommended_and_seed_urls(): 23 c = Candidate( 24 key="did:plc:target", 25 content_hash="h", 26 distance=0.1, 27 seeds=["my-cli"], 28 primary_seed="my-cli", 29 payload={ 30 "owner_handle": "them", 31 "repo_name": "cool-repo", 32 "description": "desc", 33 "created_at": "2026-01-01T00:00:00Z", 34 }, 35 ) 36 out = _repo_out(c, _settings(), {}, {"my-cli": "https://tangled.org/@me/my-cli"}) 37 assert out.url == "https://tangled.org/@them/cool-repo" 38 assert out.basedOnRepoUrl == "https://tangled.org/@me/my-cli" 39 40 41def test_issue_out_includes_parent_and_seed_urls(): 42 c = Candidate( 43 key="at://did/issue/1", 44 content_hash="h", 45 distance=0.2, 46 seeds=["dotfiles"], 47 primary_seed="dotfiles", 48 payload={ 49 "uri": "at://did:plc:them/sh.tangled.repo.issue/abc", 50 "owner_handle": "them", 51 "repo_name": "proj", 52 "title": "Fix bug", 53 "repo_did": "did:plc:target", 54 "rkey": "abc", 55 "repo_readme": "# Proj", 56 "created_at": "2026-01-01T00:00:00Z", 57 }, 58 ) 59 out = _issue_out( 60 c, 61 _settings(), 62 {"dotfiles": "https://tangled.org/@me/dotfiles"}, 63 {"at://did:plc:them/sh.tangled.repo.issue/abc"}, 64 ) 65 assert out.issueUri == "at://did:plc:them/sh.tangled.repo.issue/abc" 66 assert out.url == "https://tangled.org/@them/proj" 67 assert out.basedOnRepoUrl == "https://tangled.org/@me/dotfiles" 68 assert out.repoReadme == "# Proj" 69 assert out.hasQuestionnaire is True