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_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_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)
Esempio n. 4
0
    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 setUp(self):
     sdcard.power_on()
     fatfs.mkfs()
     fatfs.mount()