Revert "chore: ci fixups and poetry update"

This reverts commit d0b986025e.
This commit is contained in:
Andrew Herrington
2024-05-05 13:02:14 -05:00
parent d0b986025e
commit 4ca01eaf0c
24 changed files with 1026 additions and 829 deletions

View File

@@ -15,7 +15,9 @@ from healthchecks_io.client.exceptions import HCAPIError
@pytest.mark.asyncio
@pytest.mark.respx
async def test_acreate_check_200_context_manager(fake_check_api_result, respx_mock, test_async_client):
async def test_acreate_check_200_context_manager(
fake_check_api_result, respx_mock, test_async_client
):
checks_url = urljoin(test_async_client._api_url, "checks/")
respx_mock.post(checks_url).mock(
return_value=Response(
@@ -41,7 +43,9 @@ async def test_acreate_check_200_context_manager(fake_check_api_result, respx_mo
)
)
async with test_async_client as test_client:
check = await test_client.create_check(CheckCreate(name="test", tags="test", desc="test"))
check = await test_client.create_check(
CheckCreate(name="test", tags="test", desc="test")
)
assert check.name == "Backups"
@@ -72,7 +76,9 @@ async def test_acreate_check_200(fake_check_api_result, respx_mock, test_async_c
},
)
)
check = await test_async_client.create_check(CheckCreate(name="test", tags="test", desc="test"))
check = await test_async_client.create_check(
CheckCreate(name="test", tags="test", desc="test")
)
assert check.name == "Backups"
@@ -103,7 +109,9 @@ async def test_aupdate_check_200(fake_check_api_result, respx_mock, test_async_c
},
)
)
check = await test_async_client.update_check("test", CheckUpdate(name="test", desc="test"))
check = await test_async_client.update_check(
"test", CheckUpdate(name="test", desc="test")
)
assert check.name == "Backups"
@@ -112,7 +120,9 @@ async def test_aupdate_check_200(fake_check_api_result, respx_mock, test_async_c
async def test_aget_checks_200(fake_check_api_result, respx_mock, test_async_client):
assert test_async_client._client is not None
checks_url = urljoin(test_async_client._api_url, "checks/")
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json={"checks": [fake_check_api_result]}))
respx_mock.get(checks_url).mock(
return_value=Response(status_code=200, json={"checks": [fake_check_api_result]})
)
checks = await test_async_client.get_checks()
assert len(checks) == 1
assert checks[0].name == fake_check_api_result["name"]
@@ -122,9 +132,13 @@ async def test_aget_checks_200(fake_check_api_result, respx_mock, test_async_cli
@pytest.mark.respx
async def test_aget_checks_pass_in_client(fake_check_api_result, respx_mock):
httpx_client = HTTPXAsyncClient()
test_async_client = AsyncClient(api_key="test", api_url="http://localhost/api/", client=httpx_client)
test_async_client = AsyncClient(
api_key="test", api_url="http://localhost/api/", client=httpx_client
)
checks_url = urljoin(test_async_client._api_url, "checks/")
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json={"checks": [fake_check_api_result]}))
respx_mock.get(checks_url).mock(
return_value=Response(status_code=200, json={"checks": [fake_check_api_result]})
)
checks = await test_async_client.get_checks()
assert len(checks) == 1
assert checks[0].name == fake_check_api_result["name"]
@@ -132,7 +146,9 @@ async def test_aget_checks_pass_in_client(fake_check_api_result, respx_mock):
@pytest.mark.asyncio
@pytest.mark.respx
async def test_aget_checks_exceptions(fake_check_api_result, respx_mock, test_async_client):
async def test_aget_checks_exceptions(
fake_check_api_result, respx_mock, test_async_client
):
checks_url = urljoin(test_async_client._api_url, "checks/")
# test exceptions
respx_mock.get(checks_url).mock(return_value=Response(status_code=401))
@@ -170,7 +186,9 @@ def test_finalizer_closes(test_async_client):
async def test_aget_check_200(fake_check_api_result, respx_mock, test_async_client):
assert test_async_client._client is not None
checks_url = urljoin(test_async_client._api_url, "checks/test")
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json=fake_check_api_result))
respx_mock.get(checks_url).mock(
return_value=Response(status_code=200, json=fake_check_api_result)
)
check = await test_async_client.get_check(check_id="test")
assert check.name == fake_check_api_result["name"]
@@ -189,7 +207,9 @@ async def test_acheck_get_404(respx_mock, test_async_client):
@pytest.mark.respx
async def test_pause_check_200(fake_check_api_result, respx_mock, test_async_client):
checks_url = urljoin(test_async_client._api_url, "checks/test/pause")
respx_mock.post(checks_url).mock(return_value=Response(status_code=200, json=fake_check_api_result))
respx_mock.post(checks_url).mock(
return_value=Response(status_code=200, json=fake_check_api_result)
)
check = await test_async_client.pause_check(check_id="test")
assert check.name == fake_check_api_result["name"]
@@ -209,7 +229,9 @@ async def test_acheck_pause_404(respx_mock, test_async_client):
async def test_adelete_check_200(fake_check_api_result, respx_mock, test_async_client):
assert test_async_client._client is not None
checks_url = urljoin(test_async_client._api_url, "checks/test")
respx_mock.delete(checks_url).mock(return_value=Response(status_code=200, json=fake_check_api_result))
respx_mock.delete(checks_url).mock(
return_value=Response(status_code=200, json=fake_check_api_result)
)
check = await test_async_client.delete_check(check_id="test")
assert check.name == fake_check_api_result["name"]
@@ -225,9 +247,15 @@ async def test_adelete_pause404(respx_mock, test_async_client):
@pytest.mark.asyncio
@pytest.mark.respx
async def test_aget_check_pings_200(fake_check_pings_api_result, respx_mock, test_async_client):
async def test_aget_check_pings_200(
fake_check_pings_api_result, respx_mock, test_async_client
):
checks_url = urljoin(test_async_client._api_url, "checks/test/pings/")
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json={"pings": fake_check_pings_api_result}))
respx_mock.get(checks_url).mock(
return_value=Response(
status_code=200, json={"pings": fake_check_pings_api_result}
)
)
pings = await test_async_client.get_check_pings("test")
assert len(pings) == len(fake_check_pings_api_result)
assert pings[0].type == fake_check_pings_api_result[0]["type"]
@@ -235,9 +263,13 @@ async def test_aget_check_pings_200(fake_check_pings_api_result, respx_mock, tes
@pytest.mark.asyncio
@pytest.mark.respx
async def test_aget_check_flips_200(fake_check_flips_api_result, respx_mock, test_async_client):
async def test_aget_check_flips_200(
fake_check_flips_api_result, respx_mock, test_async_client
):
checks_url = urljoin(test_async_client._api_url, "checks/test/flips/")
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json=fake_check_flips_api_result))
respx_mock.get(checks_url).mock(
return_value=Response(status_code=200, json=fake_check_flips_api_result)
)
flips = await test_async_client.get_check_flips("test")
assert len(flips) == len(fake_check_flips_api_result)
assert flips[0].up == fake_check_flips_api_result[0]["up"]
@@ -245,9 +277,15 @@ async def test_aget_check_flips_200(fake_check_flips_api_result, respx_mock, tes
@pytest.mark.asyncio
@pytest.mark.respx
async def test_get_check_flips_params_200(fake_check_flips_api_result, respx_mock, test_async_client):
checks_url = urljoin(test_async_client._api_url, "checks/test/flips/?seconds=1&start=1&end=1")
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json=fake_check_flips_api_result))
async def test_get_check_flips_params_200(
fake_check_flips_api_result, respx_mock, test_async_client
):
checks_url = urljoin(
test_async_client._api_url, "checks/test/flips/?seconds=1&start=1&end=1"
)
respx_mock.get(checks_url).mock(
return_value=Response(status_code=200, json=fake_check_flips_api_result)
)
flips = await test_async_client.get_check_flips("test", seconds=1, start=1, end=1)
assert len(flips) == len(fake_check_flips_api_result)
assert flips[0].up == fake_check_flips_api_result[0]["up"]
@@ -255,7 +293,9 @@ async def test_get_check_flips_params_200(fake_check_flips_api_result, respx_moc
@pytest.mark.asyncio
@pytest.mark.respx
async def test_aget_check_flips_400(fake_check_flips_api_result, respx_mock, test_async_client):
async def test_aget_check_flips_400(
fake_check_flips_api_result, respx_mock, test_async_client
):
flips_url = urljoin(test_async_client._api_url, "checks/test/flips/")
respx_mock.get(flips_url).mock(return_value=Response(status_code=400))
with pytest.raises(BadAPIRequestError):
@@ -264,9 +304,13 @@ async def test_aget_check_flips_400(fake_check_flips_api_result, respx_mock, tes
@pytest.mark.asyncio
@pytest.mark.respx
async def test_aget_integrations(fake_integrations_api_result, respx_mock, test_async_client):
async def test_aget_integrations(
fake_integrations_api_result, respx_mock, test_async_client
):
channels_url = urljoin(test_async_client._api_url, "channels/")
respx_mock.get(channels_url).mock(return_value=Response(status_code=200, json=fake_integrations_api_result))
respx_mock.get(channels_url).mock(
return_value=Response(status_code=200, json=fake_integrations_api_result)
)
integrations = await test_async_client.get_integrations()
assert len(integrations) == len(fake_integrations_api_result["channels"])
assert integrations[0].id == fake_integrations_api_result["channels"][0]["id"]
@@ -276,7 +320,9 @@ async def test_aget_integrations(fake_integrations_api_result, respx_mock, test_
@pytest.mark.respx
async def test_aget_badges(fake_badges_api_result, respx_mock, test_async_client):
channels_url = urljoin(test_async_client._api_url, "badges/")
respx_mock.get(channels_url).mock(return_value=Response(status_code=200, json=fake_badges_api_result))
respx_mock.get(channels_url).mock(
return_value=Response(status_code=200, json=fake_badges_api_result)
)
integrations = await test_async_client.get_badges()
assert integrations.keys() == fake_badges_api_result["badges"].keys()
@@ -343,10 +389,14 @@ ping_test_parameters = [
@pytest.mark.asyncio
@pytest.mark.respx
@pytest.mark.parametrize("respx_mocker, tc, url, ping_method, method_kwargs", ping_test_parameters)
@pytest.mark.parametrize(
"respx_mocker, tc, url, ping_method, method_kwargs", ping_test_parameters
)
async def test_asuccess_ping(respx_mocker, tc, url, ping_method, method_kwargs):
channels_url = urljoin(tc._ping_url, url)
respx_mocker.post(channels_url).mock(return_value=Response(status_code=200, text="OK"))
respx_mocker.post(channels_url).mock(
return_value=Response(status_code=200, text="OK")
)
ping_method = getattr(tc, ping_method)
result = await ping_method(**method_kwargs)
assert result[0] is True