-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
github-to-sqlite starred' command, closes #1
- Loading branch information
Showing
7 changed files
with
333 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
[ | ||
{ | ||
"starred_at": "2019-09-14T08:35:12Z", | ||
"repo": { | ||
"id": 123, | ||
"node_id": "MDEwOlJlcG9zaccbcckyMDgzNjkxNTM=", | ||
"name": "repo-name", | ||
"full_name": "owner-name/repo-name", | ||
"private": false, | ||
"owner": { | ||
"login": "owner-name", | ||
"id": 456, | ||
"node_id": "OANEUTHEUONTH=", | ||
"avatar_url": "https://avatars2.githubusercontent.com/u/456?v=4", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/owner-name", | ||
"html_url": "https://github.com/owner-name", | ||
"followers_url": "https://api.github.com/users/owner-name/followers", | ||
"following_url": "https://api.github.com/users/owner-name/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/owner-name/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/owner-name/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/owner-name/subscriptions", | ||
"organizations_url": "https://api.github.com/users/owner-name/orgs", | ||
"repos_url": "https://api.github.com/users/owner-name/repos", | ||
"events_url": "https://api.github.com/users/owner-name/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/owner-name/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
}, | ||
"html_url": "https://github.com/owner-name/repo-name", | ||
"description": "Repo description", | ||
"fork": false, | ||
"url": "https://api.github.com/repos/owner-name/repo-name", | ||
"forks_url": "https://api.github.com/repos/owner-name/repo-name/forks", | ||
"keys_url": "https://api.github.com/repos/owner-name/repo-name/keys{/key_id}", | ||
"collaborators_url": "https://api.github.com/repos/owner-name/repo-name/collaborators{/collaborator}", | ||
"teams_url": "https://api.github.com/repos/owner-name/repo-name/teams", | ||
"hooks_url": "https://api.github.com/repos/owner-name/repo-name/hooks", | ||
"issue_events_url": "https://api.github.com/repos/owner-name/repo-name/issues/events{/number}", | ||
"events_url": "https://api.github.com/repos/owner-name/repo-name/events", | ||
"assignees_url": "https://api.github.com/repos/owner-name/repo-name/assignees{/user}", | ||
"branches_url": "https://api.github.com/repos/owner-name/repo-name/branches{/branch}", | ||
"tags_url": "https://api.github.com/repos/owner-name/repo-name/tags", | ||
"blobs_url": "https://api.github.com/repos/owner-name/repo-name/git/blobs{/sha}", | ||
"git_tags_url": "https://api.github.com/repos/owner-name/repo-name/git/tags{/sha}", | ||
"git_refs_url": "https://api.github.com/repos/owner-name/repo-name/git/refs{/sha}", | ||
"trees_url": "https://api.github.com/repos/owner-name/repo-name/git/trees{/sha}", | ||
"statuses_url": "https://api.github.com/repos/owner-name/repo-name/statuses/{sha}", | ||
"languages_url": "https://api.github.com/repos/owner-name/repo-name/languages", | ||
"stargazers_url": "https://api.github.com/repos/owner-name/repo-name/stargazers", | ||
"contributors_url": "https://api.github.com/repos/owner-name/repo-name/contributors", | ||
"subscribers_url": "https://api.github.com/repos/owner-name/repo-name/subscribers", | ||
"subscription_url": "https://api.github.com/repos/owner-name/repo-name/subscription", | ||
"commits_url": "https://api.github.com/repos/owner-name/repo-name/commits{/sha}", | ||
"git_commits_url": "https://api.github.com/repos/owner-name/repo-name/git/commits{/sha}", | ||
"comments_url": "https://api.github.com/repos/owner-name/repo-name/comments{/number}", | ||
"issue_comment_url": "https://api.github.com/repos/owner-name/repo-name/issues/comments{/number}", | ||
"contents_url": "https://api.github.com/repos/owner-name/repo-name/contents/{+path}", | ||
"compare_url": "https://api.github.com/repos/owner-name/repo-name/compare/{base}...{head}", | ||
"merges_url": "https://api.github.com/repos/owner-name/repo-name/merges", | ||
"archive_url": "https://api.github.com/repos/owner-name/repo-name/{archive_format}{/ref}", | ||
"downloads_url": "https://api.github.com/repos/owner-name/repo-name/downloads", | ||
"issues_url": "https://api.github.com/repos/owner-name/repo-name/issues{/number}", | ||
"pulls_url": "https://api.github.com/repos/owner-name/repo-name/pulls{/number}", | ||
"milestones_url": "https://api.github.com/repos/owner-name/repo-name/milestones{/number}", | ||
"notifications_url": "https://api.github.com/repos/owner-name/repo-name/notifications{?since,all,participating}", | ||
"labels_url": "https://api.github.com/repos/owner-name/repo-name/labels{/name}", | ||
"releases_url": "https://api.github.com/repos/owner-name/repo-name/releases{/id}", | ||
"deployments_url": "https://api.github.com/repos/owner-name/repo-name/deployments", | ||
"created_at": "2019-09-14T00:50:14Z", | ||
"updated_at": "2019-09-14T14:28:32Z", | ||
"pushed_at": "2019-09-14T07:02:40Z", | ||
"git_url": "git://github.com/owner-name/repo-name.git", | ||
"ssh_url": "[email protected]:owner-name/repo-name.git", | ||
"clone_url": "https://github.com/owner-name/repo-name.git", | ||
"svn_url": "https://github.com/owner-name/repo-name", | ||
"homepage": null, | ||
"size": 7, | ||
"stargazers_count": 2, | ||
"watchers_count": 2, | ||
"language": "Python", | ||
"has_issues": true, | ||
"has_projects": true, | ||
"has_downloads": true, | ||
"has_wiki": true, | ||
"has_pages": false, | ||
"forks_count": 0, | ||
"mirror_url": null, | ||
"archived": false, | ||
"disabled": false, | ||
"open_issues_count": 0, | ||
"license": null, | ||
"forks": 0, | ||
"open_issues": 0, | ||
"watchers": 2, | ||
"default_branch": "master" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from github_to_sqlite import utils | ||
import json | ||
import pathlib | ||
import pytest | ||
import sqlite_utils | ||
|
||
|
||
@pytest.fixture | ||
def starred(): | ||
return json.load(open(pathlib.Path(__file__).parent / "starred.json")) | ||
|
||
|
||
@pytest.fixture | ||
def user(): | ||
return json.load(open(pathlib.Path(__file__).parent / "user.json")) | ||
|
||
|
||
@pytest.fixture | ||
def db(starred, user): | ||
db = sqlite_utils.Database(memory=True) | ||
utils.save_stars(db, user, starred) | ||
return db | ||
|
||
|
||
def test_tables(db): | ||
assert {"repos", "stars", "users"} == set(db.table_names()) | ||
|
||
|
||
def test_repos(db): | ||
repos = list(db["repos"].rows) | ||
assert [ | ||
{ | ||
"id": 123, | ||
"node_id": "MDEwOlJlcG9zaccbcckyMDgzNjkxNTM=", | ||
"name": "repo-name", | ||
"full_name": "owner-name/repo-name", | ||
"private": 0, | ||
"owner": 456, | ||
"html_url": "https://github.com/owner-name/repo-name", | ||
"description": "Repo description", | ||
"fork": 0, | ||
"created_at": "2019-09-14T00:50:14Z", | ||
"updated_at": "2019-09-14T14:28:32Z", | ||
"pushed_at": "2019-09-14T07:02:40Z", | ||
"homepage": None, | ||
"size": 7, | ||
"stargazers_count": 2, | ||
"watchers_count": 2, | ||
"language": "Python", | ||
"has_issues": 1, | ||
"has_projects": 1, | ||
"has_downloads": 1, | ||
"has_wiki": 1, | ||
"has_pages": 0, | ||
"forks_count": 0, | ||
"archived": 0, | ||
"disabled": 0, | ||
"open_issues_count": 0, | ||
"license": None, | ||
"forks": 0, | ||
"open_issues": 0, | ||
"watchers": 2, | ||
"default_branch": "master", | ||
} | ||
] == repos | ||
|
||
|
||
def test_stars(db): | ||
stars = list(db["stars"].rows) | ||
assert [{"user": 9599, "repo": 123, "starred_at": "2019-09-14T08:35:12Z"}] == stars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"login": "simonw", | ||
"id": 9599, | ||
"node_id": "MDQ6VXNlcjk1OTk=", | ||
"avatar_url": "https://avatars0.githubusercontent.com/u/9599?v=4", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/simonw", | ||
"html_url": "https://github.com/simonw", | ||
"followers_url": "https://api.github.com/users/simonw/followers", | ||
"following_url": "https://api.github.com/users/simonw/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/simonw/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/simonw/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/simonw/subscriptions", | ||
"organizations_url": "https://api.github.com/users/simonw/orgs", | ||
"repos_url": "https://api.github.com/users/simonw/repos", | ||
"events_url": "https://api.github.com/users/simonw/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/simonw/received_events", | ||
"type": "User", | ||
"site_admin": false, | ||
"name": "Simon Willison", | ||
"company": "-", | ||
"blog": "https://simonwillison.net/", | ||
"location": "San Francisco, CA", | ||
"email": null, | ||
"hireable": null, | ||
"bio": null, | ||
"public_repos": 218, | ||
"public_gists": 191, | ||
"followers": 1269, | ||
"following": 129, | ||
"created_at": "2008-05-07T17:22:14Z", | ||
"updated_at": "2019-09-09T02:43:29Z" | ||
} |