-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8baa9f1
commit 2323816
Showing
9 changed files
with
661 additions
and
1 deletion.
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,36 @@ | ||
# .coveragerc to control coverage.py | ||
[run] | ||
branch = True | ||
source = comicgeeks | ||
omit = | ||
extract.py | ||
__init__.py | ||
__version__.py | ||
|
||
[paths] | ||
source = | ||
src/ | ||
*/site-packages/ | ||
|
||
[report] | ||
omit = | ||
src/comicgeeks/extract.py | ||
src/comicgeeks/__init__.py | ||
src/comicgeeks/__version__.py | ||
# Regexes for lines to exclude from consideration | ||
exclude_lines = | ||
# Have to re-enable the standard pragma | ||
pragma: no cover | ||
|
||
# Don't complain about missing debug-only code: | ||
def __repr__ | ||
if self\.debug | ||
|
||
# Don't complain if tests don't hit defensive assertion code: | ||
raise AssertionError | ||
raise NotImplementedError | ||
|
||
# Don't complain if non-runnable code isn't run: | ||
if 0: | ||
if __name__ == .__main__.: | ||
self._get_data() |
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,10 @@ | ||
""" | ||
Dummy conftest.py for pyscaffold_template. | ||
If you don't know what this is for, just leave it empty. | ||
Read more about conftest.py under: | ||
- https://docs.pytest.org/en/stable/fixture.html | ||
- https://docs.pytest.org/en/stable/writing_plugins.html | ||
""" | ||
|
||
# import pytest |
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,60 @@ | ||
import pytest | ||
from comicgeeks import Comic_Geeks | ||
from dotenv import dotenv_values | ||
from pathlib import Path | ||
|
||
dotenv_path = Path(".devdata.env") | ||
env = dotenv_values(dotenv_path=dotenv_path) | ||
|
||
__author__ = "Pablo Ruiz" | ||
__copyright__ = "Pablo Ruiz" | ||
__license__ = "GPL-3.0-only" | ||
|
||
|
||
def test_search_character(): | ||
"""Search character by name test""" | ||
client = Comic_Geeks() | ||
data = client.search_character("daredevil") | ||
assert len(data) > 1 | ||
assert any(map(lambda x: x.name == "Daredevil", data)) | ||
assert any(map(lambda x: x.real_name == "Elektra Natchios", data)) | ||
assert any(map(lambda x: x.character_id == 11699, data)) | ||
|
||
|
||
def test_search_character_error(): | ||
"""Search character that doesn't exist test""" | ||
client = Comic_Geeks() | ||
data = client.search_character("testing error") | ||
assert len(data) == 0 | ||
|
||
|
||
def test_get_character_by_id(): | ||
"""Get character by id test""" | ||
client = Comic_Geeks() | ||
data = client.character_info(11699).json() | ||
assert len(data["creators"]) > 0 | ||
assert data["description"] != "" | ||
assert len(data["series"]) > 0 | ||
assert data["image"] != "#" | ||
assert data["universe"] == "Earth-616" | ||
assert data["publisher"] == "Marvel Comics" | ||
assert data["name"] == "Daredevil" | ||
assert data["real_name"] == "Elektra Natchios" | ||
assert data["url"] == "/character/11699/daredevil" | ||
assert data["issue_count"] >= 37 | ||
assert len(data["also_known_as"]) == 0 | ||
assert data["owned"] is None | ||
assert data["read"] is None | ||
assert len(data["information"]) > 0 | ||
|
||
|
||
def test_get_character_by_id_session(): | ||
"""Get character by id test""" | ||
client = Comic_Geeks(env["CI_SESSION"]) | ||
data = client.character_info(11699) | ||
assert data.owned is not None | ||
assert data.read is not None | ||
|
||
|
||
## TODO: character without creator credits | ||
## TODO: character without aka |
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,38 @@ | ||
import pytest | ||
from comicgeeks import Comic_Geeks | ||
|
||
__author__ = "Pablo Ruiz" | ||
__copyright__ = "Pablo Ruiz" | ||
__license__ = "GPL-3.0-only" | ||
|
||
|
||
def test_search_creator(): | ||
"""Search creator by name test""" | ||
client = Comic_Geeks() | ||
data = client.search_creator("Chip") | ||
assert len(data) > 1 | ||
assert any(map(lambda x: x.name == "Chip Zdarsky", data)) | ||
assert any(map(lambda x: x.creator_id == 6209, data)) | ||
|
||
|
||
def test_search_creator_error(): | ||
"""Search creator that doesn't exist test""" | ||
client = Comic_Geeks() | ||
data = client.search_creator("testing error") | ||
assert len(data) == 0 | ||
|
||
|
||
def test_get_creator_by_id(): | ||
"""Get creator by id test""" | ||
client = Comic_Geeks() | ||
data = client.creator_info(6209) | ||
assert len(data.characters) > 0 | ||
assert len(data.series) > 0 | ||
assert data.creator_id == 6209 | ||
assert data.name == "Chip Zdarsky" | ||
assert data.description != "" | ||
assert data.image != "#" | ||
assert data.url == "/people/6209/chip-zdarsky" | ||
assert data.read is None | ||
assert data.owned is None | ||
assert data.issue_count >= 378 |
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,230 @@ | ||
import pytest | ||
from comicgeeks import Comic_Geeks | ||
from dotenv import dotenv_values | ||
from pathlib import Path | ||
|
||
dotenv_path = Path(".devdata.env") | ||
env = dotenv_values(dotenv_path=dotenv_path) | ||
|
||
__author__ = "Pablo Ruiz" | ||
__copyright__ = "Pablo Ruiz" | ||
__license__ = "GPL-3.0-only" | ||
|
||
|
||
def test_get_issue_by_id(): | ||
"""Get issue by id test""" | ||
# Also test .json() function | ||
client = Comic_Geeks() | ||
data = client.issue_info(3616996).json() | ||
assert data["issue_id"] == 3616996 | ||
assert len(data["characters"]) > 0 | ||
cover = data["cover"] | ||
assert cover["name"] == "Daredevil #8" and cover["image"] != "#" | ||
community = data["community"] | ||
assert ( | ||
( | ||
community["pull"] >= 1 | ||
if type(community["pull"]) is int | ||
else community["pull"] == "Unknown" | ||
) | ||
and ( | ||
community["collect"] >= 1 | ||
if type(community["collect"]) is int | ||
else community["collect"] == "Unknown" | ||
) | ||
and ( | ||
community["readlist"] >= 1 | ||
if type(community["readlist"]) is int | ||
else community["readlist"] == "Unknown" | ||
) | ||
and ( | ||
community["wishlist"] >= 1 | ||
if type(community["wishlist"]) is int | ||
else community["wishlist"] == "Unknown" | ||
) | ||
and ( | ||
community["rating"] >= 1 | ||
if type(community["rating"]) is int | ||
else community["rating"] == "Unknown" | ||
) | ||
) | ||
assert data["description"] != "" | ||
assert data["details"] == { | ||
"format": "comic", | ||
"page_count": "28 pages", | ||
"upc": "75960609142300811", | ||
"distributor_sku": "may190864", | ||
} | ||
assert data["name"] == "No Devils, Only God, Part 3" | ||
assert data["number"] == "8" | ||
assert len(data["person_credits"]) > 0 | ||
assert data["price"] == 3.99 | ||
assert data["publisher"] == "Marvel Comics" | ||
pagination = data["series_pagination"] | ||
assert all( | ||
map( | ||
lambda x: pagination[x] is not None, | ||
pagination.keys(), | ||
) | ||
) | ||
assert data["store_date"] == 1563314400 | ||
assert data["url"] == "/comic/3616996/daredevil-8" | ||
assert len(data["variant_covers"]) >= 2 | ||
user = data["user"] | ||
assert all(map(lambda x: user[x] is None, user.keys())) | ||
|
||
|
||
def test_get_issue_by_id_session(): | ||
"""Get issue by id test""" | ||
client = Comic_Geeks(env["CI_SESSION"]) | ||
data = client.issue_info(3616996) | ||
assert any(map(lambda x: data.user[x] is not None, data.user.keys())) | ||
|
||
|
||
def test_get_issue_without_characters(): | ||
"""Get issue without characters credits test""" | ||
client = Comic_Geeks() | ||
data = client.issue_info(3943557) | ||
assert len(data.characters) == 0 | ||
|
||
|
||
def test_get_issue_without_variant_covers(): | ||
"""Get issue without variant covers test""" | ||
client = Comic_Geeks() | ||
data = client.issue_info(7757146) | ||
assert len(data.variant_covers) == 0 | ||
|
||
|
||
## TODO: issue without creator credits | ||
|
||
def test_add_to_collection_error(): | ||
client = Comic_Geeks() | ||
issue = client.issue_info(7757146) | ||
data = issue.add_to_collection() | ||
assert data["type"] == "error" | ||
|
||
|
||
def test_add_to_wishlist_error(): | ||
client = Comic_Geeks() | ||
issue = client.issue_info(7757146) | ||
data = issue.add_to_wishlist() | ||
assert data["type"] == "error" | ||
|
||
|
||
def test_mark_read_error(): | ||
client = Comic_Geeks() | ||
issue = client.issue_info(7757146) | ||
data = issue.mark_read() | ||
assert data["type"] == "error" | ||
|
||
|
||
def test_pull_error(): | ||
client = Comic_Geeks() | ||
issue = client.issue_info(7757146) | ||
data = issue.pull() | ||
assert data["type"] == "error" | ||
|
||
|
||
def test_rate_error(): | ||
client = Comic_Geeks() | ||
issue = client.issue_info(7757146) | ||
data = issue.rate(4) | ||
assert data["type"] == "error" | ||
|
||
|
||
def test_remove_collection_error(): | ||
client = Comic_Geeks() | ||
issue = client.issue_info(7757146) | ||
data = issue.remove_from_collection() | ||
assert data["type"] == "error" | ||
|
||
|
||
def test_remove_readlist_error(): | ||
client = Comic_Geeks() | ||
issue = client.issue_info(7757146) | ||
data = issue.remove_from_readlist() | ||
assert data["type"] == "error" | ||
|
||
|
||
def test_remove_wishlist_error(): | ||
client = Comic_Geeks() | ||
issue = client.issue_info(7757146) | ||
data = issue.remove_from_wishlist() | ||
assert data["type"] == "error" | ||
|
||
|
||
def test_unsubscribe_error(): | ||
client = Comic_Geeks() | ||
issue = client.issue_info(7757146) | ||
data = issue.unsubscribe() | ||
assert data["type"] == "error" | ||
|
||
|
||
def test_add_to_collection(): | ||
client = Comic_Geeks(env["CI_SESSION"]) | ||
issue = client.issue_info(7757146) | ||
data = issue.add_to_collection() | ||
assert data["type"] == "success" | ||
|
||
|
||
def test_add_to_wishlist(): | ||
client = Comic_Geeks(env["CI_SESSION"]) | ||
issue = client.issue_info(7757146) | ||
data = issue.add_to_wishlist() | ||
assert data["type"] == "success" | ||
|
||
|
||
def test_mark_read(): | ||
client = Comic_Geeks(env["CI_SESSION"]) | ||
issue = client.issue_info(7757146) | ||
data = issue.mark_read() | ||
assert data["type"] == "success" | ||
|
||
|
||
def test_pull(): | ||
client = Comic_Geeks(env["CI_SESSION"]) | ||
issue = client.issue_info(7757146) | ||
data = issue.pull() | ||
assert data["type"] == "success" | ||
|
||
|
||
def test_rate(): | ||
client = Comic_Geeks(env["CI_SESSION"]) | ||
issue = client.issue_info(7757146) | ||
data = issue.rate(0) | ||
assert data["type"] == "success" | ||
|
||
|
||
def test_rate_invalid_error(): | ||
client = Comic_Geeks(env["CI_SESSION"]) | ||
issue = client.issue_info(7757146) | ||
data = issue.rate(20) | ||
assert data["type"] == "error" | ||
|
||
|
||
def test_remove_collection(): | ||
client = Comic_Geeks(env["CI_SESSION"]) | ||
issue = client.issue_info(7757146) | ||
data = issue.remove_from_collection() | ||
assert data["type"] == "success" | ||
|
||
|
||
def test_remove_readlist(): | ||
client = Comic_Geeks(env["CI_SESSION"]) | ||
issue = client.issue_info(7757146) | ||
data = issue.remove_from_readlist() | ||
assert data["type"] == "success" | ||
|
||
|
||
def test_remove_wishlist(): | ||
client = Comic_Geeks(env["CI_SESSION"]) | ||
issue = client.issue_info(7757146) | ||
data = issue.remove_from_wishlist() | ||
assert data["type"] == "success" | ||
|
||
|
||
def test_unsubscribe(): | ||
client = Comic_Geeks(env["CI_SESSION"]) | ||
issue = client.issue_info(7757146) | ||
data = issue.unsubscribe() | ||
assert data["type"] == "success" |
Oops, something went wrong.