Skip to content

Commit

Permalink
chore: more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravencentric committed Apr 10, 2024
1 parent bd55469 commit 5f2f399
Show file tree
Hide file tree
Showing 13 changed files with 182 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,10 @@ jobs:
with:
name: pyanilist-${{ steps.version.outputs.version }}-${{ matrix.python-version }}-${{ matrix.os }}
path: "dist/*"

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
env_vars: OS,PYTHON
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

.coverage
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@

[![PyPI - Version](https://img.shields.io/pypi/v/pyanilist?link=https%3A%2F%2Fpypi.org%2Fproject%2Fpyanilist%2F)](https://pypi.org/project/pyanilist/)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyanilist)
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/Ravencentric/pyanilist/release.yml)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/ravencentric/pyanilist/test.yml?label=tests)
![License](https://img.shields.io/github/license/Ravencentric/pyanilist)
![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)
![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)

![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/Ravencentric/pyanilist/release.yml)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/ravencentric/pyanilist/test.yml?label=tests)
[![codecov](https://codecov.io/gh/Ravencentric/pyanilist/graph/badge.svg?token=B45ODO7TEY)](https://codecov.io/gh/Ravencentric/pyanilist)

</div>

## Table Of Contents
Expand Down
72 changes: 68 additions & 4 deletions poetry.lock

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

8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ types-boltons = "^23.1.0.20240331"
pytest = "^8.1.1"
pytest-asyncio = "^0.23.5.post1"
pre-commit = "^3.7.0"
coverage = "^7.4.4"

[tool.poetry.group.docs.dependencies]
mkdocs-material = "^9.5.17"
Expand All @@ -62,6 +63,13 @@ pretty = true
[tool.pytest.ini_options]
asyncio_mode = "auto"

[tool.coverage.run]
omit = [
"src/pyanilist/_version.py",
"src/pyanilist/_compat.py",
"tests/*"
]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
4 changes: 2 additions & 2 deletions src/pyanilist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@
Studio,
)
from ._types import AniListID, AniListTitle, AniListYear, Color, CountryCode, HttpUrl, YearsActive
from ._version import VersionInfo, _get_version
from ._version import Version, _get_version

__version__ = _get_version()
__version_tuple__ = VersionInfo(*map(int, __version__.split(".")))
__version_tuple__ = Version(*map(int, __version__.split(".")))

__all__ = [
# Clients
Expand Down
2 changes: 1 addition & 1 deletion src/pyanilist/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ._compat import metadata


class VersionInfo(NamedTuple):
class Version(NamedTuple):
"""Version tuple based on SemVer"""

major: int
Expand Down
37 changes: 37 additions & 0 deletions tests/test_anilist.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def test_anilist_anime() -> None:
media = AniList().search("Attack on titan", type=MediaType.ANIME)
assert media.title.romaji == "Shingeki no Kyojin"
assert media.start_date.year == 2013
assert media.start_date.iso_format() == "2013-04-07"
assert media.end_date.iso_format() == "2013-09-28"
assert media.source is MediaSource.MANGA
assert media.type is MediaType.ANIME
assert [(staff.name.full, staff.role) for staff in media.staff] == [
Expand Down Expand Up @@ -52,6 +54,8 @@ def test_anilist_manga() -> None:
media = AniList().search("Attack on titan", type=MediaType.MANGA)
assert media.title.romaji == "Shingeki no Kyojin"
assert media.start_date.year == 2009
assert media.start_date.iso_format() == "2009-09-09"
assert media.end_date.iso_format() == "2021-04-09"
assert media.source is MediaSource.ORIGINAL
assert media.type is MediaType.MANGA
assert [(staff.name.full, staff.role) for staff in media.staff] == [
Expand All @@ -78,6 +82,8 @@ def test_anilist_with_some_constraints() -> None:
)
assert media.title.romaji == "Violet Evergarden"
assert media.start_date.year == 2015
assert media.start_date.iso_format() == "2015-12-25"
assert media.end_date.iso_format() == "2016-12-26"
assert media.source is MediaSource.ORIGINAL
assert media.type is MediaType.MANGA
assert [(staff.name.full, staff.role) for staff in media.staff] == [
Expand All @@ -98,6 +104,8 @@ def test_anilist_with_all_constraints() -> None:
)
assert media.title.romaji == "Boku no Hero Academia"
assert media.start_date.year == 2016
assert media.start_date.iso_format() == "2016-04-03"
assert media.end_date.iso_format() == "2016-06-26"
assert media.source is MediaSource.MANGA
assert media.type is MediaType.ANIME
assert [(staff.name.full, staff.role) for staff in media.staff] == [
Expand Down Expand Up @@ -136,6 +144,35 @@ def test_anilist_id() -> None:
assert media.start_date.year == 2013
assert media.source is MediaSource.MANGA
assert media.type is MediaType.ANIME
assert media.start_date.iso_format() == "2013-04-07"
assert media.end_date.iso_format() == "2013-09-28"
assert [(staff.name.full, staff.role) for staff in media.staff] == [
("Tetsurou Araki", "Director"),
("Yasuko Kobayashi", "Series Composition"),
("Youko Hikasa", "Theme Song Performance (ED1)"),
("Hiroyuki Sawano", "Music"),
("Hironori Tanaka", "Key Animation (eps 7, 21)"),
("Hajime Isayama", "Original Creator"),
("Mika Kobayashi", "Insert Song Performance"),
("Kyouji Asano", "Character Design"),
("Aimee Blackschleger", "Insert Song Performance"),
("Hiroyuki Tanaka", "Assistant Director"),
("Hiroyuki Tanaka", "Episode Director (eps 1, 10, 18, 21, 24)"),
("Cyua", "Insert Song Performance"),
("Seiichi Nakatani", "Key Animation (ep 25)"),
("Kouichi Arai", "Animation (ED1)"),
("Hiromi Katou", "Key Animation (ep 25)"),
("Mayu Fujimoto", "Key Animation (OP1, ep 1)"),
("Kazuhiro Miwa", "Key Animation (ED2)"),
("Hiroshi Seko", "Script (eps 3, 5-7, 10, 11, 15, 17, 18, 23)"),
("Tomohiro Hirata", "Key Animation (ep 25)"),
("Tomohiro Hirata", "Storyboard (eps 8, 19, 21, 25)"),
("Naoki Kobayashi", "Key Animation (ep 9)"),
("Toshirou Fujii", "Key Animation (ep 9)"),
("Shouko Yasuda", "Key Animation (eps 3, 4, 11, 15)"),
("Daizen Komatsuda", "Storyboard (ep 23)"),
("You Moriyama", "Key Animation (OP1)"),
]
assert media.site_url == HttpUrl("https://anilist.co/anime/16498")


Expand Down
37 changes: 37 additions & 0 deletions tests/test_async_anilist.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ async def test_anilist_anime() -> None:
media = await AsyncAniList().search("Attack on titan", type=MediaType.ANIME)
assert media.title.romaji == "Shingeki no Kyojin"
assert media.start_date.year == 2013
assert media.start_date.iso_format() == "2013-04-07"
assert media.end_date.iso_format() == "2013-09-28"
assert media.source is MediaSource.MANGA
assert media.type is MediaType.ANIME
assert [(staff.name.full, staff.role) for staff in media.staff] == [
Expand Down Expand Up @@ -52,6 +54,8 @@ async def test_anilist_manga() -> None:
media = await AsyncAniList().search("Attack on titan", type=MediaType.MANGA)
assert media.title.romaji == "Shingeki no Kyojin"
assert media.start_date.year == 2009
assert media.start_date.iso_format() == "2009-09-09"
assert media.end_date.iso_format() == "2021-04-09"
assert media.source is MediaSource.ORIGINAL
assert media.type is MediaType.MANGA
assert [(staff.name.full, staff.role) for staff in media.staff] == [
Expand All @@ -78,6 +82,8 @@ async def test_anilist_with_some_constraints() -> None:
)
assert media.title.romaji == "Violet Evergarden"
assert media.start_date.year == 2015
assert media.start_date.iso_format() == "2015-12-25"
assert media.end_date.iso_format() == "2016-12-26"
assert media.source is MediaSource.ORIGINAL
assert media.type is MediaType.MANGA
assert [(staff.name.full, staff.role) for staff in media.staff] == [
Expand All @@ -98,6 +104,8 @@ async def test_anilist_with_all_constraints() -> None:
)
assert media.title.romaji == "Boku no Hero Academia"
assert media.start_date.year == 2016
assert media.start_date.iso_format() == "2016-04-03"
assert media.end_date.iso_format() == "2016-06-26"
assert media.source is MediaSource.MANGA
assert media.type is MediaType.ANIME
assert [(staff.name.full, staff.role) for staff in media.staff] == [
Expand Down Expand Up @@ -136,6 +144,35 @@ async def test_anilist_id() -> None:
assert media.start_date.year == 2013
assert media.source is MediaSource.MANGA
assert media.type is MediaType.ANIME
assert media.start_date.iso_format() == "2013-04-07"
assert media.end_date.iso_format() == "2013-09-28"
assert [(staff.name.full, staff.role) for staff in media.staff] == [
("Tetsurou Araki", "Director"),
("Yasuko Kobayashi", "Series Composition"),
("Youko Hikasa", "Theme Song Performance (ED1)"),
("Hiroyuki Sawano", "Music"),
("Hironori Tanaka", "Key Animation (eps 7, 21)"),
("Hajime Isayama", "Original Creator"),
("Mika Kobayashi", "Insert Song Performance"),
("Kyouji Asano", "Character Design"),
("Aimee Blackschleger", "Insert Song Performance"),
("Hiroyuki Tanaka", "Assistant Director"),
("Hiroyuki Tanaka", "Episode Director (eps 1, 10, 18, 21, 24)"),
("Cyua", "Insert Song Performance"),
("Seiichi Nakatani", "Key Animation (ep 25)"),
("Kouichi Arai", "Animation (ED1)"),
("Hiromi Katou", "Key Animation (ep 25)"),
("Mayu Fujimoto", "Key Animation (OP1, ep 1)"),
("Kazuhiro Miwa", "Key Animation (ED2)"),
("Hiroshi Seko", "Script (eps 3, 5-7, 10, 11, 15, 17, 18, 23)"),
("Tomohiro Hirata", "Key Animation (ep 25)"),
("Tomohiro Hirata", "Storyboard (eps 8, 19, 21, 25)"),
("Naoki Kobayashi", "Key Animation (ep 9)"),
("Toshirou Fujii", "Key Animation (ep 9)"),
("Shouko Yasuda", "Key Animation (eps 3, 4, 11, 15)"),
("Daizen Komatsuda", "Storyboard (ep 23)"),
("You Moriyama", "Key Animation (OP1)"),
]
assert media.site_url == HttpUrl("https://anilist.co/anime/16498")


Expand Down
Loading

0 comments on commit 5f2f399

Please sign in to comment.