Exemplo n.º 1
0
 def test_is_full_false(self):
     self.cls = ds.DataBlock(index=0)
     input_data = bytes(self.cls.address * ds.BLOCK_SIZE) + \
                  b'this is test data\x00\x00\x00'
     with open(PATH, 'wb') as f:
         f.write(input_data)
     self.cls = ds.DataBlock(device=device_io.Disk(PATH), index=0)
     self.assertFalse(self.cls.is_full())
Exemplo n.º 2
0
 def test_read(self):
     self.cls = ds.DataBlock(index=0)
     input_data = bytes(self.cls.address * ds.BLOCK_SIZE) + \
                  b'this is test data\x00\x00\x00'
     with open(PATH, 'wb') as f:
         f.write(input_data)
     self.cls = ds.DataBlock(device=device_io.Disk(PATH), index=0)
     expected = 'this is test data'
     output = self.cls.data
     self.assertEqual(output, expected)
Exemplo n.º 3
0
 def test_append_return_no_device_2(self):
     self.cls = ds.DataBlock()
     extra_data = self.cls.append(
         'this is test data   that is really really long',
         write_through=False)
     self.assertEqual(self.cls.data, 'this is test data   ')
     self.assertEqual(extra_data, 'that is really really long')
Exemplo n.º 4
0
 def test_write(self):
     self.cls = ds.DataBlock(index=0)
     expected = bytes(self.cls.address * ds.BLOCK_SIZE) + \
                b'this is test data\x00\x00\x00'
     self.cls._device = device_io.Disk(PATH)
     self.cls.data = 'this is test data'
     self.cls.__write__()
     with open(PATH, 'rb') as f:
         output = f.read()
     self.assertEqual(output, expected)
Exemplo n.º 5
0
 def setUp(self):
     ds.BLOCK_SIZE = 20
     device_io.BLOCK_SIZE = 20
     ds.NUM_DATA_BLOCKS = 10
     self.cls = ds.DataBlock()
     open(PATH, 'a').close()
Exemplo n.º 6
0
 def test_add_to_address_list(self):
     block = ds.DataBlock()
     block.index = 1
     self.cls._add_to_address_list(block=block, write_through=False)
     self.assertEqual(self.cls.address_direct, [1, 0, 0, 0, 0])