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
51 changes: 51 additions & 0 deletions tests/transform_github_csv_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import sys
import types
import unittest


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

from transform import transform_evaluation_response


class TransformGitHubCsvTests(unittest.TestCase):
def test_uses_nested_github_profile_data(self):
row = transform_evaluation_response(
github_data={
"profile": {
"public_repos": 12,
"followers": 34,
"following": 5,
"created_at": "2024-01-01T00:00:00Z",
"bio": "Software engineer",
},
"projects": [],
}
)

self.assertEqual(row["github_repos"], 12)
self.assertEqual(row["github_followers"], 34)
self.assertEqual(row["github_following"], 5)
self.assertEqual(row["github_created_at"], "2024-01-01T00:00:00Z")
self.assertEqual(row["github_bio"], "Software engineer")

def test_supports_flat_github_data_for_compatibility(self):
row = transform_evaluation_response(
github_data={
"public_repos": 7,
"followers": 8,
"following": 9,
"created_at": "2025-01-01T00:00:00Z",
"bio": "Builder",
}
)

self.assertEqual(row["github_repos"], 7)
self.assertEqual(row["github_followers"], 8)
self.assertEqual(row["github_following"], 9)
self.assertEqual(row["github_created_at"], "2025-01-01T00:00:00Z")
self.assertEqual(row["github_bio"], "Builder")


if __name__ == "__main__":
unittest.main()
11 changes: 6 additions & 5 deletions transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,11 +657,12 @@ def transform_evaluation_response(

# Extract GitHub data
if github_data:
csv_row["github_repos"] = github_data.get("public_repos", 0)
csv_row["github_followers"] = github_data.get("followers", 0)
csv_row["github_following"] = github_data.get("following", 0)
csv_row["github_created_at"] = github_data.get("created_at", "")
csv_row["github_bio"] = github_data.get("bio", "")
github_profile = github_data.get("profile", github_data)
csv_row["github_repos"] = github_profile.get("public_repos", 0)
csv_row["github_followers"] = github_profile.get("followers", 0)
csv_row["github_following"] = github_profile.get("following", 0)
csv_row["github_created_at"] = github_profile.get("created_at", "")
csv_row["github_bio"] = github_profile.get("bio", "")
else:
csv_row["github_repos"] = 0
csv_row["github_followers"] = 0
Expand Down