11import unittest
22from typing import Callable
33from unittest .mock import patch
4- from warnings import deprecated
54import vcr
65
76from tcgdexsdk import Language , TCGdex
1413from tcgdexsdk .models .StringEndpoint import StringEndpoint
1514from tcgdexsdk .query import Query
1615
16+
1717def _use_cassette (test : Callable ) -> Callable :
1818 return vcr .use_cassette (f"tests/.fixtures/{ test .__name__ } .yaml" )(test )
1919
2020
2121class APITest (unittest .IsolatedAsyncioTestCase ):
2222 def setUp (self ):
2323 self .api = TCGdex (Language .EN )
24-
25-
26- @deprecated ("this test is deprecated" )
24+
2725 @patch ("tcgdexsdk.endpoints.Endpoint.fetch" )
2826 @patch ("tcgdexsdk.endpoints.Endpoint.fetch_list" )
2927 async def test_uri (self , mock_fetch_list , mock_fetch ):
3028 api = TCGdex (Language .EN )
31-
29+
3230 api .URI = "http://localhost:3000/v2"
33-
31+
3432 await api .card .get ("swsh1-136" )
3533 mock_fetch .assert_called_once_with (api , "http://localhost:3000/v2/en/cards/swsh1-136" , Card )
36-
34+
3735 await api .card .list ()
3836 mock_fetch_list .assert_called_once_with (api , "http://localhost:3000/v2/en/cards" , CardResume )
3937
@@ -55,17 +53,17 @@ async def test_endpoint(self, mock_fetch_list, mock_fetch):
5553 @patch ("tcgdexsdk.endpoints.Endpoint.fetch_list" )
5654 async def test_language (self , mock_fetch_list , mock_fetch ):
5755 api = TCGdex ()
58-
56+
5957 # Default language should be english
6058 self .assertEqual (api .getLanguage (), Language .EN )
61-
59+
6260 # Card should be fetched in english
6361 await api .card .get ("swsh1-136" )
6462 mock_fetch .assert_called_once_with (api , f"{ api .getEndpoint ()} /en/cards/swsh1-136" , Card )
6563
6664 # Card should be fetched in french
6765 api .setLanguage (Language .FR )
68-
66+
6967 # Test that the language is set correctly
7068 self .assertEqual (api .getLanguage (), Language .FR )
7169 await api .card .get ("swsh1-136" )
@@ -74,25 +72,25 @@ async def test_language(self, mock_fetch_list, mock_fetch):
7472 @_use_cassette
7573 async def test_fr (self ):
7674 tcg = TCGdex (Language .FR )
77- res = await tcg .card .get (' swsh3-136' )
78- self .assertEqual (res .name , ' Fouinar' )
79- tcg2 = TCGdex ('fr' )
80- res = await tcg2 .card .get (' swsh3-136' )
81- self .assertEqual (res .name , ' Fouinar' )
75+ res = await tcg .card .get (" swsh3-136" )
76+ self .assertEqual (res .name , " Fouinar" )
77+ tcg2 = TCGdex ("fr" )
78+ res = await tcg2 .card .get (" swsh3-136" )
79+ self .assertEqual (res .name , " Fouinar" )
8280
8381 @_use_cassette
8482 async def test_query_equal (self ):
8583 tcg = TCGdex (Language .EN )
86- res = await tcg .card .list (Query ().equal (' name' , ' Furret' ))
84+ res = await tcg .card .list (Query ().equal (" name" , " Furret" ))
8785 for card in res :
88- self .assertEqual (card .name , ' Furret' )
89-
86+ self .assertEqual (card .name , " Furret" )
87+
9088 @_use_cassette
9189 async def test_query_not_equal (self ):
9290 tcg = TCGdex ()
93- res = await tcg .card .list (Query ().notEqual (' name' , ' Furret' ))
91+ res = await tcg .card .list (Query ().notEqual (" name" , " Furret" ))
9492 for card in res :
95- self .assertNotEqual (card .name , ' Furret' )
93+ self .assertNotEqual (card .name , " Furret" )
9694
9795 @_use_cassette
9896 async def test_card_resume (self ):
0 commit comments