Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions tests/transform_project_url_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import sys
import types
import unittest


sys.modules.setdefault("models", types.SimpleNamespace(JSONResume=object))

from transform import transform_projects


class TransformProjectUrlTests(unittest.TestCase):
def test_uses_github_url_when_url_is_missing(self):
projects = transform_projects(
[
{
"name": "Example",
"description": "Example project",
"github_url": "https://github.com/example/project",
"technologies": ["Python"],
}
]
)

self.assertEqual(projects[0]["url"], "https://github.com/example/project")

def test_uses_live_url_when_url_and_github_url_are_missing(self):
projects = transform_projects(
[
{
"name": "Example",
"description": "Example project",
"live_url": "https://example.com",
"technologies": ["Python"],
}
]
)

self.assertEqual(projects[0]["url"], "https://example.com")

def test_preserves_explicit_url_over_fallbacks(self):
projects = transform_projects(
[
{
"name": "Example",
"url": "https://docs.example.com",
"github_url": "https://github.com/example/project",
"live_url": "https://example.com",
}
]
)

self.assertEqual(projects[0]["url"], "https://docs.example.com")


if __name__ == "__main__":
unittest.main()
4 changes: 3 additions & 1 deletion transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,9 @@ def transform_projects(projects_list: List) -> List[Dict]:
"endDate": None,
"description": item.get("description", ""),
"highlights": [item.get("type", "")] if item.get("type") else [],
"url": item.get("url", None),
"url": item.get("url")
or item.get("github_url")
or item.get("live_url"),
"technologies": technologies,
"skills": skills,
}
Expand Down