~free.ekanayaka/landscape-client/jaunty-1.5.2.1-0ubuntu0.9.04.0

« back to all changes in this revision

Viewing changes to landscape/monitor/tests/test_rebootrequired.py

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2009-09-21 17:59:31 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090921175931-4ucv40j9ro26i3lm
Tags: 1.3.2.3-0ubuntu0.9.04.0
* New upstream release (LP: #347983):
  - Don't clear the hash_id_requests table upon resynchronize (LP #417122)
  - Include the README file in landscape-client (LP: #396260)
  - Fix client capturing stderr from run_command when constructing
    hash-id-databases url (LP: #397480)
  - Use substvars to conditionally depend on update-motd or
    libpam-modules (LP: #393454)
  - Fix reporting wrong version to the server (LP: #391225)
  - The init script does not wait for the network to be available
    before checking for EC2 user data (LP: #383336)
  - When the broker is restarted by the watchdog, the state of the client
    is inconsistent (LP: #380633)
  - Package stays unknown forever in the client with hash-id-databases
    support (LP: #381356)
  - Standard error not captured when calling smart-update (LP: #387441)
  - Changer calls reporter without switching groups, just user (LP: #388092)
  - Run smart update in the package-reporter instead of having a cronjob (LP: #362355)
  - Package changer does not inherit proxy settings (LP: #381241)
  - The ./test script doesn't work in landscape-client (LP: #381613)
  - The source package should build on all supported releases (LP: #385098)
  - Strip smart update's output (LP: #387331)
  - The fetch() timeout isn't based on activity (#389224)
  - Client can use a UUID of "None" when fetching the hash-id-database (LP: #381291)
  - Registration should use the fqdn rather than just the hostname (LP: #385730)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
 
 
3
from landscape.monitor.rebootrequired import RebootRequired
 
4
from landscape.tests.helpers import LandscapeIsolatedTest
 
5
from landscape.tests.helpers import (
 
6
    MakePathHelper, MonitorHelper, LogKeeperHelper)
 
7
 
 
8
 
 
9
class RebootRequiredTest(LandscapeIsolatedTest):
 
10
 
 
11
    helpers = [MakePathHelper, MonitorHelper, LogKeeperHelper]
 
12
 
 
13
    def setUp(self):
 
14
        super(RebootRequiredTest, self).setUp()
 
15
        self.reboot_required_filename = self.make_path("")
 
16
        self.plugin = RebootRequired(self.reboot_required_filename)
 
17
        self.monitor.add(self.plugin)
 
18
        self.mstore.set_accepted_types(["reboot-required"])
 
19
 
 
20
    def test_wb_check_reboot_required(self):
 
21
        """
 
22
        L{RebootRequired.check_reboot_required} should return C{True} if the
 
23
        reboot-required flag file is present, C{False} otherwise.
 
24
        """
 
25
        self.assertTrue(self.plugin._check_reboot_required())
 
26
        os.remove(self.reboot_required_filename)
 
27
        self.assertFalse(self.plugin._check_reboot_required())
 
28
 
 
29
    def test_wb_create_message(self):
 
30
        """
 
31
        A message should be created if and only if the reboot-required status
 
32
        of the system has changed.
 
33
        """
 
34
        self.assertEquals(self.plugin._create_message(), {"flag": True})
 
35
        self.assertEquals(self.plugin._create_message(), {})
 
36
 
 
37
    def test_send_message(self):
 
38
        """
 
39
        A new C{"reboot-required"} message should be enqueued if and only
 
40
        if the reboot-required status of the system has changed.
 
41
        """
 
42
        self.plugin.send_message()
 
43
        self.assertIn("Queueing message with updated reboot-required status.",
 
44
                      self.logfile.getvalue())
 
45
        self.assertMessages(self.mstore.get_pending_messages(),
 
46
                            [{"type": "reboot-required", "flag": True}])
 
47
        self.mstore.delete_all_messages()
 
48
        self.plugin.send_message()
 
49
        self.assertMessages(self.mstore.get_pending_messages(), [])
 
50
 
 
51
    def test_run(self):
 
52
        """
 
53
        If the server can accept them, the plugin should send
 
54
        C{reboot-required} messages.
 
55
        """
 
56
        mock_plugin = self.mocker.patch(self.plugin)
 
57
        mock_plugin.send_message()
 
58
        self.mocker.count(1)
 
59
        self.mocker.replay()
 
60
        self.plugin.run()
 
61
        self.mstore.set_accepted_types([])
 
62
        self.plugin.run()