-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix block.py and add test for file block.py #25
Open
hashbangstudio
wants to merge
23
commits into
py3minepi:master
Choose a base branch
from
hashbangstudio:block-update
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
ed6a196
Fix block.py and add test for file
hashbangstudio ff8a464
Added missing enum34 dependency
doismellburning 4d18907
Rename test to indicate not py.test form
hashbangstudio d6db56f
Revert "Added missing enum34 dependency"
doismellburning 9a1edc7
Remove runner code in test
hashbangstudio b69f607
Remove block ordering comparisons
hashbangstudio 9182af3
Remove ordered comparison tests
hashbangstudio 1c6ec04
Undo unintentional indent change
hashbangstudio 810f99d
Update setup.py to inline with master
hashbangstudio 728b943
Fix comparison and typo
hashbangstudio acf013c
Use PEP8 method names and clarify enum test
hashbangstudio bed58c6
Fix missing func def and class naming
hashbangstudio 11bb748
Hopefully correct unintentional indent change
hashbangstudio c8dad24
Move to PEP8 compliant naming
hashbangstudio 2d3500c
Move to py.test style
hashbangstudio 3c1fd01
Rename for clarity and PEP8
hashbangstudio f42e1f3
Add eval repr test and use constant string
hashbangstudio ffb7ca3
Merge remote-tracking branch 'upstream/block-update' into block-update
hashbangstudio b677dc6
Merge remote-tracking branch 'upstream/master' into block-update
hashbangstudio a3e3a00
Fix conflict between files
hashbangstudio 8cb35c0
Add new block elements
hashbangstudio 23f43fe
Remove default type assignment
hashbangstudio 2f58179
Also remove the comment line
hashbangstudio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,123 @@ | ||
import unittest | ||
from minecraft.block import Block | ||
from minecraft.block import BlockType | ||
|
||
|
||
class TestBlock(unittest.TestCase): | ||
|
||
def test_representation(self): | ||
# Test repr | ||
b = Block(2, 8) | ||
expected_string = "Block({:d}, {:d})".format(b.type, b.data) | ||
rep = repr(b) | ||
self.assertEqual(rep, expected_string) | ||
|
||
def test_instantiation_and_with_data_function(self): | ||
block = Block(12) | ||
self.assertEqual(block.type, 12) | ||
self.assertEqual(block.data, 0) | ||
block_with_data = Block(12, 4) | ||
self.assertEqual(block_with_data.type, 12) | ||
self.assertEqual(block_with_data.data, 4) | ||
otherBlckWithData = block.withData(8) | ||
self.assertEqual(otherBlckWithData.type, 12) | ||
self.assertEqual(otherBlckWithData.data, 8) | ||
|
||
def test_backwards_compatibility(self): | ||
block = Block(12) | ||
self.assertEqual(block.type, block.id) | ||
|
||
def test_equality(self): | ||
b1 = Block(8, 3) | ||
b_same = Block(8, 3) | ||
b_diff_id = Block(12, 3) | ||
b_diff_data = Block(8, 7) | ||
b_diff_id_and_data = Block(51, 7) | ||
|
||
self.assertTrue(b1 == b1) | ||
self.assertTrue(b1 == b_same) | ||
self.assertTrue(b1 != b_diff_id) | ||
self.assertTrue(b1 != b_diff_data) | ||
self.assertTrue(b1 != b_diff_id_and_data) | ||
|
||
def test_iteration(self): | ||
id_and_data = [35, 4] | ||
b = Block(id_and_data[0], id_and_data[1]) | ||
for index, attr in enumerate(b): | ||
self.assertEqual(attr, id_and_data[index]) | ||
|
||
def test_block_constants_aliases(self): | ||
self.assertEqual(BlockType.WATER, BlockType.WATER_FLOWING) | ||
self.assertEqual(BlockType.LAVA, BlockType.LAVA_FLOWING) | ||
|
||
def test_block_constants(self): | ||
self.assertEqual(BlockType.AIR, 0) | ||
self.assertEqual(BlockType.STONE, 1) | ||
self.assertEqual(BlockType.GRASS, 2) | ||
self.assertEqual(BlockType.DIRT, 3) | ||
self.assertEqual(BlockType.COBBLESTONE, 4) | ||
self.assertEqual(BlockType.WOOD_PLANKS, 5) | ||
self.assertEqual(BlockType.SAPLING, 6) | ||
self.assertEqual(BlockType.BEDROCK, 7) | ||
self.assertEqual(BlockType.WATER_FLOWING, 8) | ||
self.assertEqual(BlockType.WATER_STATIONARY, 9) | ||
self.assertEqual(BlockType.LAVA_FLOWING, 10) | ||
self.assertEqual(BlockType.LAVA_STATIONARY, 11) | ||
self.assertEqual(BlockType.SAND, 12) | ||
self.assertEqual(BlockType.GRAVEL, 13) | ||
self.assertEqual(BlockType.GOLD_ORE, 14) | ||
self.assertEqual(BlockType.IRON_ORE, 15) | ||
self.assertEqual(BlockType.COAL_ORE, 16) | ||
self.assertEqual(BlockType.WOOD, 17) | ||
self.assertEqual(BlockType.LEAVES, 18) | ||
self.assertEqual(BlockType.GLASS, 20) | ||
self.assertEqual(BlockType.LAPIS_LAZULI_ORE, 21) | ||
self.assertEqual(BlockType.LAPIS_LAZULI_BLOCK, 22) | ||
self.assertEqual(BlockType.SANDSTONE, 24) | ||
self.assertEqual(BlockType.BED, 26) | ||
self.assertEqual(BlockType.COBWEB, 30) | ||
self.assertEqual(BlockType.GRASS_TALL, 31) | ||
self.assertEqual(BlockType.WOOL, 35) | ||
self.assertEqual(BlockType.FLOWER_YELLOW, 37) | ||
self.assertEqual(BlockType.FLOWER_CYAN, 38) | ||
self.assertEqual(BlockType.MUSHROOM_BROWN, 39) | ||
self.assertEqual(BlockType.MUSHROOM_RED, 40) | ||
self.assertEqual(BlockType.GOLD_BLOCK, 41) | ||
self.assertEqual(BlockType.IRON_BLOCK, 42) | ||
self.assertEqual(BlockType.STONE_SLAB_DOUBLE, 43) | ||
self.assertEqual(BlockType.STONE_SLAB, 44) | ||
self.assertEqual(BlockType.BRICK_BLOCK, 45) | ||
self.assertEqual(BlockType.TNT, 46) | ||
self.assertEqual(BlockType.BOOKSHELF, 47) | ||
self.assertEqual(BlockType.MOSS_STONE, 48) | ||
self.assertEqual(BlockType.OBSIDIAN, 49) | ||
self.assertEqual(BlockType.TORCH, 50) | ||
self.assertEqual(BlockType.FIRE, 51) | ||
self.assertEqual(BlockType.STAIRS_WOOD, 53) | ||
self.assertEqual(BlockType.CHEST, 54) | ||
self.assertEqual(BlockType.DIAMOND_ORE, 56) | ||
self.assertEqual(BlockType.DIAMOND_BLOCK, 57) | ||
self.assertEqual(BlockType.CRAFTING_TABLE, 58) | ||
self.assertEqual(BlockType.FARMLAND, 60) | ||
self.assertEqual(BlockType.FURNACE_INACTIVE, 61) | ||
self.assertEqual(BlockType.FURNACE_ACTIVE, 62) | ||
self.assertEqual(BlockType.DOOR_WOOD, 64) | ||
self.assertEqual(BlockType.LADDER, 65) | ||
self.assertEqual(BlockType.STAIRS_COBBLESTONE, 67) | ||
self.assertEqual(BlockType.DOOR_IRON, 71) | ||
self.assertEqual(BlockType.REDSTONE_ORE, 73) | ||
self.assertEqual(BlockType.SNOW, 78) | ||
self.assertEqual(BlockType.ICE, 79) | ||
self.assertEqual(BlockType.SNOW_BLOCK, 80) | ||
self.assertEqual(BlockType.CACTUS, 81) | ||
self.assertEqual(BlockType.CLAY, 82) | ||
self.assertEqual(BlockType.SUGAR_CANE, 83) | ||
self.assertEqual(BlockType.FENCE, 85) | ||
self.assertEqual(BlockType.GLOWSTONE_BLOCK, 89) | ||
self.assertEqual(BlockType.BEDROCK_INVISIBLE, 95) | ||
self.assertEqual(BlockType.STONE_BRICK, 98) | ||
self.assertEqual(BlockType.GLASS_PANE, 102) | ||
self.assertEqual(BlockType.MELON, 103) | ||
self.assertEqual(BlockType.FENCE_GATE, 107) | ||
self.assertEqual(BlockType.GLOWING_OBSIDIAN, 246) | ||
self.assertEqual(BlockType.NETHER_REACTOR_CORE, 247) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this changes a bit of the API we don't want to change, but we aren't testing thoroughly enough :s