Back to index

obnam  1.1
vfs_local_tests.py
Go to the documentation of this file.
00001 # Copyright (C) 2008  Lars Wirzenius <liw@liw.fi>
00002 #
00003 # This program is free software; you can redistribute it and/or modify
00004 # it under the terms of the GNU General Public License as published by
00005 # the Free Software Foundation; either version 2 of the License, or
00006 # (at your option) any later version.
00007 #
00008 # This program is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 # GNU General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU General Public License along
00014 # with this program; if not, write to the Free Software Foundation, Inc.,
00015 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016 
00017 
00018 import errno
00019 import os
00020 import shutil
00021 import tempfile
00022 import unittest
00023 
00024 import obnamlib
00025 
00026 
00027 class LocalFSTests(obnamlib.VfsTests, unittest.TestCase):
00028 
00029     def setUp(self):
00030         self.basepath = tempfile.mkdtemp()
00031         self.fs = obnamlib.LocalFS(self.basepath)
00032 
00033     def tearDown(self):
00034         self.fs.close()
00035         shutil.rmtree(self.basepath)
00036 
00037     def test_joins_relative_path_ok(self):
00038         self.assertEqual(self.fs.join('foo'), 
00039                          os.path.join(self.basepath, 'foo'))
00040 
00041     def test_join_treats_absolute_path_as_absolute(self):
00042         self.assertEqual(self.fs.join('/foo'), '/foo')
00043         
00044     def test_get_username_returns_root_for_zero(self):
00045         self.assertEqual(self.fs.get_username(0), 'root')
00046     
00047     def test_get_groupname_returns_root_for_zero(self):
00048         self.assertEqual(self.fs.get_groupname(0), 'root')
00049