async def test_query_search() -> None: client = Client() found = False async for item in client.search(query=TEST_ITEM.name): if item.name == TEST_ITEM.name and item.id == TEST_ITEM.id: found = True assert found
async def test_item_id_search() -> None: client = Client() found = False async for item in client.search(item_ids=[TEST_ITEM.id]): if item.name == TEST_ITEM.name and item.id == TEST_ITEM.id: found = True assert found
async def test_wearable_search() -> None: client = Client() found = False async for item in client.search(query=TEST_ITEM.name, species_id=TEST_PET.species, color_id=TEST_PET.color): if item.name == TEST_ITEM.name and item.id == TEST_ITEM.id: found = True assert found
async def test_query_exact_search_multiple() -> None: client = Client() result_ids = [] async for item in client.search( item_names=[TEST_ITEM.name, TEST_ITEM_TWO.name]): result_ids.append(item.id) found = TEST_ITEM.id in result_ids and TEST_ITEM_TWO.id in result_ids assert found
async def test_statefulness() -> None: client = Client() found = False async for item in client.search(query=TEST_ITEM.name): if item.name == TEST_ITEM.name and item.id == TEST_ITEM.id: found = True pet = await client.fetch_neopet(color=TEST_PET.color, species=TEST_PET.species) assert found and pet
async def test_flat_search() -> None: client = Client() query = "pile of dung" # currently, there are 2 search results for this expected = 2 # so we'll also use this as a limit, just in case items = await client.search(query=query).flatten() assert len(items) >= expected
async def main(): dti_client = Client() sorted_species = sorted(await dti_client.all_species(), key=lambda s: s.name) for species in sorted_species: print( f"{species.name} can have this many colors: {len(await species.colors())}" )
async def main(): dti_client = Client() try: pet = await dti_client.fetch_neopet_by_name("diceroll123456789") with open("./pet.png", "wb") as fp: await pet.render(fp) except NeopetNotFound as e: # raised if the pet by that name does not exist print(e)
async def test_item_id_search_broken() -> None: client = Client() with pytest.raises(InvalidItemID): async for item in client.search(item_ids=[1]): print(item)
async def test_uncached_call() -> None: client = Client() cacheless_before = client._state.is_cached is False await client.get_species("Red") assert cacheless_before and client._state.is_cached
async def test_impossible_pet_name() -> None: client = Client() with pytest.raises(NeopetNotFound): await client.fetch_neopet_by_name("thyassa_thyassa_thyassa") # too long!
async def test_impossible_pet() -> None: client = Client() with pytest.raises(InvalidColorSpeciesPair): await client.fetch_neopet(color="Apple", species="Aisha")
async def main(): dti_client = Client() async for item in dti_client.search(item_ids=[81162]): print(item)