2424test_nft_type = BtcNftType .COLLECTION
2525
2626
27- def test_fetch_collection (requests_mock , unisat_client , collection_stats ):
27+ def test_fetch_collection_icon_code (requests_mock , unisat_client , collection_stats ):
28+ """
29+ UniSat sometimes sends only the icon *code* ― no URL.
30+ We expect `parse_collection` to prepend the static CDN prefix automatically.
31+ """
2832 requests_mock .post (
29- f"{ unisat_client .api_options .base_url } v3/market/collection/auction/collection_statistic" ,
33+ f"{ unisat_client .api_options .base_url } "
34+ "v3/market/collection/auction/collection_statistic" ,
3035 text = collection_stats ,
3136 )
3237
33- test_collection = "pixel-pepes"
34- fetch_result = unisat_client .fetch_collection (test_collection )
35- assert not fetch_result .errors , f"Fetch errors: { fetch_result .errors } "
38+ fetch_result = unisat_client .fetch_collection ("pixel-pepes" )
39+ assert not fetch_result .errors
40+
41+ parsed = unisat_client .parse_collection (fetch_result )
42+ assert not parsed .errors and len (parsed .data ) == 1
43+
44+ col : NftCollection = parsed .data [0 ]
45+ assert col .ident == "pixel-pepes"
46+ assert col .name == "Pixel Pepes"
47+ assert (
48+ col .image == "https://static.unisat.io/content/"
49+ "47c1d21c508f6d49dfde64d958f14acd041244e1bb616f9b78114b8d9dc7b945i0"
50+ )
51+ assert str (col .total_stats .floor_price ) == "0.0099"
52+ assert str (col .total_stats .volume ) == "0.399"
53+
3654
37- parse_result = unisat_client .parse_collection (fetch_result )
38- assert not parse_result .errors , f"Parse errors: { parse_result .errors } "
39- assert len (parse_result .data ) == 1
55+ def test_fetch_collection_icon_full_url (
56+ requests_mock , unisat_client , collection_stats_full_url
57+ ):
58+ """
59+ UniSat may also deliver a *fully-qualified* icon URL.
60+ In that case we should **not** touch the value.
61+ """
62+ requests_mock .post (
63+ f"{ unisat_client .api_options .base_url } "
64+ "v3/market/collection/auction/collection_statistic" ,
65+ text = collection_stats_full_url ,
66+ )
67+
68+ fetch_result = unisat_client .fetch_collection ("rune-mania-miner" )
69+ assert not fetch_result .errors
4070
41- collection = parse_result .data [0 ]
42- assert isinstance (collection , NftCollection )
43- assert collection .ident == "pixel-pepes"
44- assert collection .name == "Pixel Pepes"
71+ parsed = unisat_client .parse_collection (fetch_result )
72+ assert not parsed .errors and len (parsed .data ) == 1
73+
74+ col : NftCollection = parsed .data [0 ]
75+ assert col .ident == "rune-mania-miner"
76+ assert col .name == "Rune Mania Miner"
4577 assert (
46- collection .image
47- == "https://static.unisat.io/content/47c1d21c508f6d49dfde64d958f14acd041244e1bb616f9b78114b8d9dc7b945i0 "
78+ col .image == "https://creator-hub-prod.s3.us-east-2.amazonaws.com/"
79+ "ord-rmm_pfp_1708461604099.png "
4880 )
49- assert not collection .is_disabled
50- assert not collection .is_nsfw
51- assert collection .blockchain == Blockchain .BITCOIN
52- assert str (collection .total_stats .floor_price ) == "0.0099"
53- assert str (collection .total_stats .owners_count ) == "1563"
54- assert str (collection .total_stats .sales_count ) == "20"
55- assert str (collection .total_stats .volume ) == "0.399"
56- assert str (collection .total_stats .market_cap ) == "15.4737"
81+
82+ assert str (col .total_stats .floor_price ) == "0.0008"
5783
5884
5985def test_fetch_listings (requests_mock , unisat_client , listings_data ):
@@ -153,21 +179,6 @@ def unisat_client(fake_sleep_provider):
153179 return UnisatApi (api_key = "test_key" , sleep_provider = fake_sleep_provider )
154180
155181
156- @pytest .fixture
157- def inscription_data ():
158- return read_file ('data/unisat/inscription_data.json' )
159-
160-
161- @pytest .fixture
162- def inscription_data_edge_cases ():
163- return read_file ('data/unisat/inscription_data_edge_cases.json' )
164-
165-
166- @pytest .fixture
167- def collection_edge_cases ():
168- return read_file ('data/unisat/collection_edge_cases.json' )
169-
170-
171182@pytest .fixture
172183def listings_data ():
173184 return read_file ('data/unisat/listings.json' )
@@ -180,4 +191,11 @@ def offers_data():
180191
181192@pytest .fixture
182193def collection_stats ():
183- return read_file ('data/unisat/collection_stats.json' )
194+ """Pixel Pepes – icon **code** only."""
195+ return read_file ("data/unisat/collection_stats.json" )
196+
197+
198+ @pytest .fixture
199+ def collection_stats_full_url ():
200+ """Rune Mania Miner – icon is a full URL."""
201+ return read_file ("data/unisat/collection_stats_full_url.json" )
0 commit comments