Ejemplo n.º 1
0
 def test_state(self):
     b1 = Block('piston')
     b2 = b1.state(facing='up')
     self.assertEqual(b1.block_id, 'piston')
     self.assertEqual(b1.block_state, BlockState())
     self.assertEqual(b2.block_id, 'piston')
     self.assertEqual(b2.block_state, BlockState(facing='up'))
Ejemplo n.º 2
0
 def test_setitem_bad_value_str(self):
     bs = BlockState()
     with self.assertRaises(ValueError):
         bs['goodkey'] = 'bad value'
Ejemplo n.º 3
0
 def test_setitem_bad_key_obj(self):
     bs = BlockState()
     with self.assertRaises(KeyError):
         bs[{'bad', 'obj'}] = 'goodvalue'
Ejemplo n.º 4
0
 def test_block_state_from_dict(self):
     b = Block('piston', dict(facing='up'))
     self.assertEqual(b.block_state, BlockState(facing='up'))
Ejemplo n.º 5
0
 def test_str_with_str_values(self):
     bs = BlockState(half='bottom', variant='quartz')
     self.assertEqual(
         set(str(bs).split(',')),
         set('half=bottom,variant=quartz'.split(',')))
Ejemplo n.º 6
0
 def test_int_value(self):
     bs = BlockState(age=4)
     self.assertEqual(bs['age'], 4)
Ejemplo n.º 7
0
 def test_bool_false(self):
     bs = BlockState(powered=False)
     self.assertEqual(bs['powered'], False)
Ejemplo n.º 8
0
 def test_eq(self):
     bs = BlockState(color='blue')
     self.assertEqual(bs, BlockState(color='blue'))
Ejemplo n.º 9
0
 def test_getitem(self):
     bs = BlockState(half='bottom', variant='quartz')
     self.assertEqual(bs['half'], 'bottom')
     self.assertEqual(bs['variant'], 'quartz')
Ejemplo n.º 10
0
 def __init__(self, block_id: str, block_state: Mapping = None):
     self.block_id: str = block_id
     self.block_state: BlockState = BlockState.sift(block_state, {})
Ejemplo n.º 11
0
 def test_with_id_and_block_state_and_data_tag(self):
     be = BlockEntity('chest', BlockState(facing='north'),
                      CompoundDataTag(lock='password'))
     self.assertEqual(be.block_id, 'chest')
     self.assertEqual(be.block_state['facing'], 'north')
     self.assertEqual(be.data_tag['lock'], StringDataTag('password'))
Ejemplo n.º 12
0
 def test_with_id_and_block_state(self):
     be = BlockEntity('chest', BlockState(facing='north'))
     self.assertEqual(be.block_id, 'chest')
     self.assertEqual(be.block_state['facing'], 'north')
Ejemplo n.º 13
0
 def test_block_state_from_braces(self):
     b = Block('piston', {'facing': 'up'})
     self.assertEqual(b.block_state, BlockState(facing='up'))
Ejemplo n.º 14
0
 def test_setitem_bad_value_obj(self):
     bs = BlockState()
     with self.assertRaises(ValueError):
         bs['goodkey'] = {'bad', 'obj'}
Ejemplo n.º 15
0
 def test_len_0(self):
     bs0 = BlockState()
     self.assertEqual(len(bs0), 0)
Ejemplo n.º 16
0
 def test_set_then_get(self):
     bs = BlockState()
     bs['color'] = 'blue'
     self.assertEqual(bs['color'], 'blue')
Ejemplo n.º 17
0
 def test_len_1(self):
     bs1 = BlockState(color='blue')
     self.assertEqual(len(bs1), 1)
Ejemplo n.º 18
0
 def test_overwrite(self):
     bs = BlockState(color='blue')
     self.assertEqual(bs['color'], 'blue')
     bs['color'] = 'red'
     self.assertEqual(bs['color'], 'red')
Ejemplo n.º 19
0
 def test_len_2(self):
     bs2 = BlockState(half='bottom', variant='quartz')
     self.assertEqual(len(bs2), 2)
Ejemplo n.º 20
0
 def test_bool_true(self):
     bs = BlockState(powered=True)
     self.assertEqual(bs['powered'], True)
Ejemplo n.º 21
0
 def test_delitem(self):
     bs = BlockState(half='bottom', variant='quartz')
     self.assertEqual(bs['variant'], 'quartz')
     del bs['variant']
     with self.assertRaises(KeyError):
         shouldfail = bs['variant']
Ejemplo n.º 22
0
 def test_str_default(self):
     bs = BlockState()
     self.assertEqual(str(bs), 'default')
Ejemplo n.º 23
0
 def test_setitem_bad_key_str(self):
     bs = BlockState()
     with self.assertRaises(KeyError):
         bs['bad key'] = 'goodvalue'
Ejemplo n.º 24
0
 def test_str_with_all_values(self):
     bs = BlockState(powered=True, age=7, color='green')
     self.assertEqual(
         set(str(bs).split(',')),
         set('powered=true,age=7,color=green'.split(',')))
Ejemplo n.º 25
0
 def test_block_with_id_and_block_state(self):
     b = Block('piston', BlockState(facing='up'))
     self.assertEqual(b.block_id, 'piston')
     self.assertEqual(b.block_state, BlockState(facing='up'))