Beispiel #1
0
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
Beispiel #2
0
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
Beispiel #3
0
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
Beispiel #4
0
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
Beispiel #5
0
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
Beispiel #6
0
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
Beispiel #7
0
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())}"
        )
Beispiel #8
0
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)
Beispiel #9
0
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)
Beispiel #10
0
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
Beispiel #11
0
async def test_impossible_pet_name() -> None:
    client = Client()
    with pytest.raises(NeopetNotFound):
        await client.fetch_neopet_by_name("thyassa_thyassa_thyassa")  # too long!
Beispiel #12
0
async def test_impossible_pet() -> None:
    client = Client()
    with pytest.raises(InvalidColorSpeciesPair):
        await client.fetch_neopet(color="Apple", species="Aisha")
Beispiel #13
0
async def main():
    dti_client = Client()
    async for item in dti_client.search(item_ids=[81162]):
        print(item)