Skip to content

Commit

Permalink
Merge pull request #95 from OpenRarity/vicky/skip_external_resolver_t…
Browse files Browse the repository at this point in the history
…ests

Small fixes
  • Loading branch information
vickygos authored Oct 28, 2022
2 parents 4f9be7b + 1e06280 commit bf53aef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 14 additions & 2 deletions open_rarity/resolver/opensea_api_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,22 @@ def read_collection_data_from_file(expected_supply: int, slug: str) -> list[Toke
len(tokens_data),
expected_supply,
)
non_null_tokens = 0
if len(tokens_data) > 0:
for token_data in tokens_data:
assert token_data["metadata_dict"]
tokens.append(Token.from_dict(token_data))
if token_data["metadata_dict"]:
non_null_tokens += 1
tokens.append(Token.from_dict(token_data))
null_tokens = len(tokens_data) - non_null_tokens
if null_tokens:
msg = (
f"Warning: Data cache file had empty metadata for {null_tokens} "
"tokens. This is expected if those tokens are burned or "
"unrevealed. However, they are not taken into account into "
"rarity. Please check the cache file for errors."
)
logger.warning(msg)
print(msg)
logger.debug(f"Read {len(tokens)} tokens from cache file: {cache_filename}")
except FileNotFoundError:
logger.warning(f"No opensea cache file found for {slug}: {cache_filename}")
Expand Down
6 changes: 6 additions & 0 deletions tests/resolver/test_rarity_sniffer.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import pytest

from open_rarity.resolver.rarity_providers.rank_resolver import RankResolver
from open_rarity.resolver.rarity_providers.rarity_sniffer import RaritySnifferResolver


class TestRaritySnifferResolver:
BORED_APE_COLLECTION_ADDRESS = "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d"

@pytest.mark.skipif(
"not config.getoption('--run-resolvers')",
reason="This just verifies external APIs but should not block main library",
)
def test_get_all_ranks(self):
token_id_to_ranks = RaritySnifferResolver.get_all_ranks(
contract_address=self.BORED_APE_COLLECTION_ADDRESS
Expand Down

0 comments on commit bf53aef

Please sign in to comment.