-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Imprint schema * Add Imprint methods * Add tests for Imprint endpoints * Update tests for refreshed data * Add `imprint` field to Issue & Series schemas
- Loading branch information
Showing
14 changed files
with
165 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"""Imprint module. | ||
This module provides the following classes: | ||
- Imprint | ||
""" | ||
|
||
from mokkari.schemas.generic import GenericItem | ||
from mokkari.schemas.publisher import Publisher | ||
|
||
|
||
class Imprint(Publisher): | ||
"""A data model representing an imprint that extends Publisher. | ||
Attributes: | ||
publisher (GenericItem): The generic item representing the publisher. | ||
""" | ||
|
||
publisher: GenericItem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
"""Test Imprints module. | ||
This module contains tests for Imprint objects. | ||
""" | ||
|
||
import json | ||
|
||
import pytest | ||
import requests_mock | ||
|
||
from mokkari import exceptions | ||
from mokkari.session import Session | ||
|
||
|
||
def test_known_imprints(talker: Session) -> None: | ||
"""Test for a known publisher.""" | ||
vertigo = talker.imprint(1) | ||
assert vertigo.name == "Vertigo Comics" | ||
assert ( | ||
vertigo.image.__str__() | ||
== "https://static.metron.cloud/media/imprint/2024/08/12/vertigo.jpg" | ||
) | ||
assert vertigo.founded == 1993 | ||
assert vertigo.publisher.name == "DC Comics" | ||
assert ( | ||
vertigo.resource_url.__str__() == "https://metron.cloud/imprint/vertigo-comics/" | ||
) | ||
|
||
|
||
def test_imprint_list(talker: Session) -> None: | ||
"""Test the ImprintList.""" | ||
imprints = talker.imprints_list() | ||
imprints_iter = iter(imprints) | ||
assert next(imprints_iter).name == "DC Black Label" | ||
assert next(imprints_iter).name == "Icon Comics" | ||
assert next(imprints_iter).name == "Vertigo Comics" | ||
assert len(imprints) == 3 | ||
assert imprints[2].name == "Vertigo Comics" | ||
|
||
|
||
def test_bad_imprint(talker: Session) -> None: | ||
"""Test for a non-existent imprint.""" | ||
with requests_mock.Mocker() as r: | ||
r.get( | ||
"https://metron.cloud/api/imprint/-1/", | ||
text='{"response_code": 404, "detail": "Not found."}', | ||
) | ||
with pytest.raises(exceptions.ApiError): | ||
talker.imprint(-1) | ||
|
||
|
||
def test_bad_imprint_validate(talker: Session) -> None: | ||
"""Test data with invalid data.""" | ||
# Change the 'name' field to an int, when it should be a string. | ||
data = { | ||
"id": 15, | ||
"name": 150, | ||
"founded": 1993, | ||
"desc": "Foo Bar", | ||
"image": "https://static.metron.cloud/media/imprint/2018/12/02/bongo.png", | ||
"modified": "2019-06-23T15:13:23.581612-04:00", | ||
} | ||
|
||
with requests_mock.Mocker() as r: | ||
r.get( | ||
"https://metron.cloud/api/imprint/15/", | ||
text=json.dumps(data), | ||
) | ||
|
||
with pytest.raises(exceptions.ApiError): | ||
talker.imprint(15) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.