Skip to content

Commit

Permalink
test: fixup test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
ahal committed Oct 22, 2023
1 parent 289b4da commit 1d9d509
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
9 changes: 5 additions & 4 deletions test/test_auth.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import time
from unittest import mock

import jwt
import pytest
from unittest import mock

from simple_github.auth import AppAuth, AppInstallationAuth, TokenAuth
from simple_github.client import GITHUB_API_ENDPOINT


@pytest.mark.asyncio
Expand Down Expand Up @@ -45,12 +46,12 @@ async def test_app_installation_auth_get_token(aioresponses, privkey):
auth = AppInstallationAuth(app=AppAuth(app_id, privkey), owner=owner)

aioresponses.get(
"/app/installations",
f"{GITHUB_API_ENDPOINT}/app/installations",
status=200,
payload=[{"id": inst_id, "account": {"login": owner}}],
)
aioresponses.post(
f"/app/installations/{inst_id}/access_tokens",
f"{GITHUB_API_ENDPOINT}/app/installations/{inst_id}/access_tokens",
status=200,
payload={"token": "111"},
)
Expand All @@ -62,7 +63,7 @@ async def test_app_installation_auth_get_token(aioresponses, privkey):

# Unless it will expire in under a minute
aioresponses.post(
f"/app/installations/{inst_id}/access_tokens",
f"{GITHUB_API_ENDPOINT}/app/installations/{inst_id}/access_tokens",
status=200,
payload={"token": "222"},
)
Expand Down
17 changes: 12 additions & 5 deletions test/test_simple_github.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import pytest

from simple_github import AppClient, TokenClient
from simple_github.client import GITHUB_API_ENDPOINT


@pytest.mark.asyncio
async def test_token_client(aioresponses):
aioresponses.get("/octocat", status=200, payload={"foo": "bar"})
aioresponses.get(
f"{GITHUB_API_ENDPOINT}/octocat", status=200, payload={"foo": "bar"}
)

async with TokenClient("abc") as client:
result = await client.get("/octocat")
Expand All @@ -14,7 +17,9 @@ async def test_token_client(aioresponses):

@pytest.mark.asyncio
async def test_app_client(aioresponses, privkey):
aioresponses.get("/octocat", status=200, payload={"foo": "bar"})
aioresponses.get(
f"{GITHUB_API_ENDPOINT}/octocat", status=200, payload={"foo": "bar"}
)

async with AppClient(id=123, privkey=privkey) as client:
result = await client.get("/octocat")
Expand All @@ -27,16 +32,18 @@ async def test_app_installation_client(aioresponses, privkey):
inst_id = 1

aioresponses.get(
"/app/installations",
f"{GITHUB_API_ENDPOINT}/app/installations",
status=200,
payload=[{"id": inst_id, "account": {"login": owner}}],
)
aioresponses.post(
f"/app/installations/{inst_id}/access_tokens",
f"{GITHUB_API_ENDPOINT}/app/installations/{inst_id}/access_tokens",
status=200,
payload={"token": "789"},
)
aioresponses.get("/octocat", status=200, payload={"foo": "bar"})
aioresponses.get(
f"{GITHUB_API_ENDPOINT}/octocat", status=200, payload={"foo": "bar"}
)

async with AppClient(id=123, privkey=privkey, owner=owner) as client:
result = await client.get("/octocat")
Expand Down

0 comments on commit 1d9d509

Please sign in to comment.