black, pagination, tests

This commit is contained in:
Tyrel Souza 2021-11-04 22:59:03 -04:00
parent 85b7b1fcb1
commit 360ce1196b
11 changed files with 268 additions and 429 deletions

28
api.py
View File

@ -1,24 +1,40 @@
import httpx
import os
from urllib.parse import urljoin
class API:
headers = {"Accept": "application/vnd.github.v3+json"}
URLBASE = "https://api.github.com" # note: no slash
headers = {
"Accept": "application/vnd.github.v3+json",
"Authorization": f"token {os.environ['GITHUB_TOKEN']}",
}
def raise_on_4xx_5xx(self, response):
response.raise_for_status()
response.raise_for_status()
def get(self, url: str) -> list:
"""Uses httpx.Client().get to send the appropriate github headers, and return the url"""
content = []
with httpx.Client(headers=self.headers, event_hooks={'response': [self.raise_on_4xx_5xx]}) as client:
with httpx.Client(
headers=self.headers, event_hooks={"response": [self.raise_on_4xx_5xx]}
) as client:
return client.get(urljoin(self.URLBASE, url)).json()
def get_with_pagination(self, url: str) -> list:
"""Uses httpx.Client().get to send the appropriate github headers, and return the url"""
content = []
with httpx.Client(
headers=self.headers, event_hooks={"response": [self.raise_on_4xx_5xx]}
) as client:
while True:
resp = client.get(url)
resp = client.get(urljoin(self.URLBASE, url))
body = resp.json()
if isinstance(body, dict):
# short circuit if not list
return body
content.extend(body)
if not resp.links.get('next'):
if not resp.links.get("next"):
break
url = resp.links['next']['url']
url = resp.links["next"]["url"]
return content

View File

@ -3,26 +3,35 @@ import pytest
from api import API
from pytest_httpx import HTTPXMock
LINK1 = '<https://api.github.com/user/6292/repos?page=2>; rel="next", <https://api.github.com/user/6292/repos?page=2>; rel="last"'
LINK2 = '<https://api.github.com/user/6292/repos?page=1>; rel="prev", <https://api.github.com/user/6292/repos?page=2>; rel="last"'
def _load_user():
with open("./tests/fixtures/user.json", "r") as f:
def _load_fixture(name: str):
with open(f"./tests/fixtures/{name}.json", "r") as f:
return json.loads(f.read())
def _load_repos():
with open("./tests/fixtures/repos.json", "r") as f:
return json.loads(f.read())
def test_get(httpx_mock: HTTPXMock):
httpx_mock.add_response(method="GET", json=_load_fixture("user"))
api = API()
assert api.get("users")["login"] == "tyrelsouza"
def test_load_user(httpx_mock: HTTPXMock):
httpx_mock.add_response(method="GET", json=_load_user())
def test_get_with_pagination(httpx_mock: HTTPXMock):
api = API()
# link, so multiple pages
httpx_mock.add_response(
method="GET", json=_load_fixture("repos_1"), headers={"link": LINK1}
)
httpx_mock.add_response(
method="GET", json=_load_fixture("repos_2"), headers={"link": LINK2}
)
gh = API(user_name="tyrelsouza")
assert gh.user["login"] == "tyrelsouza"
repos = api.get_with_pagination("repos")
assert len(repos) == 2
def test_load_repos(httpx_mock: HTTPXMock):
httpx_mock.add_response(method="GET", json=_load_user())
httpx_mock.add_response(method="GET", json=_load_repos())
gh = API(user_name="tyrelsouza")
assert gh.repos[0]["git_url"] == "git://github.com/tyrelsouza/genealogy.git"
# No link, so no 2nd page, only one item
httpx_mock.add_response(method="GET", json=_load_fixture("repos_1"))
repos = api.get_with_pagination("repos")
assert len(repos) == 1

6
cli.py
View File

