Skip to content
Closed
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
4 changes: 2 additions & 2 deletions src/tcgdexsdk/endpoints/Endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self,
self.endpoint = endpoint

async def get(self, id: str) -> Optional[Item]:
return fetch(self.tcgdex, f"https://api.tcgdex.net/v2/{self.tcgdex.language}/{self.endpoint}/{id.replace(' ', '%20')}", self.item_model)
return fetch(self.tcgdex, f"{self.tcgdex.URI}/{self.tcgdex.language}/{self.endpoint}/{id.replace(' ', '%20')}", self.item_model)

async def list(self, query: Optional[Query] = None) -> List[ListModel]:
return fetch_list(self.tcgdex, f"https://api.tcgdex.net/v2/{self.tcgdex.language}/{self.endpoint}", self.list_model)
return fetch_list(self.tcgdex, f"{self.tcgdex.URI}/{self.tcgdex.language}/{self.endpoint}", self.list_model)
12 changes: 11 additions & 1 deletion tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from unittest.mock import patch
from typing import Callable

import vcr
Expand All @@ -21,6 +22,16 @@ class APITest(unittest.IsolatedAsyncioTestCase):
def setUp(self):
self.api = TCGdex(Language.EN)

@patch("tcgdexsdk.endpoints.Endpoint.fetch")
@patch("tcgdexsdk.endpoints.Endpoint.fetch_list")
async def test_uri(self, mock_fetch_list, mock_fetch):
api = TCGdex(Language.EN)
api.URI = "http://localhost:3000/v2"
await api.card.get("swsh1-136")
mock_fetch.assert_called_once_with(api, "http://localhost:3000/v2/en/cards/swsh1-136", Card)
await api.card.list()
mock_fetch_list.assert_called_once_with(api, "http://localhost:3000/v2/en/cards", CardResume)

@_use_cassette
async def test_fr(self):
tcg = TCGdex(Language.FR)
Expand All @@ -30,7 +41,6 @@ async def test_fr(self):
res = await tcg2.card.get('swsh3-136')
self.assertEqual(res.name, 'Fouinar')


@_use_cassette
async def test_card_resume(self):
res = await self.api.card.list()
Expand Down