def test_mount_unmount(self): fatfs.mkfs() self.assertFalse(fatfs.is_mounted()) fatfs.mount() self.assertTrue(fatfs.is_mounted()) fatfs.mount() self.assertTrue(fatfs.is_mounted()) fatfs.unmount() self.assertFalse(fatfs.is_mounted())
def test_no_filesystem(self): # trash FAT table sdcard.write(0, bytes([0xFF] * sdcard.BLOCK_SIZE)) self.assertFalse(fatfs.is_mounted()) try: fatfs.mount() self.fail("should have raised") except OSError as e: self.assertEqual(e.args[0], 19) # ENODEV self.assertFalse(fatfs.is_mounted())
def test_sd_power(self): sdcard.power_off() self.assertFalse(fatfs.is_mounted()) self.assertRaises(fatfs.FatFSError, fatfs.mount) sdcard.power_on() self.assertFalse(fatfs.is_mounted()) fatfs.mkfs() fatfs.mount() self.assertTrue(fatfs.is_mounted()) sdcard.power_off() self.assertFalse(fatfs.is_mounted())
def test_no_filesystem(self): # trash FAT table sdcard.write(0, bytes([0xFF] * sdcard.BLOCK_SIZE)) self.assertFalse(fatfs.is_mounted()) try: fatfs.mount() self.fail("should have raised") except fatfs.FatFSError as e: self.assertIsInstance(e, fatfs.NoFilesystem) # check that the proper error code is set on the NoFilesystem subclass self.assertEqual(e.args[0], fatfs.FR_NO_FILESYSTEM) self.assertFalse(fatfs.is_mounted())
def test_unmounted(self): fatfs.unmount() fatfs.mkfs() self.assertFalse(fatfs.is_mounted()) for name, call in self.UNMOUNTED_METHODS: function = getattr(fatfs, name) function(*call) self.assertFalse(fatfs.is_mounted()) for name, call in self.MOUNTED_METHODS: function = getattr(fatfs, name) try: function(*call) self.fail("should have raised") except OSError as e: self.assertEqual(e.args[0], 19) # ENODEV
def test_unmounted(self): fatfs.unmount() fatfs.mkfs() self.assertFalse(fatfs.is_mounted()) for name, call in self.UNMOUNTED_METHODS: function = getattr(fatfs, name) function(*call) self.assertFalse(fatfs.is_mounted()) for name, call in self.MOUNTED_METHODS: function = getattr(fatfs, name) try: function(*call) self.fail("should have raised") except fatfs.FatFSError as e: self.assertIsInstance(e, fatfs.NotMounted) # check that the proper error code is set on the NotMounted subclass self.assertEqual(e.args[0], fatfs.FR_NOT_READY)
def test_mounted(self): fatfs.mkfs() fatfs.mount() self.assertTrue(fatfs.is_mounted()) for name, call in self.MOUNTED_METHODS: function = getattr(fatfs, name) function(*call) for name, call in self.UNMOUNTED_METHODS: function = getattr(fatfs, name) try: function(*call) self.fail("should have raised") except fatfs.FatFSError as e: self.assertEqual(e.args[0], fatfs.FR_LOCKED)