@ -2,9 +2,12 @@ from ghub import GHub
from rich.prompt import Prompt
from rich import print
import httpx
import os
def main():
if not os.environ.get("GITHUB_TOKEN"):
raise Exception("Please set GITHUB_TOKEN")
user_name = Prompt.ask("Username?")
gh = GHub()
success = gh.load_user(user_name=user_name)
@ -12,8 +15,5 @@ def main():
print(gh.repos_table())
if __name__ == "__main__":
main()

10
ghub.py
View File

@ -9,14 +9,18 @@ class GHub:
user = None
repos = None
def load_user(self, user_name: str) -> None:
def load_user(self, user_name: str) -> bool:
self.user_name = user_name
self.api = API()
try:
self.user = self.api.get(f"https://api.github.com/users/{user_name}")
self.repos = self.api.get(f"https://api.github.com/users/{user_name}/repos")
self.user = self.api.get(f"/users/{user_name}")
self.repos = self.api.get_with_pagination(
f"https://api.github.com/users/{user_name}/repos"
)
return True
except httpx.HTTPStatusError as e:
print(e)
return False
def repos_trimmed(self) -> list:
for repo in self.repos:

View File

@ -2,14 +2,17 @@ import json
import pytest
from ghub import GHub
def _load_user():
with open("./tests/fixtures/user.json", "r") as f:
return json.loads(f.read())
def _load_repos():
with open("./tests/fixtures/repos.json", "r") as f:
with open("./tests/fixtures/repos_1.json", "r") as f:
return json.loads(f.read())
def _fake_tyrel() -> GHub:
gh = GHub()
gh.user = _load_user()

View File

@ -4,4 +4,5 @@ black
invoke
pytest
pytest-httpx
pytest-cov
rich

View File

@ -22,6 +22,8 @@ colorama==0.4.4
# via rich
commonmark==0.9.1
# via rich
coverage[toml]==6.1.1
# via pytest-cov
h11==0.12.0
# via httpcore
httpcore==0.13.7
@ -61,7 +63,10 @@ pyparsing==2.4.7
pytest==6.2.5
# via
# -r requirements.in
# pytest-cov
# pytest-httpx
pytest-cov==3.0.0
# via -r requirements.in
pytest-httpx==0.14.0
# via -r requirements.in
regex==2021.11.2
@ -80,6 +85,7 @@ toml==0.10.2
tomli==1.2.2
# via
# black
# coverage
# pep517
typing-extensions==3.10.0.2
# via black

View File

@ -9,7 +9,7 @@ def run(c):
@task
def test(c):
c.run("pytest *_tests.py")
c.run("pytest --cov=. *_tests.py")
@task

View File

