@@ -0,0 +1,2279 @@
+import unittest%0Aimport mock%0Aimport tempfile%0Aimport shutil%0Aimport os%0Aimport stat%0A%0Afrom base.file import File%0Afrom cct.errors import CCTError%0A%0Aclass TestFileModule(unittest.TestCase):%0A    test_data = %22Test Data 123%22%0A%0A    def setUp(self):%0A        self.tempdir = tempfile.mkdtemp('', 'test_unit_module_file')%0A        self.testfile = os.path.join(self.tempdir, %22testfile%22)%0A        with open(self.testfile,'w') as fh:%0A            fh.write(self.test_data)%0A%0A        self.ffile = File('shell', 'shell')%0A%0A    def tearDown(self):%0A        shutil.rmtree(self.tempdir)%0A%0A    def _file_contains_test_data(self, f):%0A        with open(f, 'r') as fh:%0A            self.assertEqual(fh.read(), self.test_data)%0A%0A    def test_copy(self):%0A        dest = os.path.join(self.tempdir, %22dest%22)%0A        self.ffile.copy(self.testfile, dest)%0A        self._file_contains_test_data(dest)%0A%0A    def test_link(self):%0A        dest = os.path.join(self.tempdir, %22destlink%22)%0A        self.ffile.link(self.testfile, dest)%0A        self._file_contains_test_data(dest)%0A%0A    def test_move(self):%0A        tmp   = os.path.join(self.tempdir, %22tmpdest%22)%0A        final = os.path.join(self.tempdir, %22finaldest%22)%0A%0A        self.ffile.copy(self.testfile, tmp)%0A        self.ffile.move(tmp, final)%0A%0A        self._file_contains_test_data(final)%0A%0A    def test_remove(self):%0A        tmp = os.path.join(self.tempdir, %22rmdest%22)%0A        self.ffile.copy(self.testfile, tmp)%0A        self.ffile.remove(tmp)%0A        self.assertFalse(os.path.exists(tmp))%0A%0A    def test_removedir(self):%0A        tmp = os.path.join(self.tempdir, %22rmdest%22)%0A        os.mkdir(tmp)%0A        self.ffile.remove(tmp)%0A        self.assertFalse(os.path.exists(tmp))%0A%0A    def _test_chmod(self, modestr):%0A        self.ffile.chmod(modestr, self.testfile)%0A        mode = os.stat(self.testfile).st_mode%0A%0A        desired = int(modestr, 0)%0A        actual = mode & (stat.S_IRWXU %7C stat.S_IRWXG %7C stat.S_IRWXO)%0A%0A        self.assertEqual(desired, actual)%0A%0A    def test_chmod(self):%0A        %22%22%22%0A        We run two separate tests with two different modes just in case%0A        the testfile happened to have the same mode as one test before%0A        chmod was called.%0A        %22%22%22%0A        self._test_chmod(%220666%22)%0A        self._test_chmod(%220777%22)%0A%0Aif __name__ == '__main__':%0A    unittest.main()%0A

Add test_unit_module_file unit tests