~mvo/unattended-upgrades/xz-support

« back to all changes in this revision

Viewing changes to test/test_log_install_progress.py

  • Committer: Michael Vogt
  • Date: 2013-01-16 07:25:52 UTC
  • mfrom: (254.2.10 verbose)
  • Revision ID: michael.vogt@ubuntu.com-20130116072552-vtl9jcek0qxbfvot
merged  lp:~mvo/unattended-upgrades/verbose 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import apt_pkg
 
4
import logging
 
5
import os
 
6
import mock
 
7
import sys
 
8
import tempfile
 
9
import unittest
 
10
 
 
11
sys.path.insert(0, "..")
 
12
from unattended_upgrade import LogInstallProgress
 
13
 
 
14
 
 
15
class MockOptions:
 
16
    dry_run = False
 
17
    debug = False
 
18
    verbose = False
 
19
 
 
20
 
 
21
class TestLogInstallProgress(unittest.TestCase):
 
22
 
 
23
    def setUp(self):
 
24
        self.tempdir = tempfile.mkdtemp()
 
25
        apt_pkg.init()
 
26
        self.mock_options = MockOptions()
 
27
 
 
28
    def test_log_installprogress(self):
 
29
        logdir = os.path.join(self.tempdir, "mylog")
 
30
        apt_pkg.config.set("Unattended-Upgrade::LogDir", logdir)
 
31
        logging.root.handlers = []
 
32
        _setup_logging(self.mock_options)
 
33
        self.assertTrue(os.path.exists(logdir))
 
34
 
 
35
 
 
36
if __name__ == "__main__":
 
37
    logging.basicConfig(level=logging.DEBUG)
 
38
    unittest.main()