def test_write_data_when_bytes_is_a_full_block_does_not_pad_the_block( self): block_size = 64 segment = ReadWriteSegment(123, block_size=block_size) block_bytes = block_size * b'a' block_number = segment.write_data(block_bytes) self.assertEqual(segment.read_block(block_number), block_bytes) self.assertEqual(block_number, 0)
def test_write_inode_when_bytes_less_than_block_pads_the_block(self): block_size = 64 segment = ReadWriteSegment(123, block_size=block_size) block_bytes = (block_size // 2) * b'a' block_number = segment.write_inode(block_bytes, 123) padded_block = block_bytes + b'\0' * (block_size - len(block_bytes)) self.assertEqual(segment.read_block(block_number), padded_block) self.assertEqual(block_number, 0)