@ -1,400 +0,0 @@
[
{
"id": 416199052,
"node_id": "R_kgDOGM6xjA",
"name": "genealogy",
"full_name": "tyrelsouza/genealogy",
"private": false,
"owner": {
"login": "tyrelsouza",
"id": 923113,
"node_id": "MDQ6VXNlcjkyMzExMw==",
"avatar_url": "https://avatars.githubusercontent.com/u/923113?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/tyrelsouza",
"html_url": "https://github.com/tyrelsouza",
"followers_url": "https://api.github.com/users/tyrelsouza/followers",
"following_url": "https://api.github.com/users/tyrelsouza/following{/other_user}",
"gists_url": "https://api.github.com/users/tyrelsouza/gists{/gist_id}",
"starred_url": "https://api.github.com/users/tyrelsouza/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/tyrelsouza/subscriptions",
"organizations_url": "https://api.github.com/users/tyrelsouza/orgs",
"repos_url": "https://api.github.com/users/tyrelsouza/repos",
"events_url": "https://api.github.com/users/tyrelsouza/events{/privacy}",
"received_events_url": "https://api.github.com/users/tyrelsouza/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/tyrelsouza/genealogy",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/tyrelsouza/genealogy",
"forks_url": "https://api.github.com/repos/tyrelsouza/genealogy/forks",
"keys_url": "https://api.github.com/repos/tyrelsouza/genealogy/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/tyrelsouza/genealogy/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/tyrelsouza/genealogy/teams",
"hooks_url": "https://api.github.com/repos/tyrelsouza/genealogy/hooks",
"issue_events_url": "https://api.github.com/repos/tyrelsouza/genealogy/issues/events{/number}",
"events_url": "https://api.github.com/repos/tyrelsouza/genealogy/events",
"assignees_url": "https://api.github.com/repos/tyrelsouza/genealogy/assignees{/user}",
"branches_url": "https://api.github.com/repos/tyrelsouza/genealogy/branches{/branch}",
"tags_url": "https://api.github.com/repos/tyrelsouza/genealogy/tags",
"blobs_url": "https://api.github.com/repos/tyrelsouza/genealogy/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/tyrelsouza/genealogy/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/tyrelsouza/genealogy/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/tyrelsouza/genealogy/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/tyrelsouza/genealogy/statuses/{sha}",
"languages_url": "https://api.github.com/repos/tyrelsouza/genealogy/languages",
"stargazers_url": "https://api.github.com/repos/tyrelsouza/genealogy/stargazers",
"contributors_url": "https://api.github.com/repos/tyrelsouza/genealogy/contributors",
"subscribers_url": "https://api.github.com/repos/tyrelsouza/genealogy/subscribers",
"subscription_url": "https://api.github.com/repos/tyrelsouza/genealogy/subscription",
"commits_url": "https://api.github.com/repos/tyrelsouza/genealogy/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/tyrelsouza/genealogy/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/tyrelsouza/genealogy/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/tyrelsouza/genealogy/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/tyrelsouza/genealogy/contents/{+path}",
"compare_url": "https://api.github.com/repos/tyrelsouza/genealogy/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/tyrelsouza/genealogy/merges",
"archive_url": "https://api.github.com/repos/tyrelsouza/genealogy/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/tyrelsouza/genealogy/downloads",
"issues_url": "https://api.github.com/repos/tyrelsouza/genealogy/issues{/number}",
"pulls_url": "https://api.github.com/repos/tyrelsouza/genealogy/pulls{/number}",
"milestones_url": "https://api.github.com/repos/tyrelsouza/genealogy/milestones{/number}",
"notifications_url": "https://api.github.com/repos/tyrelsouza/genealogy/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/tyrelsouza/genealogy/labels{/name}",
"releases_url": "https://api.github.com/repos/tyrelsouza/genealogy/releases{/id}",
"deployments_url": "https://api.github.com/repos/tyrelsouza/genealogy/deployments",
"created_at": "2021-10-12T05:38:27Z",
"updated_at": "2021-10-12T05:38:32Z",
"pushed_at": "2021-10-12T05:38:29Z",
"git_url": "git://github.com/tyrelsouza/genealogy.git",
"ssh_url": "git@github.com:tyrelsouza/genealogy.git",
"clone_url": "https://github.com/tyrelsouza/genealogy.git",
"svn_url": "https://github.com/tyrelsouza/genealogy",
"homepage": null,
"size": 67,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"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,
"allow_forking": true,
"is_template": false,
"topics": [],
"visibility": "public",
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master"
},
{
"id": 353575397,
"node_id": "MDEwOlJlcG9zaXRvcnkzNTM1NzUzOTc=",
"name": "proglog",
"full_name": "tyrelsouza/proglog",
"private": false,
"owner": {
"login": "tyrelsouza",
"id": 923113,
"node_id": "MDQ6VXNlcjkyMzExMw==",
"avatar_url": "https://avatars.githubusercontent.com/u/923113?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/tyrelsouza",
"html_url": "https://github.com/tyrelsouza",
"followers_url": "https://api.github.com/users/tyrelsouza/followers",
"following_url": "https://api.github.com/users/tyrelsouza/following{/other_user}",
"gists_url": "https://api.github.com/users/tyrelsouza/gists{/gist_id}",
"starred_url": "https://api.github.com/users/tyrelsouza/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/tyrelsouza/subscriptions",
"organizations_url": "https://api.github.com/users/tyrelsouza/orgs",
"repos_url": "https://api.github.com/users/tyrelsouza/repos",
"events_url": "https://api.github.com/users/tyrelsouza/events{/privacy}",
"received_events_url": "https://api.github.com/users/tyrelsouza/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/tyrelsouza/proglog",
"description": "Following Distributed Services with Go book",
"fork": false,
"url": "https://api.github.com/repos/tyrelsouza/proglog",
"forks_url": "https://api.github.com/repos/tyrelsouza/proglog/forks",
"keys_url": "https://api.github.com/repos/tyrelsouza/proglog/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/tyrelsouza/proglog/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/tyrelsouza/proglog/teams",
"hooks_url": "https://api.github.com/repos/tyrelsouza/proglog/hooks",
"issue_events_url": "https://api.github.com/repos/tyrelsouza/proglog/issues/events{/number}",
"events_url": "https://api.github.com/repos/tyrelsouza/proglog/events",
"assignees_url": "https://api.github.com/repos/tyrelsouza/proglog/assignees{/user}",
"branches_url": "https://api.github.com/repos/tyrelsouza/proglog/branches{/branch}",
"tags_url": "https://api.github.com/repos/tyrelsouza/proglog/tags",
"blobs_url": "https://api.github.com/repos/tyrelsouza/proglog/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/tyrelsouza/proglog/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/tyrelsouza/proglog/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/tyrelsouza/proglog/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/tyrelsouza/proglog/statuses/{sha}",
"languages_url": "https://api.github.com/repos/tyrelsouza/proglog/languages",
"stargazers_url": "https://api.github.com/repos/tyrelsouza/proglog/stargazers",
"contributors_url": "https://api.github.com/repos/tyrelsouza/proglog/contributors",
"subscribers_url": "https://api.github.com/repos/tyrelsouza/proglog/subscribers",
"subscription_url": "https://api.github.com/repos/tyrelsouza/proglog/subscription",
"commits_url": "https://api.github.com/repos/tyrelsouza/proglog/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/tyrelsouza/proglog/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/tyrelsouza/proglog/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/tyrelsouza/proglog/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/tyrelsouza/proglog/contents/{+path}",
"compare_url": "https://api.github.com/repos/tyrelsouza/proglog/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/tyrelsouza/proglog/merges",
"archive_url": "https://api.github.com/repos/tyrelsouza/proglog/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/tyrelsouza/proglog/downloads",
"issues_url": "https://api.github.com/repos/tyrelsouza/proglog/issues{/number}",
"pulls_url": "https://api.github.com/repos/tyrelsouza/proglog/pulls{/number}",
"milestones_url": "https://api.github.com/repos/tyrelsouza/proglog/milestones{/number}",
"notifications_url": "https://api.github.com/repos/tyrelsouza/proglog/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/tyrelsouza/proglog/labels{/name}",
"releases_url": "https://api.github.com/repos/tyrelsouza/proglog/releases{/id}",
"deployments_url": "https://api.github.com/repos/tyrelsouza/proglog/deployments",
"created_at": "2021-04-01T04:42:22Z",
"updated_at": "2021-04-10T04:17:56Z",
"pushed_at": "2021-04-10T04:17:54Z",
"git_url": "git://github.com/tyrelsouza/proglog.git",
"ssh_url": "git@github.com:tyrelsouza/proglog.git",
"clone_url": "https://github.com/tyrelsouza/proglog.git",
"svn_url": "https://github.com/tyrelsouza/proglog",
"homepage": null,
"size": 8,
"stargazers_count": 0,
"watchers_count": 0,
"language": "Go",
"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,
"allow_forking": true,
"is_template": false,
"topics": [],
"visibility": "public",
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "main"
},
{
"id": 415131409,
"node_id": "R_kgDOGL5nEQ",
"name": "tyrel-intellij-demo",
"full_name": "tyrelsouza/tyrel-intellij-demo",
"private": false,
"owner": {
"login": "tyrelsouza",
"id": 923113,
"node_id": "MDQ6VXNlcjkyMzExMw==",
"avatar_url": "https://avatars.githubusercontent.com/u/923113?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/tyrelsouza",
"html_url": "https://github.com/tyrelsouza",
"followers_url": "https://api.github.com/users/tyrelsouza/followers",
"following_url": "https://api.github.com/users/tyrelsouza/following{/other_user}",
"gists_url": "https://api.github.com/users/tyrelsouza/gists{/gist_id}",
"starred_url": "https://api.github.com/users/tyrelsouza/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/tyrelsouza/subscriptions",
"organizations_url": "https://api.github.com/users/tyrelsouza/orgs",
"repos_url": "https://api.github.com/users/tyrelsouza/repos",
"events_url": "https://api.github.com/users/tyrelsouza/events{/privacy}",
"received_events_url": "https://api.github.com/users/tyrelsouza/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/tyrelsouza/tyrel-intellij-demo",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo",
"forks_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/forks",
"keys_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/teams",
"hooks_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/hooks",
"issue_events_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/issues/events{/number}",
"events_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/events",
"assignees_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/assignees{/user}",
"branches_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/branches{/branch}",
"tags_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/tags",
"blobs_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/statuses/{sha}",
"languages_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/languages",
"stargazers_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/stargazers",
"contributors_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/contributors",
"subscribers_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/subscribers",
"subscription_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/subscription",
"commits_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/contents/{+path}",
"compare_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/merges",
"archive_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/downloads",
"issues_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/issues{/number}",
"pulls_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/pulls{/number}",
"milestones_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/milestones{/number}",
"notifications_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/labels{/name}",
"releases_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/releases{/id}",
"deployments_url": "https://api.github.com/repos/tyrelsouza/tyrel-intellij-demo/deployments",
"created_at": "2021-10-08T21:28:08Z",
"updated_at": "2021-10-08T21:30:01Z",
"pushed_at": "2021-10-08T21:29:58Z",
"git_url": "git://github.com/tyrelsouza/tyrel-intellij-demo.git",
"ssh_url": "git@github.com:tyrelsouza/tyrel-intellij-demo.git",
"clone_url": "https://github.com/tyrelsouza/tyrel-intellij-demo.git",
"svn_url": "https://github.com/tyrelsouza/tyrel-intellij-demo",
"homepage": null,
"size": 104,
"stargazers_count": 0,
"watchers_count": 0,
"language": "Java",
"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,
"allow_forking": true,
"is_template": false,
"topics": [],
"visibility": "public",
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "main"
},
{
"id": 228900091,
"node_id": "MDEwOlJlcG9zaXRvcnkyMjg5MDAwOTE=",
"name": "work_sample",
"full_name": "tyrelsouza/work_sample",
"private": false,
"owner": {
"login": "tyrelsouza",
"id": 923113,
"node_id": "MDQ6VXNlcjkyMzExMw==",
"avatar_url": "https://avatars.githubusercontent.com/u/923113?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/tyrelsouza",
"html_url": "https://github.com/tyrelsouza",
"followers_url": "https://api.github.com/users/tyrelsouza/followers",
"following_url": "https://api.github.com/users/tyrelsouza/following{/other_user}",
"gists_url": "https://api.github.com/users/tyrelsouza/gists{/gist_id}",
"starred_url": "https://api.github.com/users/tyrelsouza/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/tyrelsouza/subscriptions",
"organizations_url": "https://api.github.com/users/tyrelsouza/orgs",
"repos_url": "https://api.github.com/users/tyrelsouza/repos",
"events_url": "https://api.github.com/users/tyrelsouza/events{/privacy}",
"received_events_url": "https://api.github.com/users/tyrelsouza/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/tyrelsouza/work_sample",
"description": "i need a public repo for work.",
"fork": false,
"url": "https://api.github.com/repos/tyrelsouza/work_sample",
"forks_url": "https://api.github.com/repos/tyrelsouza/work_sample/forks",
"keys_url": "https://api.github.com/repos/tyrelsouza/work_sample/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/tyrelsouza/work_sample/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/tyrelsouza/work_sample/teams",
"hooks_url": "https://api.github.com/repos/tyrelsouza/work_sample/hooks",
"issue_events_url": "https://api.github.com/repos/tyrelsouza/work_sample/issues/events{/number}",
"events_url": "https://api.github.com/repos/tyrelsouza/work_sample/events",
"assignees_url": "https://api.github.com/repos/tyrelsouza/work_sample/assignees{/user}",
"branches_url": "https://api.github.com/repos/tyrelsouza/work_sample/branches{/branch}",
"tags_url": "https://api.github.com/repos/tyrelsouza/work_sample/tags",
"blobs_url": "https://api.github.com/repos/tyrelsouza/work_sample/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/tyrelsouza/work_sample/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/tyrelsouza/work_sample/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/tyrelsouza/work_sample/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/tyrelsouza/work_sample/statuses/{sha}",
"languages_url": "https://api.github.com/repos/tyrelsouza/work_sample/languages",
"stargazers_url": "https://api.github.com/repos/tyrelsouza/work_sample/stargazers",
"contributors_url": "https://api.github.com/repos/tyrelsouza/work_sample/contributors",
"subscribers_url": "https://api.github.com/repos/tyrelsouza/work_sample/subscribers",
"subscription_url": "https://api.github.com/repos/tyrelsouza/work_sample/subscription",
"commits_url": "https://api.github.com/repos/tyrelsouza/work_sample/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/tyrelsouza/work_sample/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/tyrelsouza/work_sample/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/tyrelsouza/work_sample/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/tyrelsouza/work_sample/contents/{+path}",
"compare_url": "https://api.github.com/repos/tyrelsouza/work_sample/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/tyrelsouza/work_sample/merges",
"archive_url": "https://api.github.com/repos/tyrelsouza/work_sample/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/tyrelsouza/work_sample/downloads",
"issues_url": "https://api.github.com/repos/tyrelsouza/work_sample/issues{/number}",
"pulls_url": "https://api.github.com/repos/tyrelsouza/work_sample/pulls{/number}",
"milestones_url": "https://api.github.com/repos/tyrelsouza/work_sample/milestones{/number}",
"notifications_url": "https://api.github.com/repos/tyrelsouza/work_sample/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/tyrelsouza/work_sample/labels{/name}",
"releases_url": "https://api.github.com/repos/tyrelsouza/work_sample/releases{/id}",
"deployments_url": "https://api.github.com/repos/tyrelsouza/work_sample/deployments",
"created_at": "2019-12-18T18:36:33Z",
"updated_at": "2019-12-18T18:37:38Z",
"pushed_at": "2019-12-18T18:37:36Z",
"git_url": "git://github.com/tyrelsouza/work_sample.git",
"ssh_url": "git@github.com:tyrelsouza/work_sample.git",
"clone_url": "https://github.com/tyrelsouza/work_sample.git",
"svn_url": "https://github.com/tyrelsouza/work_sample",
"homepage": null,
"size": 3,
"stargazers_count": 0,
"watchers_count": 0,
"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": 1,
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
},
"allow_forking": true,
"is_template": false,
"topics": [],
"visibility": "public",
"forks": 0,
"open_issues": 1,
"watchers": 0,
"default_branch": "master"
}
]

100
tests/fixtures/repos_1.json vendored Normal file
View File

@ -0,0 +1,100 @@
[
{
"id": 416199052,
"node_id": "R_kgDOGM6xjA",
"name": "genealogy",
"full_name": "tyrelsouza/genealogy",
"private": false,
"owner": {
"login": "tyrelsouza",
"id": 923113,
"node_id": "MDQ6VXNlcjkyMzExMw==",
"avatar_url": "https://avatars.githubusercontent.com/u/923113?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/tyrelsouza",
"html_url": "https://github.com/tyrelsouza",
"followers_url": "https://api.github.com/users/tyrelsouza/followers",
"following_url": "https://api.github.com/users/tyrelsouza/following{/other_user}",
"gists_url": "https://api.github.com/users/tyrelsouza/gists{/gist_id}",
"starred_url": "https://api.github.com/users/tyrelsouza/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/tyrelsouza/subscriptions",
"organizations_url": "https://api.github.com/users/tyrelsouza/orgs",
"repos_url": "https://api.github.com/users/tyrelsouza/repos",
"events_url": "https://api.github.com/users/tyrelsouza/events{/privacy}",
"received_events_url": "https://api.github.com/users/tyrelsouza/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/tyrelsouza/genealogy",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/tyrelsouza/genealogy",
"forks_url": "https://api.github.com/repos/tyrelsouza/genealogy/forks",
"keys_url": "https://api.github.com/repos/tyrelsouza/genealogy/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/tyrelsouza/genealogy/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/tyrelsouza/genealogy/teams",
"hooks_url": "https://api.github.com/repos/tyrelsouza/genealogy/hooks",
"issue_events_url": "https://api.github.com/repos/tyrelsouza/genealogy/issues/events{/number}",
"events_url": "https://api.github.com/repos/tyrelsouza/genealogy/events",
"assignees_url": "https://api.github.com/repos/tyrelsouza/genealogy/assignees{/user}",
"branches_url": "https://api.github.com/repos/tyrelsouza/genealogy/branches{/branch}",
"tags_url": "https://api.github.com/repos/tyrelsouza/genealogy/tags",
"blobs_url": "https://api.github.com/repos/tyrelsouza/genealogy/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/tyrelsouza/genealogy/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/tyrelsouza/genealogy/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/tyrelsouza/genealogy/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/tyrelsouza/genealogy/statuses/{sha}",
"languages_url": "https://api.github.com/repos/tyrelsouza/genealogy/languages",
"stargazers_url": "https://api.github.com/repos/tyrelsouza/genealogy/stargazers",
"contributors_url": "https://api.github.com/repos/tyrelsouza/genealogy/contributors",
"subscribers_url": "https://api.github.com/repos/tyrelsouza/genealogy/subscribers",
"subscription_url": "https://api.github.com/repos/tyrelsouza/genealogy/subscription",
"commits_url": "https://api.github.com/repos/tyrelsouza/genealogy/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/tyrelsouza/genealogy/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/tyrelsouza/genealogy/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/tyrelsouza/genealogy/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/tyrelsouza/genealogy/contents/{+path}",
"compare_url": "https://api.github.com/repos/tyrelsouza/genealogy/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/tyrelsouza/genealogy/merges",
"archive_url": "https://api.github.com/repos/tyrelsouza/genealogy/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/tyrelsouza/genealogy/downloads",
"issues_url": "https://api.github.com/repos/tyrelsouza/genealogy/issues{/number}",
"pulls_url": "https://api.github.com/repos/tyrelsouza/genealogy/pulls{/number}",
"milestones_url": "https://api.github.com/repos/tyrelsouza/genealogy/milestones{/number}",
"notifications_url": "https://api.github.com/repos/tyrelsouza/genealogy/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/tyrelsouza/genealogy/labels{/name}",
"releases_url": "https://api.github.com/repos/tyrelsouza/genealogy/releases{/id}",
"deployments_url": "https://api.github.com/repos/tyrelsouza/genealogy/deployments",
"created_at": "2021-10-12T05:38:27Z",
"updated_at": "2021-10-12T05:38:32Z",
"pushed_at": "2021-10-12T05:38:29Z",
"git_url": "git://github.com/tyrelsouza/genealogy.git",
"ssh_url": "git@github.com:tyrelsouza/genealogy.git",
"clone_url": "https://github.com/tyrelsouza/genealogy.git",
"svn_url": "https://github.com/tyrelsouza/genealogy",
"homepage": null,
"size": 67,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"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,
"allow_forking": true,
"is_template": false,
"topics": [],
"visibility": "public",
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master"
}
]

100
tests/fixtures/repos_2.json vendored Normal file
View File

@ -0,0 +1,100 @@
[
{
"id": 353575397,
"node_id": "MDEwOlJlcG9zaXRvcnkzNTM1NzUzOTc=",
"name": "proglog",
"full_name": "tyrelsouza/proglog",
"private": false,
"owner": {
"login": "tyrelsouza",
"id": 923113,
"node_id": "MDQ6VXNlcjkyMzExMw==",
"avatar_url": "https://avatars.githubusercontent.com/u/923113?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/tyrelsouza",
"html_url": "https://github.com/tyrelsouza",
"followers_url": "https://api.github.com/users/tyrelsouza/followers",
"following_url": "https://api.github.com/users/tyrelsouza/following{/other_user}",
"gists_url": "https://api.github.com/users/tyrelsouza/gists{/gist_id}",
"starred_url": "https://api.github.com/users/tyrelsouza/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/tyrelsouza/subscriptions",
"organizations_url": "https://api.github.com/users/tyrelsouza/orgs",
"repos_url": "https://api.github.com/users/tyrelsouza/repos",
"events_url": "https://api.github.com/users/tyrelsouza/events{/privacy}",
"received_events_url": "https://api.github.com/users/tyrelsouza/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/tyrelsouza/proglog",
"description": "Following Distributed Services with Go book",
"fork": false,
"url": "https://api.github.com/repos/tyrelsouza/proglog",
"forks_url": "https://api.github.com/repos/tyrelsouza/proglog/forks",
"keys_url": "https://api.github.com/repos/tyrelsouza/proglog/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/tyrelsouza/proglog/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/tyrelsouza/proglog/teams",
"hooks_url": "https://api.github.com/repos/tyrelsouza/proglog/hooks",
"issue_events_url": "https://api.github.com/repos/tyrelsouza/proglog/issues/events{/number}",
"events_url": "https://api.github.com/repos/tyrelsouza/proglog/events",
"assignees_url": "https://api.github.com/repos/tyrelsouza/proglog/assignees{/user}",
"branches_url": "https://api.github.com/repos/tyrelsouza/proglog/branches{/branch}",
"tags_url": "https://api.github.com/repos/tyrelsouza/proglog/tags",
"blobs_url": "https://api.github.com/repos/tyrelsouza/proglog/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/tyrelsouza/proglog/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/tyrelsouza/proglog/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/tyrelsouza/proglog/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/tyrelsouza/proglog/statuses/{sha}",
"languages_url": "https://api.github.com/repos/tyrelsouza/proglog/languages",
"stargazers_url": "https://api.github.com/repos/tyrelsouza/proglog/stargazers",
"contributors_url": "https://api.github.com/repos/tyrelsouza/proglog/contributors",
"subscribers_url": "https://api.github.com/repos/tyrelsouza/proglog/subscribers",
"subscription_url": "https://api.github.com/repos/tyrelsouza/proglog/subscription",
"commits_url": "https://api.github.com/repos/tyrelsouza/proglog/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/tyrelsouza/proglog/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/tyrelsouza/proglog/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/tyrelsouza/proglog/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/tyrelsouza/proglog/contents/{+path}",
"compare_url": "https://api.github.com/repos/tyrelsouza/proglog/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/tyrelsouza/proglog/merges",
"archive_url": "https://api.github.com/repos/tyrelsouza/proglog/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/tyrelsouza/proglog/downloads",
"issues_url": "https://api.github.com/repos/tyrelsouza/proglog/issues{/number}",
"pulls_url": "https://api.github.com/repos/tyrelsouza/proglog/pulls{/number}",
"milestones_url": "https://api.github.com/repos/tyrelsouza/proglog/milestones{/number}",
"notifications_url": "https://api.github.com/repos/tyrelsouza/proglog/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/tyrelsouza/proglog/labels{/name}",
"releases_url": "https://api.github.com/repos/tyrelsouza/proglog/releases{/id}",
"deployments_url": "https://api.github.com/repos/tyrelsouza/proglog/deployments",
"created_at": "2021-04-01T04:42:22Z",
"updated_at": "2021-04-10T04:17:56Z",
"pushed_at": "2021-04-10T04:17:54Z",
"git_url": "git://github.com/tyrelsouza/proglog.git",
"ssh_url": "git@github.com:tyrelsouza/proglog.git",
"clone_url": "https://github.com/tyrelsouza/proglog.git",
"svn_url": "https://github.com/tyrelsouza/proglog",
"homepage": null,
"size": 8,
"stargazers_count": 0,
"watchers_count": 0,
"language": "Go",
"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,
"allow_forking": true,
"is_template": false,
"topics": [],
"visibility": "public",
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "main"
}
]