11import unittest
22from typing import Callable
33from unittest .mock import patch
4- from warnings import deprecated
4+
55import vcr
66
77from tcgdexsdk import Language , TCGdex
1414from tcgdexsdk .models .StringEndpoint import StringEndpoint
1515from tcgdexsdk .query import Query
1616
17+
1718def _use_cassette (test : Callable ) -> Callable :
1819 return vcr .use_cassette (f"tests/.fixtures/{ test .__name__ } .yaml" )(test )
1920
2021
2122class APITest (unittest .IsolatedAsyncioTestCase ):
2223 def setUp (self ):
2324 self .api = TCGdex (Language .EN )
24-
25-
26- @deprecated ("this test is deprecated" )
25+
2726 @patch ("tcgdexsdk.endpoints.Endpoint.fetch" )
2827 @patch ("tcgdexsdk.endpoints.Endpoint.fetch_list" )
2928 async def test_uri (self , mock_fetch_list , mock_fetch ):
3029 api = TCGdex (Language .EN )
31-
30+
3231 api .URI = "http://localhost:3000/v2"
33-
32+
3433 await api .card .get ("swsh1-136" )
3534 mock_fetch .assert_called_once_with (api , "http://localhost:3000/v2/en/cards/swsh1-136" , Card )
36-
35+
3736 await api .card .list ()
3837 mock_fetch_list .assert_called_once_with (api , "http://localhost:3000/v2/en/cards" , CardResume )
3938
@@ -55,17 +54,17 @@ async def test_endpoint(self, mock_fetch_list, mock_fetch):
5554 @patch ("tcgdexsdk.endpoints.Endpoint.fetch_list" )
5655 async def test_language (self , mock_fetch_list , mock_fetch ):
5756 api = TCGdex ()
58-
57+
5958 # Default language should be english
6059 self .assertEqual (api .getLanguage (), Language .EN )
61-
60+
6261 # Card should be fetched in english
6362 await api .card .get ("swsh1-136" )
6463 mock_fetch .assert_called_once_with (api , f"{ api .getEndpoint ()} /en/cards/swsh1-136" , Card )
6564
6665 # Card should be fetched in french
6766 api .setLanguage (Language .FR )
68-
67+
6968 # Test that the language is set correctly
7069 self .assertEqual (api .getLanguage (), Language .FR )
7170 await api .card .get ("swsh1-136" )
@@ -74,25 +73,25 @@ async def test_language(self, mock_fetch_list, mock_fetch):
7473 @_use_cassette
7574 async def test_fr (self ):
7675 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' )
76+ res = await tcg .card .get (" swsh3-136" )
77+ self .assertEqual (res .name , " Fouinar" )
78+ tcg2 = TCGdex ("fr" )
79+ res = await tcg2 .card .get (" swsh3-136" )
80+ self .assertEqual (res .name , " Fouinar" )
8281
8382 @_use_cassette
8483 async def test_query_equal (self ):
8584 tcg = TCGdex (Language .EN )
86- res = await tcg .card .list (Query ().equal (' name' , ' Furret' ))
85+ res = await tcg .card .list (Query ().equal (" name" , " Furret" ))
8786 for card in res :
88- self .assertEqual (card .name , ' Furret' )
89-
87+ self .assertEqual (card .name , " Furret" )
88+
9089 @_use_cassette
9190 async def test_query_not_equal (self ):
9291 tcg = TCGdex ()
93- res = await tcg .card .list (Query ().notEqual (' name' , ' Furret' ))
92+ res = await tcg .card .list (Query ().notEqual (" name" , " Furret" ))
9493 for card in res :
95- self .assertNotEqual (card .name , ' Furret' )
94+ self .assertNotEqual (card .name , " Furret" )
9695
9796 @_use_cassette
9897 async def test_card_resume (self ):
0 commit comments