7
from testutils import setup_test_env
11
class TestLogging(unittest.TestCase):
12
""" tests the sc logging facilities """
14
def test_no_write_access_for_cache_dir(self):
15
""" test for bug LP: #688682 """
16
# make the test cache dir non-writeable
17
import softwarecenter.paths
18
cache_dir = softwarecenter.paths.SOFTWARE_CENTER_CACHE_DIR
19
# set not-writable (mode 0400)
20
os.chmod(cache_dir, stat.S_IRUSR)
21
self.assertFalse(os.access(cache_dir, os.W_OK))
22
# and then start up the logger
23
import softwarecenter.log
24
softwarecenter.log # pyflakes
25
# check that the old directory was moved aside (renamed with a ".0" appended)
26
self.assertTrue(os.path.exists(cache_dir + ".0"))
27
self.assertFalse(os.path.exists(cache_dir + ".1"))
28
# and check that the new directory was created and is now writable
29
self.assertTrue(os.path.exists(cache_dir))
30
self.assertTrue(os.access(cache_dir, os.W_OK))
33
if __name__ == "__main__":
35
logging.basicConfig(level=logging.DEBUG)