Skip to content
Draft
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
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ignore-paths=
# The regex matches against base names, not paths. The default value ignores
# Emacs file locks
ignore-patterns=^\.#
tests/test_**.py

# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
Expand Down
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ sphinx = "*"
sphinx-rtd-theme = "*"
tomlkit = "*"
twine = "*"
pytest = "*"
pytest-asyncio = "*"

[requires]
python_version = "3.11"
148 changes: 82 additions & 66 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ Documentation = "https://gormo.co/pyhatching/"
[tool.setuptools.packages.find]
namespaces = true
where = ["src"]

[tool.pytest.ini_options]
minversion = "7.0"
testpaths = [
"tests",
"integration",
]
asyncio_mode = "auto"
# addopts = "-ra -q"
11 changes: 11 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""pytest suite for pyhatching."""

import os
import pytest


@pytest.fixture
def token():
"""The API token to use while testing."""

return os.environ["HATCHING_TOKEN"]
38 changes: 38 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""Tests pyhatching.PyHatchingClient and some related functions."""


import aiohttp

import pyhatching
import pytest

from . import token


class TestClientInit:
@pytest.mark.asyncio
async def test_ctxmgr(self, token):
async with pyhatching.PyHatchingClient(api_key=token) as client:
await client.close()
assert isinstance(client, pyhatching.PyHatchingClient)

@pytest.mark.asyncio
async def test_factory(self, token):
# NOTE Lets test out all the args, add new ones here when added to factory.
client = await pyhatching.new_client(
api_key=token,
url="http://testurl.local",
timeout=100,
raise_on_api_err=False,
)
await client.close()
assert isinstance(client, pyhatching.PyHatchingClient)

@pytest.mark.asyncio
async def test_init(self, token):
client = pyhatching.PyHatchingClient(api_key=token)
assert isinstance(client, pyhatching.PyHatchingClient)
await client.start()
assert isinstance(client.session, aiohttp.ClientSession)
await client.close()
assert client.session.closed