generated from EndstoneMC/python-example-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add more tests for the inventory api
- Loading branch information
1 parent
e9d40c2
commit 918b82f
Showing
4 changed files
with
52 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
from endstone import Player, Server | ||
from endstone.inventory import ItemStack | ||
|
||
|
||
@pytest.fixture | ||
def server(player: Player) -> Server: | ||
return player.server | ||
|
||
|
||
def test_inventory_sizes(player: Player): | ||
assert player.inventory.size == 36 | ||
assert player.inventory.max_stack_size == 254 | ||
|
||
|
||
def test_set_invalid_item(player: Player): | ||
player.inventory.set_item(35, ItemStack("item_that_does_not_exist", 1)) | ||
assert player.inventory.get_item(35) is None | ||
|
||
|
||
def test_set_empty_item(player: Player): | ||
player.inventory.set_item(35, None) | ||
assert player.inventory.get_item(35) is None | ||
|
||
|
||
def test_set_item(player: Player): | ||
player.inventory.set_item(35, ItemStack("minecraft:clock", 7)) | ||
|
||
item = player.inventory.get_item(35) | ||
assert item.type == "minecraft:clock" | ||
assert item.amount == 7 | ||
|
||
player.inventory.set_item(35, item) | ||
item = player.inventory.get_item(35) | ||
assert item.type == "minecraft:clock" | ||
assert item.amount == 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters