~ubuntu-branches/ubuntu/trusty/landscape-client/trusty

« back to all changes in this revision

Viewing changes to landscape/sysinfo/tests/test_deployment.py

  • Committer: Package Import Robot
  • Author(s): Andreas Hasenack
  • Date: 2014-03-28 10:20:01 UTC
  • Revision ID: package-import@ubuntu.com-20140328102001-x229iltmzrpcc2gl
Tags: 14.01-0ubuntu3
landscape-sysinfo should ignore non existent or unreadable default
config files. (LP: #1293990)

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
from twisted.internet.defer import Deferred
7
7
 
 
8
from landscape.lib.fs import create_file
 
9
 
8
10
from landscape.sysinfo.deployment import (
9
11
    SysInfoConfiguration, ALL_PLUGINS, run, setup_logging,
10
12
    get_landscape_log_directory)
49
51
 
50
52
    def test_config_file(self):
51
53
        filename = self.makeFile()
52
 
        f = open(filename, "w")
53
 
        f.write("[sysinfo]\nsysinfo_plugins = TestPlugin\n")
54
 
        f.close()
 
54
        create_file(filename, "[sysinfo]\nsysinfo_plugins = TestPlugin\n")
55
55
        self.configuration.load(["--config", filename, "-d", self.makeDir()])
56
56
        plugins = self.configuration.get_plugins()
57
57
        self.assertEqual(len(plugins), 1)
155
155
 
156
156
        return result.addCallback(check_result)
157
157
 
 
158
    def test_missing_config_file(self):
 
159
        """The process doesn't fail if there is no config file."""
 
160
        # Existing revert in tearDown will handle undoing this
 
161
        SysInfoConfiguration.default_config_filenames = []
 
162
        result = run([])
 
163
 
 
164
        def check_result(result):
 
165
            self.assertIn("System load", self.stdout.getvalue())
 
166
 
 
167
        return result.addCallback(check_result)
 
168
 
158
169
    def test_plugins_called_after_reactor_starts(self):
159
170
        """
160
171
        Plugins are invoked after the reactor has started, so that they can